2014-10-20 04:57 PM
Hello all, I'm trying to run a ws2812 strip using a timer and DMA. I'm using the stm32f303vct6 chip at 48MHz.
The Timer is running with no prescaler, and no clock division in PWM1 mode, with a period of 60 (1.25us), for a data rate of 800kHz.For ws2812, the data is sent with 1 being longer than 0 - basically I modify the compare value with dma to get the correct output.Currently it works, for the most part, if I use a compare value of 26 for HIGH, and a compare value of 16 for LOW. However, this timing isn't perfect, and doesn't seem to work with all ws2812 LEDs. If I try to make the LOW shorter, say, 14, or the HIGH longer, say 28, weird things start happening in the output. The 1s have spikes in them.This picture shows what I see if I use 16 and 26:This is what it looks like if I change HIGH to 28:And here's a closer view of that weird spike:My code can be found here: https://github.com/synic/ws2812_test/blob/master/src/main.cWhat am I doing wrong here? As I understand, in PWM1 mode, the signal will remain HIGH until the compare value is reached, and then it should go LOW. How can it suddenly go back HIGH again like that? #stm32f3 #ws2813 #dma2014-10-20 05:26 PM
I'm not sure what the period has to do with the length of the DMA transfer.
I'd have the DMA hit on the UPDATE, having it use CC4 means you could have it hit multiple times during one period. Period = N-1 100% Pulse N 50% Pulse N/22014-10-20 05:32 PM
Drop this to 1 or 2MHz, it will ring less
GPIO_InitStructure
.
GPIO_Speed
=
GPIO_Speed_50MHz
;
2014-10-20 07:35 PM
So,
TIM_DMACmd(TIM2, TIM_DMA_Update, ENABLE);doesn't work (I'm not really sure what's going on. There's a quick pulse every period, but that's all). However,TIM_DMACmd(TIM2, TIM_DMA_CC2, ENABLE);does work. However, I'm not sure why. TIM_DMA_CC4 definitely isn't what I thought it was. I don't see an explanation of what TIM_DMA_x is in either the datasheet or the reference manual. Where do you usually find these things?Thank you!2014-10-22 12:27 PM
Nevermind, it seems that it was a bit of a fluke that TIM_DMA_CC2 worked (I'm still not sure why that worked. It shouldn't have). I tried using a different timer/port/pin and it did not work. It seems that I was right about what TIM_DMA_CC4 is; it means interrupt when the capture value has been reached on channel 4. I say seems, because I still can't find any real documentation on what the different values you can pass to TIM_DMACmd() are, let alone documentation for TIM_DMACmd itself.
What does work is enabling preload for that channel:TIM_OC4PreloadConfig(TIM2, TIM_OCPreload_Enable);2014-10-22 01:33 PM
There is typically a Windows Help .CHM file for the library, and there is documentation in-line with the functions.
For the chip the Reference Manual covers DMA function/connectivity, and the Data Sheet the pin availability. This table should illustrate the TIM to DMA channel associativity.2016-11-23 09:26 PM
I want to know if those can work with
led ,the updated version of ws2812b