Author Topic: PIC18F remappable pins  (Read 800 times)

0 Members and 1 Guest are viewing this topic.

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
PIC18F remappable pins
« on: May 16, 2020, 09:52:33 pm »
Hi,
after almost 20 years I am am using a PIC18 and it now looks very different in terms of flexibility in configuration.

Specifically I am looking at the 28-pins part PIC18F26K42T-I/SS. Here's the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/PIC18LF26-27-45-46-47-55-56-57K42-Data-Sheet-40001919E.pdf

It looks like the digital pins are remappable. What is not clear is:

1) whether I can remap ANY digital pin to be the input/output to ANY peripheral (say SPI) input/output?

2) on page 9 and 10 there is no SDO signal listed under the SPI column. I assume that is a typo? Or some other reason?

3) finally and MOST IMPORTANT, I need to be sure I can remap the SPI pins as follows (2 different ways for 2 different applications:

              PCB A       PCB B     OPTIONAL PCB C
SCK        RA5          RC5        RB5
SDO       RA6          RC6         RB6
SDI         RA7         RC7         RB7
SS          ANY          ANY        ANY     

Are all of those combinations (or at least A and B) possible?

Many thanks :)
 

Offline WattsThat

  • Frequent Contributor
  • **
  • Posts: 767
  • Country: us
Re: PIC18F remappable pins
« Reply #1 on: May 16, 2020, 10:54:53 pm »
 
The following users thanked this post: ricko_uk

Offline itdontgo

  • Regular Contributor
  • *
  • Posts: 167
  • Country: gb
    • IoT Manufacturer
Re: PIC18F remappable pins
« Reply #2 on: May 17, 2020, 12:13:44 pm »
First time I did this I glanced at the datasheet, knocked up a PCB, excitedly built it and then realised you can't map a pin anywhere you have to stick to one or two ports.

 :-[

Shameful
 
The following users thanked this post: ricko_uk

Online NorthGuy

  • Super Contributor
  • ***
  • Posts: 3146
  • Country: ca
Re: PIC18F remappable pins
« Reply #3 on: May 17, 2020, 05:22:43 pm »
1) whether I can remap ANY digital pin to be the input/output to ANY peripheral (say SPI) input/output?

No. There are groups. If you have different modules of the same kind, they are usually assigned to different groups. So, it's more or less flexible, but not universal. It's better to assign everything before making boards.

2) on page 9 and 10 there is no SDO signal listed under the SPI column. I assume that is a typo? Or some other reason?

Muxes have one output and many inputs.

To route peripheral outputs, you have registers for every package pin. You write numbers to these registers. Each peripoheral output has its own number. The  number determines which peripheral output will be selected for the given package pin. You do this with SDO and SCK (for master).

To route peripheral inputs, you have registers for every peripheral input. You write numbers to these registers. Each package pin has its own number. The  number determines which package pin will be selected for the given peripheral input. You do this with SDI, SCK (for slave), and SS.

So, there are different tables - one for inputs and one for outputs. SDO will only be in the output table, SCK will be in both, SDI and SS will be in input tables.

Note that SCK is bidirectional, so it is found in both input and output tables.

3) finally and MOST IMPORTANT, I need to be sure I can remap the SPI pins as follows (2 different ways for 2 different applications:

              PCB A       PCB B     OPTIONAL PCB C
SCK        RA5          RC5        RB5
SDO       RA6          RC6         RB6
SDI         RA7         RC7         RB7
SS          ANY          ANY        ANY     

Are all of those combinations (or at least A and B) possible?

I'm sure you can look it up in the datasheet by yourself.
« Last Edit: May 17, 2020, 05:24:28 pm by NorthGuy »
 
The following users thanked this post: ricko_uk

Offline ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1015
  • Country: gb
Re: PIC18F remappable pins
« Reply #4 on: May 17, 2020, 06:03:12 pm »
Thank you NorthGuy for the detailed explanation! :)
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: PIC18F remappable pins
« Reply #5 on: May 17, 2020, 06:07:19 pm »
First time I did this I glanced at the datasheet, knocked up a PCB, excitedly built it and then realised you can't map a pin anywhere you have to stick to one or two ports.

 :-[

Shameful

your fault for not reading the datasheet. Luckily sometimes you can get around it, once or twice i used the CLC module to pass through some peripheral outputs to other ports
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf