cpldcpu / light_ws2812

Light weight library to control WS2811/WS2812 based LEDS and LED Strings for 8-Bit AVR microcontrollers.
GNU General Public License v3.0
958 stars 207 forks source link

calculations based on F_CPU do not work #62

Closed JBecker32 closed 6 years ago

JBecker32 commented 6 years ago

If I set F_CPU to 8000000UL (8MHz), w1 is calculated as 0 (2-2), w2 as 3 (7-4) and w3 is below zero (10-8-0-3)! This leads to a veeeeery long low period. And, even if I set F_CPU to 500000UL (500kHz), I do not get a warning. Code is compiled without error.

cpldcpu commented 6 years ago

Both cases are caught in the code. Have you verified this in the listing file?

On Fri 20. Jul 2018 at 18:32, JBecker32 notifications@github.com wrote:

If I set F_CPU to 8000000UL (8MHz), w1 is calculated as 0 (2-2), w2 as 3 (7-4) and w3 is below zero (10-8-0-3)! This leads to a veeeeery long low period. And, even if I set F_CPU to 500000UL (500kHz), I do not get a warning. Code is compiled without error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cpldcpu/light_ws2812/issues/62, or mute the thread https://github.com/notifications/unsubscribe-auth/AD5ahuEScBIp9et3OttwD-KPD64bUCOpks5uIgYGgaJpZM4VYVz8 .

JBecker32 commented 6 years ago

But I have seen that it does not work. Period was not ok until I manually set w3 to 0.

Tim notifications@github.com schrieb am Fr., 20. Juli 2018, 20:41:

Both cases are caught in the code. Have you verified this in the listing file?

On Fri 20. Jul 2018 at 18:32, JBecker32 notifications@github.com wrote:

If I set F_CPU to 8000000UL (8MHz), w1 is calculated as 0 (2-2), w2 as 3 (7-4) and w3 is below zero (10-8-0-3)! This leads to a veeeeery long low period. And, even if I set F_CPU to 500000UL (500kHz), I do not get a warning. Code is compiled without error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cpldcpu/light_ws2812/issues/62, or mute the thread < https://github.com/notifications/unsubscribe-auth/AD5ahuEScBIp9et3OttwD-KPD64bUCOpks5uIgYGgaJpZM4VYVz8

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cpldcpu/light_ws2812/issues/62#issuecomment-406692298, or mute the thread https://github.com/notifications/unsubscribe-auth/ADxBWtweCir2d-dhYSSdF1bWzMlD_Dhqks5uIiRmgaJpZM4VYVz8 .

cpldcpu commented 6 years ago

Can you post the listing file?

On Fri 20. Jul 2018 at 20:46, JBecker32 notifications@github.com wrote:

But I have seen that it does not work. Period was not ok until I manually set w3 to 0.

Tim notifications@github.com schrieb am Fr., 20. Juli 2018, 20:41:

Both cases are caught in the code. Have you verified this in the listing file?

On Fri 20. Jul 2018 at 18:32, JBecker32 notifications@github.com wrote:

If I set F_CPU to 8000000UL (8MHz), w1 is calculated as 0 (2-2), w2 as 3 (7-4) and w3 is below zero (10-8-0-3)! This leads to a veeeeery long low period. And, even if I set F_CPU to 500000UL (500kHz), I do not get a warning. Code is compiled without error.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cpldcpu/light_ws2812/issues/62, or mute the thread <

https://github.com/notifications/unsubscribe-auth/AD5ahuEScBIp9et3OttwD-KPD64bUCOpks5uIgYGgaJpZM4VYVz8

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/cpldcpu/light_ws2812/issues/62#issuecomment-406692298>, or mute the thread < https://github.com/notifications/unsubscribe-auth/ADxBWtweCir2d-dhYSSdF1bWzMlD_Dhqks5uIiRmgaJpZM4VYVz8

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/cpldcpu/light_ws2812/issues/62#issuecomment-406693699, or mute the thread https://github.com/notifications/unsubscribe-auth/AD5ahtOxFj6bAQ5qP5fAid1up8rmPQeKks5uIiWbgaJpZM4VYVz8 .

JBecker32 commented 6 years ago

Problem solved: F_CPU has to be defined as (e.g) 8000000, not as 8000000uL. The uL (which is needed for me due to code conventions) forces the calculations to be done in integer which leads to false results.