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:
- FRAM CS pin = P1S5 (PC1)
- Temperature ADC CS pin = A2 (PC2)
SPI (faster SPI) is connected to one peripheral:
- 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.
- Is there something that can be done to keep the same pins on the hardware, but modify the firmware to fix this issue?
- What is causing this issue?