Teensy 4.1 simultaneous SPI.transfer calls with eventhandler using LPSPI 1, 2 & 4

english2

Member
I am using a Teensy 4.1 to write to 3 dual channel MCP4922 DACs with the non blocking SPI.transfer command and an event handler (eg SPI.transfer(dmabuf, nullptr, 2, callbackHandler); ). I'm currently writing to each DAC sequentially by setting the CS pin to low, doing the transfer and moving on to the next. This works, ... slowly.

Is it possible to use SPI.transfer to start several transfers at once to LPSPI1, LPSPI3 and SPSPI4?
 
As far as I know, each of the SPI busses is completely independent so you can't trigger them at the same time. You should be able to trigger the non-blocking transfers concurrently though and you shouldn't have to wait for each one to finish I think.
 
As far as I know, each of the SPI busses is completely independent so you can't trigger them at the same time. You should be able to trigger the non-blocking transfers concurrently though and you shouldn't have to wait for each one to finish I think.

Thanks for your reply. I have managed to do concurrent writes to the 2 easily accessible SPI busses now after repinning my PCB, but there is no performance gain, possible as i'm only writing 16 bits to each at a time. Oddly, if I use the hardware CS pins 10 and 0 the transfer command doesn't seem to work at all. I tried this as I hoped that maybe using the hardware pins would result in a performance gain...
 
If you post full code, that might help.

I would expect to be able to do:

Code:
digitalWriteFast(10, LOW); //numbers are just examples.
digitalWriteFast(0, LOW);
digitalWriteFast(20, LOW);//Write HIGH in callbackHandlers.

SPI.transfer(dmabuf, nullptr, 2, callbackHandler); 
SPI3.transfer(dmabuf3, nullptr, 2, callbackHandler3);
SPI4.transfer(dmabuf4, nullptr, 2, callbackHandler4);
And I would expect the main loop to do the 3 digitalWrites, then set up 3 transfers, and then do whatever comes next in the code. (And later do whatever is in the callback handler).

As you say, I don't think it's possible to get much improvement when transferring 6 bytes though.
 
Back
Top