Teensy 4.1 - DMA multiple SPI slaves + writing to multiple pins simultaneously

Status
Not open for further replies.
Hi there,
I hope it is allowed to open mulitple topics for different questions.

DMA multiple SPI slaves:
On non-Teensy-environment microcontrollers I have used 12x SPI slaves all on the same bus, with different CS's and write to each one sequentially and this works well.
However I'd like to use a similar large number of SPI slaves on a Teensy 4.1, but this time use DMA to handle the transfers freeing up the micro to do other things.

- Is it possible to have many SPI slaves setup on a T4.1 and use DMA to each? The SPI transfers are write only. If so, can anyone point me in the right direction / show any examples of multiple SPI slaves with DMA?



Writing to multiple pins simultaneously:
On ATMEGA32U4's I used to write to an entire port "PORTD" etc.

- How is this accomplished on T4.1's?
Does anyone have an example of how to write to a port group such that 16x GPIO pins all toggle high / low at exactly the same time?


All the best,
Dan
 
Yes you can do SPI buss in a non blocking manor.

There is some support in the Teensy version of the SPI library with the method, which is not fully documented. :
Code:
	bool transfer(const void *txBuffer, void *rxBuffer, size_t count,  EventResponderRef  event_responder);
Which uses an EvetResponder object to signal when the transfer completes. So you can do a transfer and continue to do things. In this one you have the ability to specify a transfer Write buffer, a Receive buffer and a count. This does that many 8 bit transfers using DMA.

But again only one transfer on a buss can be done at the same time. You do have the option of having multiple SPI busses active at same time. That is if you setup SPI with some devices, SPI1 with others, both can be active. And you also have the option for SPI2 as well, but the pins are harder to use, either from the SDCard pins or from the memory chip pins on bottom of board.

And you can manipulate whole ports as well, They are not named the same as AVR ports but are labeled on T4.1 as either 6-9 (or 1-5) or a combination of both. That is Port 1 and 6 are the same pins, the difference is port 1 is in normal mode and 6 is in a higher speed mode, and the startup code initializes all of the pins into the higher speed mode. However you can not do DMA to the pins in high speed mode, so you can switch some or all of the pins on a port back to port 1... Dito for 2-7...

There is different examples of this in some recent threads, including one to read from an OV7670 camera, as well as the OctoWS...
 
Looking at non-blocking SPI transfers at the moment.

On my STM32 video library it sends 1 scanline at a time unblocked while it decodes and stores the next scanline in a double buffered loop.

The video source may be BGR8 format (for example) so I read the entire frame into a buffer then decode it to BRG565 on the fly. In essence the conversion is free because it's usually done while still waiting for the DMA transfer.

Ordered 2 4.1's so looking at changes I'll have to make in order to use them.
 
Status
Not open for further replies.
Back
Top