Author Topic: DMA with five SPI ports simultaneously  (Read 1963 times)

0 Members and 1 Guest are viewing this topic.

Offline luiHSTopic starter

  • Frequent Contributor
  • **
  • Posts: 612
  • Country: es
DMA with five SPI ports simultaneously
« on: April 01, 2022, 06:18:08 am »
 
Hi
I have no experience with DMA, and I need to develop a project with five SPI ports using DMA. It's just about sending data to control WS2812 LEDS.

Is it possible to send data through five SPI ports at the same time using DMA? I will use RT1064 microcontrollers.
 

Offline TomS_

  • Frequent Contributor
  • **
  • Posts: 860
  • Country: gb
Re: DMA with five SPI ports simultaneously
« Reply #1 on: April 01, 2022, 06:30:52 am »
If you have 5 SPI peripherals and 5 DMA channels available it should be possible.
 
The following users thanked this post: luiHS

Offline luiHSTopic starter

  • Frequent Contributor
  • **
  • Posts: 612
  • Country: es
Re: DMA with five SPI ports simultaneously
« Reply #2 on: April 01, 2022, 07:01:17 am »
If you have 5 SPI peripherals and 5 DMA channels available it should be possible.

 
The RT1064 has 32 eDMA channels. Does this mean that it can run 32 simultaneous processes per DMA?.
It also has 4 x SPI and 1 x FlexSPI.


« Last Edit: April 01, 2022, 07:02:58 am by luiHS »
 

Online pcprogrammer

  • Super Contributor
  • ***
  • Posts: 5605
  • Country: nl
Re: DMA with five SPI ports simultaneously
« Reply #3 on: April 01, 2022, 08:20:50 am »
The RT1064 has 32 eDMA channels. Does this mean that it can run 32 simultaneous processes per DMA?.

This means that you can have 32 DMA transactions running in total. A single channel can do a single task.

It does mean that with the 5 available SPI interfaces you will be able to do your DMA setup, as long as it is possible to route the requests of the 5 SPI interfaces to different DMA channels. With the 128 sources muxible onto the 32 channels you should be ok.

Find your self the manuals for programming this device and see what you have to do to set it all up.

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1873
  • Country: se
Re: DMA with five SPI ports simultaneously
« Reply #4 on: April 01, 2022, 08:37:38 am »
As pcprogrammer says. it should be possible, given also the relatively slow SPI speed if used for WS2812 control (about 6.4 MHz if 8 bits per WS2812 "bit" are used, but it's probably possible to go lower using 4 bits/bit).

In an SDR home project with a iMX RT1021 we are simultaneously using two DMA channels for I2S in and out (up to 384 kS/s, L+R channels), one for SPI out at 45 MHz, and one for memory to memory moves at a handful of milliseconds interval.

If you are using the NXP SDK, and especially with freeRTOS adapted drivers (not sure you are using it), there's a lot of overhead.

I have stripped the drivers to the bare minimum, building your own TCD (transfer control descriptor) and using direct register access will ease the CPU load a lot - the eDMA controller in this series is not outlandishly difficult to use.

Also, remember to check what is the best priority grouping and scheduling algorithm for your use case to avoid channels starving each other (should not happen, given the speed).

Eta: WAIT! isn't the FlexSPI used only for the external flash? I'm not sure you can use it (at least, this is on the 1021).
Still, you have three FlexIOs that can be repurposed to SPI - or something more WS2812 friendly, maybe.
« Last Edit: April 01, 2022, 08:48:56 am by newbrain »
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: luiHS

Offline PlainName

  • Super Contributor
  • ***
  • Posts: 8112
  • Country: 00
Re: DMA with five SPI ports simultaneously
« Reply #5 on: April 04, 2022, 09:38:04 pm »
An alternative might be using GPIO to drive up to 8 LED signals at once. You'd use a timer to trigger the DMA which would just do memory to GPIO on each tick. However, the downside is that each DMA transfer is a bit (specifically, 8 off parallel bits) rather than byte, so you'd need to organise the source data as bytes of bitstream, orthogonal to source used to drive SPI. The plus side is each stream is synced to each other and you only need one DMA channel (and one GPIO port).
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17067
  • Country: fr
Re: DMA with five SPI ports simultaneously
« Reply #6 on: April 04, 2022, 09:48:43 pm »

Hi
I have no experience with DMA, and I need to develop a project with five SPI ports using DMA. It's just about sending data to control WS2812 LEDS.

Is it possible to send data through five SPI ports at the same time using DMA? I will use RT1064 microcontrollers.

If you're using the RT1064, I'd suggest looking at FlexIO. You should be able to generate signals for even more than 5 strings of those LEDs concurrently.
And you can sure couple this with DMA.
It's basically the idea just above, but with FlexIO, you can devise something very efficient.
 

Offline hans

  • Super Contributor
  • ***
  • Posts: 1857
  • Country: 00
Re: DMA with five SPI ports simultaneously
« Reply #7 on: April 05, 2022, 08:26:56 am »
Sorry if I'm too divergent thinking in this solution.. reason I post because IMO SPIs are quite valuable periperhals, and using them for LEDs sounds a bit overkill....

On other MCUs I've successfully used timers to control WS2812B LEDs. After all, it's a PWM with about 1/3 and 2/3 duty cycle to send 0s and 1s.
On a PIC32MX250 I've done this with the 2ch of DMA, 2x output-compare on 1 timer to control 2 LED strings. Should be easy to scale it far further.. (up to the limit of PWM/DMA channels)

If the duty cycle of each LED string is no where near 50% , you can perhaps also use a multiplexer (perhaps in the MCU if it has alternative pin locations) to switch 1 control channel between multiple strings. The data is then sent sequentially in time, but if a slight delay is not an issue, then that's very possible.

Then finally if you really do need in the other of 5 or more LED strings.. perhaps DMA'ing into 8 bits of a GPIO port is a possibility? Again use a timer to chop up the time base in 3 or 4 sections to send the normal PWM cycle with data over it. I think mikeselectricstuff has a video of that concept on YT with a PIC32.

I've not familiarized myself much with the RT micros. Perhaps I should get a Teensy. That FlexIO peripheral sounds interesting.
« Last Edit: April 05, 2022, 08:28:28 am by hans »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf