PIC24FJ64GA002, PPS for SPI - Page 1
Forum section: electronics / general

author: Drirr
author_rank: Regular Contributor
timestamp: October 26, 2024, 12:41:13 pm
content: HiI just switched to the PIC24F series. After reading the datasheet, I noticed that I need to set up the PPS (Peripheral Pin Select) to make SPI work.I'm using the PIC24FJ64GA002 in a 28-Pin SPDIP package.On page 41 of the PIC24FJ64GA002 datasheet, there is a PPS table. I believe that these lines represent registers where I can select what is connected to RPx. For example, does "RPINR20.SDIR0 = 6" connect SDI to RP6? Are the other bits, SDIR1 and SDIR2, for connecting the same SDI to other ports? Does anyone have a functional configuration for the SPI PPS pins? Where exactly in this table can I find all the SPI1 module inputs and outputs? Do I need to set the TRIS register for PPS?Thanks, David

author: voltsandjolts
author_rank: Unknown
timestamp: October 26, 2024, 01:01:26 pm
content: e.g.https://github.com/vintagechips/ttbasic_pic24f/blob/5b3b0f14fa33c5dc2573bff9ad8bf15fa5fe9897/ttbasic.X/sci.c#L16

author: Drirr
author_rank: Regular Contributor
timestamp: October 26, 2024, 01:28:57 pm
content: @voltsandjolts, thanks for the reply.TRISBbits.TRISB10 = 0; // TXTRISBbits.TRISB11 = 1; // RXI see that I need to set the TRIS register.RPOR5bits.RP10R = 5; // 5 = U2TXI understand that U2TX is mapped to PGED2/TDI/RP10/CN16/PMD2/RB10, but why did he use "5"?RPINR19bits.U2RXR = 11; // 11 = RP11I understand that U2RXR is mapped to RP11.

author: voltsandjolts
author_rank: Unknown
timestamp: October 26, 2024, 01:33:06 pm
content: Probably best to read the datasheet, section 10.4 PPS

author: Drirr
author_rank: Regular Contributor
timestamp: October 26, 2024, 03:24:25 pm
content: By bad, overlook table 10-3.RPOR4bits.RP8R = 7; // RP8 as SDO1RPOR3bits.RP7R = 8; // RP7 as SCK1Thanks!

author: newtekuser
author_rank: Frequent Contributor
timestamp: October 26, 2024, 03:32:08 pm
content: I was in a similar boat a few days ago when I transitioned my project from PIC16F to PIC18F, but as I later found I didn't have to set PPS to get I2C or EUSART to work. So I wonder is setting PPS only necessary for some protocols or some devices such as your PIC24?Or is configuring PPS only necessary if you want to remap these peripherals to different ports other than the default ones? The behavior on mine seems to point to the latter in my case.

author: Drirr
author_rank: Regular Contributor
timestamp: October 26, 2024, 03:50:27 pm
content: @newtekuserI believe that for the PIC24FJ64GA002, peripheral mapping is necessary. I tried testing SPI without using PPS but had no success. Maybe someone with more experience could advise?

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 26, 2024, 04:27:15 pm
content: Yes, PIC24 connects most peripherals (If not all) through the PPS.It's an engineering marvel, connect any pin to any peripheral!PIC18s don't have PPS, or at least didn't, maybe newer ones do.

author: newtekuser
author_rank: Frequent Contributor
timestamp: October 26, 2024, 04:39:19 pm
content: Quote from: DavidAlfa on October 26, 2024, 04:27:15 pmThe PIC18F46K40 I’m using does have PPS.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 26, 2024, 05:12:45 pm
content: Some (all?) PPS units have defaults that route functions to particular pins without setting up explicitly - typically shown in the page after the pinout diagrams

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 26, 2024, 05:53:08 pm
content: AFAIK, not the case, enabling SPI without configuring PPS doesn't set any default pins, see attached pic.I recall some special peripherals not using it, perhabs I2C?

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 27, 2024, 10:09:06 am
content: Quote from: DavidAlfa on October 26, 2024, 05:53:08 pmVaries by family - it's a while since I used PIC24 but I think the PIC16F15xx have default PPS settings

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: October 27, 2024, 10:14:08 am
content: Quote from: DavidAlfa on October 26, 2024, 05:53:08 pmPPS functionality does vary quite a lot by familyI think I2C is the only non-PPS peripheral on PIC24. On PIC16F15xxx, I2C can be changes with PPS but there are some constraints on signal levels if using alternate pins.

author: voltsandjolts
author_rank: Unknown
timestamp: October 27, 2024, 10:14:18 am
content: https://developerhelp.microchip.com/xwiki/bin/view/products/mcu-mpu/8bit-pic/peripherals/pin-select/Quote

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 27, 2024, 10:15:55 am
content: PIC16F18xxx came much later, yes, they have a default PPS assignment on reset.PIC24 and dsPIC33 are way different in this matter.

author: NorthGuy
author_rank: Super Contributor
timestamp: October 29, 2024, 03:58:10 am
content: I2C requires different voltage levels and open drain outputs, so it often has dedicated pins.It is all improving with time. Newer PICs have better PPS, regardless of family.