PIC18F remappable pins - Page 1
Forum section: electronics / projects

author: ricko_uk
author_rank: Super Contributor
timestamp: May 16, 2020, 09:25:03 pm
content: 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.pdfIt 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 andMOST 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 CSCK RA5 RC5 RB5SDO RA6 RC6 RB6SDI RA7 RC7 RB7SS ANY ANY ANYAre all of those combinations (or at least A and B) possible?Many thanks

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 16, 2020, 09:57:56 pm
content: 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.

author: ricko_uk
author_rank: Super Contributor
timestamp: May 16, 2020, 11:16:26 pm
content: Thank youwith 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 functionAnd 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

author: JPortici
author_rank: Super Contributor
timestamp: May 17, 2020, 01:58:22 am
content: 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 peripheralsthis also means that you can route the output of a peripheral to different pinsUnfortunately 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)

author: jpanhalt
author_rank: Super Contributor
timestamp: May 17, 2020, 11:06:11 am
content: 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.

author: ricko_uk
author_rank: Super Contributor
timestamp: May 17, 2020, 04:18:15 pm
content: 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 RC72) 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 blueCould someone please answer those two questions?Many thanks

author: jc101
author_rank: Frequent Contributor
timestamp: May 17, 2020, 04:57:29 pm
content: Quote from: ricko_uk on May 17, 2020, 04:18:15 pmMany colours are available in MCC, seehttps://microchipdeveloper.com/mcc:overviewfor 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).

author: ricko_uk
author_rank: Super Contributor
timestamp: May 17, 2020, 05:31:35 pm
content: Thank you jc101

author: NivagSwerdna
author_rank: Super Contributor
timestamp: May 18, 2020, 09:00:33 am
content: Quote from: JPortici on May 17, 2020, 01:58:22 amI know but the OP was obviously struggling with the datasheet so I was trying to give them an alternative visualisation.Quote from: JPortici on May 17, 2020, 01:58:22 amI know. I have only myself to blame!Will have less bodge wires in Rev 2.0