DMA priorities

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

DMA priorities

Post by rubenswerk »

Hello,

I'm working on a WS2812 LED project. The LEDs are driven by a STM32F4 which writes to the IO port at 2.4MHz via DMA2, resulting in 2.4MB/s data throughput.
I receive the control data for the LEDs via Ethernet. Everything works fine.

Now I want to switch from Ethernet to SD card as signal source. It is connected on SPI1, which is also tied to DMA2.
In general, this seems to work as well, but the LEDs start to flicker a little bit as soon as I start reading from the SD card. The WS2812 protocol needs very stable timing, otherwise the LEDs receive wrong data.
SPI clock for SD card is 10.5Mhz, so a maximum of ~1.3MB/s.

I tried to set all DMA priorities in mcuconf.h to 0 and set my own WS2812 priority to 3, but this makes no difference.
Is it possible that the F4's DMA is overloaded with this amount of data? I expected that the F4 @168MHz should be able to handle a lot of traffic.

Does a SPI DMA transfer block the DMA for such a long time? The LEDs accept a jitter of ~0.1 microseconds.

I wonder because as far as I know the Ethernet uses DMA (its own DMA?) as well but there are no problems when I generate high Ethernet traffic in parallel with WS2812 protocol. So whats the problem here, is it the memory bus, the DMA itself, ...?

Would it have been better to choose SPI2 or SPI3 for the SD card, because those are on DMA1?

Thanks, RuWe
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: DMA priorities

Post by Giovanni »

Hi,

SPI DMA transfers frame by frame, so it generates very sporadic transfers to memory (two per frame because RX and TX but APB accesses are slow).

What kind of jitter are you getting? It would be worth trying use the other DMA for SPI and see if something changes.

Also, are you sure that the DMA priorities are really as you expect them to be? I wouldn't rule out a SW bug (DMA registers inspection).

Giovanni
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: DMA priorities

Post by rubenswerk »

Hello,

I checked DMA registers at runtime, the priorities seem to be correct. I also moved SPI1 to a higher DMA stream number (lower hardware priority), but it makes no difference.

I will try to move SD card to SPI2 or SPI3 which are located on DMA1 instead of DMA2, but this will take some time due to PCB modification. However this does not fit into my final hardware concept, because I have planned to use SDIO mode in the future, which uses DMA2...

I have to think about how to measure the actual jitter. I only have a cheap scope with low memory. I should trigger when a LED blinks. WS2812 LEDs have controller and LED together in the same package, so there's no electrical connection to the RGB pins.

It looks like switching between different DMA streams takes a lot of time and therefore causes a remarkable jitter.

Thanks so far.
Post Reply