calculations based on F_CPU do not work
Closed this issue · 4 comments
JBecker32 commented
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
Both cases are caught in the code. Have you verified this in the listing
file?
…On Fri 20. Jul 2018 at 18:32, JBecker32 ***@***.***> 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
<#62>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD5ahuEScBIp9et3OttwD-KPD64bUCOpks5uIgYGgaJpZM4VYVz8>
.
JBecker32 commented
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 ***@***.***> 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
> <#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
<#62 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADxBWtweCir2d-dhYSSdF1bWzMlD_Dhqks5uIiRmgaJpZM4VYVz8>
.
cpldcpu commented
Can you post the listing file?
…On Fri 20. Jul 2018 at 20:46, JBecker32 ***@***.***> wrote:
But I have seen that it does not work. Period was not ok until I manually
set w3 to 0.
Tim ***@***.***> 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 ***@***.***>
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
> > <#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
> <
#62 (comment)>,
> 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
<#62 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD5ahtOxFj6bAQ5qP5fAid1up8rmPQeKks5uIiWbgaJpZM4VYVz8>
.
JBecker32 commented
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.