stm32f103_fastNP icon indicating copy to clipboard operation
stm32f103_fastNP copied to clipboard

Problem with running LEDs

Open birkoni5 opened this issue 4 years ago • 1 comments

Dear Sir,

I used your CubeMX file to generate code for my project, then I added files to run WS2812b LEDs. It is working but not quite well. For example, if I set all pixels to red (255, 0, 0), it shows red, green and blue colors alternately, and also some pixels are turned off, as shown in the picture below. Do you have any ideas how can I fix it?

IMG_20200418_125143

Best regards, Toni

birkoni5 avatar Apr 18 '20 11:04 birkoni5

Hmmm. Are you able to measure the LED timings with a logic analyzer? I wonder if the timings are off. If you are using CubeMX to generate code, can you please confirm that the Timer2 frequency is set for 72MHz and not something lower? The pulse generator assumes a 72MHz timer frequency (this is configurable in a header file but I haven't tried anything slower than 72MHz). The initial state of my project assumes you are running with an 8MHz crystal, but if you regenerated code, it's possible you had to change this.

Another possible thing that can get you is the compiler optimization level. I needed to set the GCC optimization level to at least -O1, otherwise the produced code is too slow. I am not sure if CubeMX is smart enough to preserve this setting. It might be good to check the generated Makefile to see what the OPT level is.

Does my original demo code work as-is? Are you able to see a smooth pattern of brightness fading?

evilwombat avatar Apr 21 '20 10:04 evilwombat