Author Topic: PIC24FJ64GA002, PPS for SPI  (Read 1311 times)

0 Members and 1 Guest are viewing this topic.

Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 82
PIC24FJ64GA002, PPS for SPI
« on: October 26, 2024, 12:41:13 pm »
Hi

I 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
 


Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 82
Re: PIC24FJ64GA002, PPS for SPI
« Reply #2 on: October 26, 2024, 01:28:57 pm »
@voltsandjolts, thanks for the reply.

TRISBbits.TRISB10 = 0; // TX
TRISBbits.TRISB11 = 1; // RX

I see that I need to set the TRIS register.

RPOR5bits.RP10R = 5; // 5 = U2TX

I understand that U2TX is mapped to PGED2/TDI/RP10/CN16/PMD2/RB10, but why did he use "5"?

RPINR19bits.U2RXR = 11; // 11 = RP11

I understand that U2RXR is mapped to RP11.
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2504
  • Country: gb
Re: PIC24FJ64GA002, PPS for SPI
« Reply #3 on: October 26, 2024, 01:33:06 pm »
Probably best to read the datasheet, section 10.4 PPS
 
The following users thanked this post: Drirr

Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 82
Re: PIC24FJ64GA002, PPS for SPI
« Reply #4 on: October 26, 2024, 03:24:25 pm »
By bad, overlook table 10-3.  :-[

RPOR4bits.RP8R = 7;      // RP8 as SDO1
RPOR3bits.RP7R = 8;      // RP7 as SCK1

Thanks!
« Last Edit: October 26, 2024, 03:36:07 pm by Drirr »
 

Offline newtekuser

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: us
Re: PIC24FJ64GA002, PPS for SPI
« Reply #5 on: October 26, 2024, 03:32:08 pm »
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.
« Last Edit: October 26, 2024, 03:33:50 pm by newtekuser »
 

Offline DrirrTopic starter

  • Regular Contributor
  • *
  • Posts: 82
Re: PIC24FJ64GA002, PPS for SPI
« Reply #6 on: October 26, 2024, 03:50:27 pm »
@newtekuser
I 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?
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6331
  • Country: es
Re: PIC24FJ64GA002, PPS for SPI
« Reply #7 on: October 26, 2024, 04:27:15 pm »
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.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline newtekuser

  • Frequent Contributor
  • **
  • Posts: 445
  • Country: us
Re: PIC24FJ64GA002, PPS for SPI
« Reply #8 on: October 26, 2024, 04:39:19 pm »
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.

The PIC18F46K40 I’m using does have PPS.
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14101
  • Country: gb
    • Mike's Electric Stuff
Re: PIC24FJ64GA002, PPS for SPI
« Reply #9 on: October 26, 2024, 05:12:45 pm »
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
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6331
  • Country: es
Re: PIC24FJ64GA002, PPS for SPI
« Reply #10 on: October 26, 2024, 05:53:08 pm »
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?

« Last Edit: October 26, 2024, 05:58:36 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14101
  • Country: gb
    • Mike's Electric Stuff
Re: PIC24FJ64GA002, PPS for SPI
« Reply #11 on: October 27, 2024, 10:09:06 am »
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?

(Attachment Link)
Varies by family - it's a while since I used PIC24 but I think the PIC16F15xx have default PPS settings
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 14101
  • Country: gb
    • Mike's Electric Stuff
Re: PIC24FJ64GA002, PPS for SPI
« Reply #12 on: October 27, 2024, 10:14:08 am »
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?

(Attachment Link)
PPS functionality does vary quite a lot by family
I 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.

Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2504
  • Country: gb
Re: PIC24FJ64GA002, PPS for SPI
« Reply #13 on: October 27, 2024, 10:14:18 am »
https://developerhelp.microchip.com/xwiki/bin/view/products/mcu-mpu/8bit-pic/peripherals/pin-select/

Quote
Some Microchip customers may be familiar with PPS from the PIC24 product line. PPS for the 8-bit family differs in that each digital peripheral input signal is connected to a pin by default. This stands in contrast to PPS for the PIC24 products, where peripherals are left unconnected by default. For 8-bit PPS, peripheral input and output signals need to be selected before the peripheral is enabled. Then the peripheral should be enabled after both input and output selections have been completed.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6331
  • Country: es
Re: PIC24FJ64GA002, PPS for SPI
« Reply #14 on: October 27, 2024, 10:15:55 am »
PIC16F18xxx came much later, yes, they have a default PPS assignment on reset.
PIC24 and dsPIC33 are way different in this matter.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 3279
  • Country: ca
Re: PIC24FJ64GA002, PPS for SPI
« Reply #15 on: October 29, 2024, 03:58:10 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf