ancher-bohdan / LedStrip

Adress Led Strip (ws2812) with STM32 microcontroller`s family
0 stars 0 forks source link

Data corruption after second and all subsequent calls of ws2812_transfer_recurrent function #4

Open ancher-bohdan opened 5 years ago

ancher-bohdan commented 5 years ago

When I call mentioned function at the first time everything working as expected. But after new call, the data is corrupting.

ancher-bohdan commented 5 years ago

It seems that after subsequent call, the data is shifted to 1 left.

Besides, this shift is circular. After I send via this function all led strip to green color (128), first call cause right behavior, but all subsequent set led strip to blue (1)

ancher-bohdan commented 5 years ago

After disabling circular mode for DMA, I have got more strange result. Now data is shifted 1 right....

ancher-bohdan commented 5 years ago

I think I got it.

After last byte was transfer via DMA to timer`s CCR, this value is saved until subsequent DMA transaction rewrite it. I think there is a small gap between transition of new byte to CCR and starting timer. This gap leads to stalled value is used to transmit first PWM pulse. This staled value is mess up all bit sequence for led strip.

ancher-bohdan commented 5 years ago

It is strange, but my previous assumption was wrong. There are nothing change after I clean timers CCR register

ancher-bohdan commented 5 years ago

I think I found temporary workaround for this issue. It is possible to enforce DMA send one dummy byte, before actual led data. This leads to swallowing one dummy byte and transmitting only correct data.

I will create a patch with this solution. In future I must investigate this more carefully and rewrite solution for this

ancher-bohdan commented 5 years ago

Workaround for this issue is in #5

This pull request contain commit (the last one) that add before any transition to led strip, one buffer, fill by 0. Therefore, before any transmission, micro-controller will send some amount of pulses with 0 pulse with.

So far it is working, but I am need to investigate for more efficient solution

ancher-bohdan commented 4 years ago

It seems, that solution with sending one dummy buffer with zeros was not so bed. It allows to get rid of strange behavior of ws2812 ledstip and guarantee, that reset sequence will be present before any new transaction.

This approach was successfully implemented in release-2.0 (commit hash 6502f81).

I am afraid, this issue is related to ws2812 controller. Need additional investigation.

Still help wanted!