Author Topic: PIC18F remappable pins  (Read 2314 times)

0 Members and 1 Guest are viewing this topic.

Online ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: gb
PIC18F remappable pins
« on: May 16, 2020, 09:25:03 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 :)
« Last Edit: May 16, 2020, 11:07:09 pm by ricko_uk »
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Re: PIC18F remappable pins
« Reply #1 on: May 16, 2020, 09:57:56 pm »
I find MLCC Configurator in MPLABX a useful way of exploring what is possible.  Sadly for me using dsPIC33.. I found SPI has restrictions.... you mileage may vary.
 
The following users thanked this post: ricko_uk

Online ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: gb
Re: PIC18F remappable pins
« Reply #2 on: May 16, 2020, 11:16:26 pm »
Thank you :)

with reference to the attached screenshot, what do the orange/yellow vs blue colour mean in the configurator?

Ideally I need to assign the SDO1 to RC7 and it allows me to select it but for some reason only RC5 is orange, what does that mean?

The manual says:
Blue colored pin: pins that are available to be allocated to a module.
Yellow colored pin: a possible alternate pin for an already allocated pin function

And the difference is not really clear... Anybody can explain? And ultimately is it safe to connect SDO1 to RC7? I need to be sure for the PCB connection.

Many thanks :)
« Last Edit: May 16, 2020, 11:31:16 pm by ricko_uk »
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3573
  • Country: it
Re: PIC18F remappable pins
« Reply #3 on: May 17, 2020, 01:58:22 am »
PPS is awesome! and i find the one on PICs to be more advanced and flexible than most other microcontrollers.
so, you have PERIPHERAL PPS input and PIN PPS Output.
this means that you can route only a single pin to a peripheral, but the same pin can become the input for many peripherals
this also means that you can route the output of a peripheral to different pins

Unfortunately there are restrictions in which ports can route which peripherals (i.e. CCP can only be on PORTB and PORTC) and a different package may have different ports for the same peripheral (i.e. PORTB/PORTC on 28pin, PORTB/PORTD on 48 pin) but in general you can always get the legacy mapping.

MCC is never necessary, at all. The mapping operation is damn simple and MCC is not a substitute for reading the datasheet anyway.
in the case of dsPIC, the datasheet clearly states in multiple places that in those parts the higher speed SPI can be achieved only on dedicated pins (it says that in the device summary tables, pps section, spi section, electrical specifications)

 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 4005
  • Country: us
Re: PIC18F remappable pins
« Reply #4 on: May 17, 2020, 11:06:11 am »
I concur with JPortici.  There are limitations to what can be switched to what.  Aside from CCP/PWM, those often apply to communications. 

Table 1 in the datasheet will tell you what pins can do what.
 
The following users thanked this post: ricko_uk

Online ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: gb
Re: PIC18F remappable pins
« Reply #5 on: May 17, 2020, 04:18:15 pm »
Thank you JPortici and jpanhalt,
nice explanation which clarified some of my questions! :)

Maybe I am missing something but Table 1 does not provide the information I am looking for. Namely:
1) whether I can route SDO1 to RC7
2) with reference to my previous picture, why does SDO1 shows blue icons for all port B and C but shows orange only for RC4 and what does that mean (orange/yellow box vs blue

Could someone please answer those two questions?

Many thanks :)
 

Offline jc101

  • Frequent Contributor
  • **
  • Posts: 729
  • Country: gb
Re: PIC18F remappable pins
« Reply #6 on: May 17, 2020, 04:57:29 pm »
Thank you JPortici and jpanhalt,
nice explanation which clarified some of my questions! :)

Maybe I am missing something but Table 1 does not provide the information I am looking for. Namely:
1) whether I can route SDO1 to RC7
2) with reference to my previous picture, why does SDO1 shows blue icons for all port B and C but shows orange only for RC4 and what does that mean (orange/yellow box vs blue

Could someone please answer those two questions?

Many thanks :)

Many colours are available in MCC, see https://microchipdeveloper.com/mcc:overview for them all.

To answer the questions...

1) Yes, looks mappable, does it not change to a green padlock when you click on block highlighted in your screenshot?  Looking at the table on page 10 of the data sheet for that PIC SDO1 is mappable to any output pin.  I suspect if you set RC7 to a GPIO Input pin it would not be available to SDO1.

2) The Yellow against SDO1, I think it's because the matrix is 2 dimensional.  It isn't just what function that can be mapped to a pin, but also what pin can be mapped to a function.  So, in this case, RC5 could be mapped to various alternative functions.  It's the mapping from the pin's point of view, not the Peripheral (UART etc).
 
The following users thanked this post: ricko_uk

Online ricko_ukTopic starter

  • Super Contributor
  • ***
  • Posts: 1158
  • Country: gb
Re: PIC18F remappable pins
« Reply #7 on: May 17, 2020, 05:31:35 pm »
Thank you jc101 :)
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2507
  • Country: gb
Re: PIC18F remappable pins
« Reply #8 on: May 18, 2020, 09:00:33 am »
MCC is never necessary, at all. The mapping operation is damn simple and MCC is not a substitute for reading the datasheet anyway.
I know but the OP was obviously struggling with the datasheet so I was trying to give them an alternative visualisation.
in the case of dsPIC, the datasheet clearly states in multiple places that in those parts the higher speed SPI can be achieved only on dedicated pins (it says that in the device summary tables, pps section, spi section, electrical specifications)
I know.  I have only myself to blame!  :-DD  Will have less bodge wires in Rev 2.0  :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf