MM Teensy & SPI


New member
Related to the other question I put on this forum (and some other devices where SPI fails to work) I decided to check with my logic analyzer what was going on with my SPI communication. I have two MM Teensy reproducing the same behaviour on the ATP board from Sparkfun and the analyser (one of those cheap knockoff ones) attached. No other ports used.

Code is taken from the example on the website, and adapted to use only one device, I wanted to make as few changes as possible, even though it doesn't provide a meaningful example. CS Pin used is 55 on MM Teensy.

#include <SPI.h>  // include the new SPI library:

// using two incompatible SPI devices, A and B
const int slaveBPin = 55;

// set up the speed, mode and endianness of each device
SPISettings settingsB(16000000, MSBFIRST, SPI_MODE0); 

void setup() {
  // set the Slave Select Pins as outputs:
  pinMode (slaveBPin, OUTPUT);
  // initialize SPI:

uint8_t stat, val1, val2, result;

void loop() {
  // read three bytes from device A
  if (stat == 1) { 
   result = val1;
  } else if (stat == 2) { 
   result = val2;
  } else {
   result = 0;
  // send result to device B
  digitalWrite (slaveBPin, LOW);
  digitalWrite (slaveBPin, HIGH);

Now for the issue:

Looking at the graph from PulseView (please see attachment) it doesn't seem to correlate at all with what I am expecting to see from the code provided as I would be expecting the CS Pin (SS in Pulseview) to stay low until transmission has been finished. I might be wrong, but can someone please explain if I am doing something wrong or if there's something to look for? I'd really like to get SPI working on this device. Happy to provide more examples I tried and where I see similar behaviour.

Screenshot 2023-09-15 at 21.04.50.jpg
Your logic analyzer is fooling you. The sample rate of the analyzer [24MHz] is just too low to reliably catch all edges of a 16MHz SPI signal.

With respect to the CS signal: I think the threshold level of your analyzer (to decide whether the signal is high or low) is also playing tricks on you. Probably the digital signal is distorted when it arrives at the inner works of your analyzer.

Using your code above (and using a Teensy 4.0 with CS on pin 10), here are 2 screenshots of my logic analyzer. The upper with the analyzer sample rate set to 20MHz, the lower screenshot set at 400MHz.




please excuse the delay in my answer, appreciate your input and your explanation. If I was to lower the SPI Signal rate, would my logic analyser sample rate then catch up with these? Or is it that I cannot catch the signals at all with these cheap logic analysers?

If you lower the SPI signal to a low enough speed, then yours might work better. Especially if you can get your analyzer running at a multiple of the SPi speed.

For example 4mhz or 6mhz probably 8.
Like KurtE stated, lowering the SPI clockrate will allow your analyzer to take more samples of that alternating signal.
What will not improve is the sampling of your CS signal - here another phenomenon is present. Please check whether the analyzer connectors are OK and that the ground connection is fine.
Your analyzer is specified for use with 5V signals: "The measurement range of the Logic Analyzer is 0-5 volts, the thresholds for digital low and digital high are <0.8 V and >2V respectively". However, the 2 mentioned thresholds should generally be fine for 3V3 signals (but not guaranteed).

Thank you, both Paul and Kurt!

I tested my connections (which seem fine) and lowered the clock rate to 4mhz but the CS signal line doesn't change and always stays high. Next steps would be to check the Analyser and the MM Carrier Board, als I get the same results with two MM Teensy.

Why am I doing all this? I connected 3 displays to the MM board and none of them work while using the Adafruit libraries and/or U8g2 which otherwise work with my Picos (albeit then with other libraries. So I wanted to check what is going on with SPI and why I can't make it work.

Will post here once I received a better logic analyzer. Also, I will check what the output looks like with a regular Teensy 4.1 which is in use in another project.
but the CS signal line doesn't change and always stays high
In your first post, the PulseView screendump shows the CS going low every now and then. But with 4MHz SPI clock rate, the CS signal is always high? Weird...
Just to make sure that the CS pin is not broken, you could try
void setup() {
  pinMode(55, OUTPUT);
  digitalWrite(55, LOW);

void loop() {
and check with a multimeter instead of your analyzer.