Page 2 of 2

Re: WS2812 LEDs - Driver

Posted: Thu May 07, 2015 4:28 pm
by Noname
Hi

So. I read the DMA and Timer section of the manuel and everything is much clearer now. Very interesting indeed.

Well, I returned to the first driver again (that one already written using ChibiOS and for a STM32F3), and according to the manual, only the streamer channel numbers changed in my case.
Streamer 2 became Streamer 7
Streamer 3 became Streamer 2
Streamer 6 became Streamer 4

The other settings (or the default ones) are ok I think, I only added the STM32_DMA_CR_CHSEL(5) that you mentioned.

But I can't really test it if it works now. I accidentally burned my unique compatible level translator (74HTC256), I have to wait that another one arrives, I also ordered a cheap USB logic analyser, I think it will help int he future :D.

But since the discovery board has 4 onboard LEDs, I have connected the 2 channels of the TIM3 to them, and slowed down the frequency of the timer (I changed the period from 1.25us to 1s) so that so that I could see the ticks of the timer, and the resulting datastream coming out of the DMA/GPIO pin.
(I disabled the master PWM2, I can't find the rights settings that fits to the modified PWM3 settings values, so I started the PWM3 slave manually, if I understood the algorithm right it won't have any repercussion on the behavior of the DMA transfers, so it's ok for debugging the code)

Well the timer 3 runs fine, but still no data on the output port, it's frustrating.

Is it normal that I can't read the values of some registers with OpenOCD???
I wanted to check if the DMA requests were triggered or not.

Image


mmh. I think I will try to activate the CC interrupts, the are triggered at the same time as the DMA request (no idea how to implement it, it will be funny :D ). :idea:

EDIT:
mmh, why is there no Capture Compare Interrupt for the TIM3 defined in the stm32f4xx.h file :?:
There are only one for the TIM1 and another one for the TIM8.

Re: WS2812 LEDs - Driver

Posted: Thu May 07, 2015 5:48 pm
by Giovanni
In TIM3 (and all other timers except 1 and 8) all interrupts are associated to the same IRQ line.

Giovanni

Re: WS2812 LEDs - Driver

Posted: Fri May 08, 2015 5:26 pm
by Noname
Hi

Well, the problem comes clearly from the DMA, they effectively get the DMA requests from the timers, but after the first attempt of transfer 2 of the 3 streamers have their transfer error flag and transfer complete flag set. No idea why that error.

But the funniest is that I realized that the author of the driver also wrote a version compatible with the F4. :evil:
Well I wasted a lot of time trying doing it, but at least I know how the DMA works now, it was still instructive.

https://github.com/omriiluz/WS2812B-LED ... EDDriver.c


But there is one strange thing.
He did exactly the same changes as I did.
He changed streamers and added the STM32_DMA_CR_CHSEL() bits to the register, nothing more.

The only differences compared to my modifications are:
- he chose TIM1 instead of the TIM3.
- therefore he had to chose DMA2 and I took the DMA1.

And that's it.

Really I don't understand. I know the TIM1 ( and TIM8) on the F4 are more advanced on the F4 as its TIM3, I haven't read the section about the TIM1 in the manual. The difference between DMA1 and DMA2 is that the DMA2 has the ability to do memory to memory transfers, which isn't necessary for that driver.
Really, it's a mystery for me.

Well, I will know try to slightly modify it to add support to several LED strings instead of only one.

Re: WS2812 LEDs - Driver

Posted: Fri May 08, 2015 7:11 pm
by Giovanni
Facing problems, it is how you understand things :)

Giovanni

Re: WS2812 LEDs - Driver

Posted: Fri May 08, 2015 9:32 pm
by Noname
Yep :)


And I know now why my version hasn't work:
(commentary on the github repository)
Change to TIM1 and DMA2 as DMA1 is not connected to AHB1


I saw it on a diagram in the manual, but in the note it was stated that it would imply that memory to memory copy wouldn't be possible, and since in the configuration of the streams the M2P parameter is used instead of M2M, I though that the GPIO were a "peripheral" and not a memory space :D

Re: WS2812 LEDs - Driver

Posted: Tue Oct 25, 2016 4:53 am
by alanwangwang
Frist WS2812 Without Clock , i don't think it can reach 800khz singal , you need to use APA102 LED SK9822 LED ,which have data and clock ,can reach 800khz

Re: WS2812 LEDs - Driver

Posted: Mon Jan 02, 2017 2:02 am
by joewa
Hi,

here is a demo that works for STM32F4: https://github.com/joewa/WS2812-LED-Driver_ChibiOS

Cheers,
Jörg