Teensy 3.2 to 4.0 with a SPI slave throught platformIO


New member

I had a system board with a teensy 3.2 and a DWM1000 (with the decaDuino library) which work good enough.
I looking for upgrade the teensy to a teensy 4.0.
But, it doesn’t work.

Why a SPI code in a teensy 3.2 could not work in a teensy 4.0 ?
Do you have an idea where I should looking for ?

I hope my English is good enough.

Thank you

Warning I don't use platform IO, so not sure if that may influence the issue or not.
Also as mentioned as the Forum Rule: It helps to show an example sketch to reproduce your issue.
Also in some cases (many) it may also help to see a photo of the wiring.

Is this the library: https://github.com/irit-rmess/DecaDuino ?

Unclear what "But, it doesn't work" mean? Does it compile? Does it run?
Values different?

My 30 second look through the library it looked like it was using a standard SPI library? But again don't know what the issue is to give you better suggestions?
Ok, I understand.

So, here are my tests with the Arduino IDE (1.8.12), the Teensyduino (1.51) and
the examples codes from Decaduino : DecaDuinoTWR_server and DecaDuinoTWR_client.

I have two PCB, I gonna call : (I don't have the PCB schematics accessible :c )
PCB 3 : made for the teensy 3.2
PCB 4 : made for the teensy 4.0
there has been no change about the SPI, so I can put a teensy 3.2 on the PCB 4

My result :
Teensy 3.2 / PCB 3 : RUN OK
Teensy 3.2 / PCB 4 : RUN OK
Teensy 4.0 / PCB 3 : RUN KO (failed on the init call)
Teensy 4.0 / PCB 4 : RUN KO (failed on the init call)

I don't understand. It's should be equal, no ?
Yes and No. That is you would hope things work equally for both, both they have different core processors underneath and as such the code may assume one thing or another.

First thing I would try is to install the recently released 1.52 of Teensyduino. There was a change to SPI for T4, where it delayed a bit longer between when the CS is asserted and when it started transfers, to see if that might help.

I would also go into their header file and turn on debug. I think it is line 98: //#define DECADUINO_DEBUG
Remove the comments and see if it prints out anything useful.
I would then go into their ::init method and if does not already have it with the debug code, I would add some prints around each place that can return false to see which test is failing.
And I would print out things like it expected X and returned Y... Then go from there.

Well, It works with Teensyduino 1.52 !

Thank you so much ! Thank you for your time ! You are awesome !