stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer icon indicating copy to clipboard operation
stm32-ws2811-ws2812-ws2812b-ws281x-tim-pwm-dma-timer copied to clipboard

St32f072c8t - usart

Open gaucho1978 opened this issue 1 year ago • 9 comments

I’m on St32f072c8t. I can use only one of these 2 pin to control a ws2812 led strip: PA14 (Alternate functions Usart2_tx and swclk) or PA12 (Alternate functions can_tx, usart_rts, tim1_etr, comp2_out, tsc_g4_io4, eventout, usb_dp) Can I use this library? I suppose no, but I’m a newbie 😁 Any hint for a beginner?

gaucho1978 avatar Apr 22 '24 20:04 gaucho1978

Sure you can. You will need to select another timer and adjust DMA for another timer (different channel) but concept will of course work.

MaJerle avatar Apr 22 '24 20:04 MaJerle

Sure you can. You will need to select another timer and adjust DMA for another timer (different channel) but concept will of course work.

Thank you for reply. I don’t understand: this library uses timer to generate pwm. But timer can be used only with specific gpio. No one of the alternate functions of my gpio are related to timer output, then I suppose I can not use this approach. Where am I wrong?

gaucho1978 avatar Apr 23 '24 20:04 gaucho1978

But you can always change the timer, which is available in your GPIO. Sadly, if there is no timer alternate function on your pin, then you cannot use this pin for signal generation.

MaJerle avatar Apr 24 '24 05:04 MaJerle

Yes, my pin doesn’t have timer as alternate function.

Is it possible to generate custom interrupts at fixed periods and toggle gpio inside that interrupts? Sorry for newbie question.

will it result in a too slow update rate for a 2 meters led strip?

gaucho1978 avatar Apr 24 '24 16:04 gaucho1978

Alternatively you may use SPI if you have MOSI on your pin? Otherwise you will need bitbanging, that will slow your CPU :)

MaJerle avatar Apr 24 '24 17:04 MaJerle

Alternatively you may use SPI if you have MOSI on your pin? Otherwise you will need bitbanging, that will slow your CPU :)

Thank you. Meanwhile I found the way to use another pin with AF timer. Now I’m reading your code to find the way to integrate it in to my code.

gaucho1978 avatar Apr 24 '24 21:04 gaucho1978

unfortunately this library is using LL driver and not HAL. I find too difficult to convert it to STM32F0xx uP, since some functions are using different number of parameters, and I obtain a lot of errors. Can I use some other github repo as starting point?

gaucho1978 avatar Apr 26 '24 15:04 gaucho1978

Driving LEDs with SPI or timer is very advanced topic and not a typical application use case with these IPs. For this reason, HAL drivers don't necessary support all the features in the every neat way. This is then when LL drivers come to play.

I do not have any other repo.

Maybe this can help you if you have access to SPI on your led pin: https://www.newinnovations.nl/post/controlling-ws2812-and-ws2812b-using-only-stm32-spi/

MaJerle avatar Apr 26 '24 16:04 MaJerle

I have no SPI in my free pins. Meanwhile i compiled with success this: https://github.com/Cpt-Quantum/STM32F0-Timer-WS2812 I made some adjustments and I need to double check everything before to try it. I hope I can do it today.

gaucho1978 avatar Apr 27 '24 06:04 gaucho1978

Anyway this repo was really useful to understand the best approach to use, the protocol, and to get support on my problem. At the end I implemented with success the same approach on stm32cube ide. Thank you very much.

gaucho1978 avatar May 14 '24 05:05 gaucho1978