Particle P1 SPI CS and SPI1 CS pins issue

I am using a P1 to communicate to multiple peripherals using the SPI busses available (SPI and SPI1).
SPI1 (slower SPI) is connected to two peripherals:

  1. FRAM CS pin = P1S5 (PC1)
  2. Temperature ADC CS pin = A2 (PC2)

SPI (faster SPI) is connected to one peripheral:

  1. Microcontroller as SPI slave, with custom firmware and particle library; CS pin = P1S3 (PC4)

While bringing up the peripheral uC with custom particle library, I was testing the communication and features with an example (i.e. standalone without the FRAM and Temperature ADC hardware and libraries). The P1 to peripheral uC communication works as expected, data being pushed to uC from the P1 and back with no trouble at all.

I imported the peripheral uC’s library to the main firmware (with the FRAM and Temperature ADC chip) and I was reading empty SPI buffer on the peripheral uC. I debugged (by removing the FRAM and ADC chip’s SPI calls), and the system worked as expected.
I later deep-dived and found that if I change the Temperature ADC chip’s CS pin from A2 (PC2) to any other pin, the peripheral uC SPI is working as expected.

From the P1’s datasheet:



From the pinout, the Temperature ADC chip’s CS pin is the default CS pin for the SPI bus. Although it is mentioned that I can use any GPIO for the CS (or SS) pin for the SPI busses, I see that I cannot.
I realize that modifying the PCB would be ideal (moving the CS pins around), but I am unable to do so since the PCBs are being used and will be a huge hurdle to hack something or replace to new boards.

  1. Is there something that can be done to keep the same pins on the hardware, but modify the firmware to fix this issue?
  2. What is causing this issue?


What do you mean with that?
You just need to enable the respective CS pin (and disable all others) in your code as needed.
You should also wrap your respective communication calls in a set of SPI.beginTransaction()SPI.endTransaction() calls.


The P1 Datasheet says that I can use any other available hardware pin for CS, I was unable to.

Yes, the SPI.transfer() calls are wrapped inside the SPI.beginTransaction() and SPI.endTransaction() calls.

How did you try?
Some code would be good to look at.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.