Teensy 4.0 Chip Select Pins

cheyward

New member
Hello PJRC Folk,

I am attempting to use SPI to interface with a Pressure Sensor (https://invensense.tdk.com/wp-content/uploads/2022/08/DS-000416-ICP-20100-v1.4.pdf). There is only one using SPI communication. I have had multiple generations of this interface and the most recent does not work. I have pinpointed the problem to the Chip-Select pin - for some Chip-Select pin selections on Teensy 4.0 this code works, for others it does not. I was operating under the assumption that any Digital IO pin should function as a Chip-Select pin (excluding some libraries, but I'm only using the standard SPI library).

I have searched through documentation on the forum and haven't found a similar issue for Teensy 4.0 as all information for standard SPI library, single device communication, says this should work.

As an example, if I use chip-select pin 16 SPI communication works, however if I use pin 7 for chip-select SPI communication does not work.

In general, the code selects parameters for the pressure sensor triggering an interrupt for each sample at 25Hz sample rate. The sensor drives a pin on Teensy low when new data is available, the interrupt triggers a data read, and the data is displayed in the next loop.

I have attached my full source code as it includes a library I wrote myself.

Thank you for any help

View attachment ICP20100_Testing.ino
View attachment ICP20100.h
View attachment ICP20100.cpp
 
I ran it here with nothing connected to the Teensy pins. These are the waveforms my scope sees on pins 7, 11, 12, 13.

file.png

Looks like pin 7 is working as a chip select, though it might be good to first drive it to logic high before you initialize the hardware.
 
If pins 7 and 8 are shorted or interfering, and pin 8 stays low, maybe your could could get into an infinite interrupt loop? Might be better to use FALLING instead of LOW with attachInterrupt.
 
Sorry, I don't see anything obvious.

As mentioned all digital pins should more or less act the same.

So maybe hardware issue? A picture might help.

for example, the picture might show if there is a bad solder joint on pin 7.

Or maybe, that you have some other hardware setup with this. For example, the Teensy Audio board, which uses pins 7 and 8.
 
Thank you Paul and Kurt for your quick responses.

At first glance, it does appear that the Chip select pin functions correctly - I am able to recreate your oscilloscope pattern, Paul - however, I am not able to consistently obtain measurements using Chip Select pin 7. To illustrate, here is the output from the exact same setup and code, only changing Chip Select from pin 16 to pin 7 on a breadboard:

SPI_Issues.png

On the left of the figure is the good Chip-Select pin (e.g. pin 16), while the bad is shown on the right. In both cases I am able to initialize device communication, however programming the device settings often does not work using pin 7 chip-select, further when samples are taken (should be at 25Hz - 0.04s sample period) they are erratic indicating something is wrong with SPI communication.

Also, per Kurt, I have attached a picture of my setup. I made a simple breakout PCB of the sensor and connections are via breadboard:

ICP20100_Setup.jpg
 

Attachments

  • SPI_Issues.jpg
    SPI_Issues.jpg
    86.3 KB · Views: 29
Looked at the datasheet. Page 38 says the interrupt pin is open drain.

You probably need to add a pullup resistor, like 4.7K to 10K. Or maybe using pinMode INPUT_PULLUP at the beginning of setup() could be enough?

My guess is it's just barely working without this when not other signal is changing nearby. Maybe. At least that's my latest troubleshoot-electronics-over-the-internet guesswork.
 
Thank you again for your response, Paul. The sensor has an internal pull-up resistor on the interrupt pin so an external one is not needed - I added one just to confirm with no change.

This is an interesting problem, I've noticed there are several pins which my code works every time. At this point, I'm not sure what else to look for, so I tested all Digital IO pins to see whether they could function as the Chip Select pin - this was the result:

SPI_Issues_Pinout.jpg

If you're not sure still I will assume this is a device issue and continue to troubleshoot on my own - I'll update the forum if I'm able to figure out this issue.

Thank you.
 
I had a bad 4.1 that did the same thing last year but got attacked on here when I brought it up. Come to find out the 4.1 had bad soldering done from the manufacture as I could not recreate the same issues with a new 4.1. It was freezing up when I used certain pins so I eventually desoldered all the usable parts and threw the rest in the trash. It was most likely a soldering issue when the chip was attached to the board and I have no way of doing that precision work and struggle at tssop, 603 but manage. I to had done a lot of troubleshooting but came to a point that all the time spent on the issue was not worth it in the long run.
God luck on this issue.
Regards,
Marathonman
 
Back
Top