carlosrafaelgn/ArduinoTimer

the maximum period we can give 1 sec only.

Closed this issue · 3 comments

i am trying to give more than 1 sec period in timer 4. it is not changing still it is giving 1sec period only.
if you find please upload.

Hi there!

Can you provide me with more info? Like, which board you are using, and an example code? Does this issue occur only with Timer4, or have you also noticed it with Timer1?

I just checked Timer4's code and it looks fine...

Thank you so much for giving reply.

I am using arduino mega 2560.
I have checked your code, in all timers your using pre scale 64 or 256.
That is you have set the
" _timer3Control=B00000100" and
" _timer3Control=B00000011"
so we can't give more counter value,
If we use prescaler 1024 we can give max 8.3 secs counter value.
For that I have changed
" _timer3Control=B00000101" now interrupt can give at most 8.3 sec.

If my approach is wrong can you provide best one.

Thanks and regards,
Manohar.

On 28 Jul 2016 17:01, "Carlos Rafael Gimenes das Neves" <
notifications@github.com> wrote:

Hi there!

Can you provide me with more info? Like, which board you are using, and an
example code? Does this issue occur only with Timer4, or have you also
noticed it with Timer1?

I just checked Timer4's code and it looks fine...


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ASccTqZVwZWpzdkhuKAsyz_dMeLHKJNEks5qaJMogaJpZM4JCEi2
.

Oooo... I see your point now.

Well, indeed there was a limit of aprox. 1.048 s for 16 MHz boards (like your Mega).
I left it written in a comment above the functions startTimer#(), since it was by design:
// 0 < microsecondsInterval <= 1000000
// On 16 MHz Arduino boards, this function has a resolution of 4us, for intervals <= 260000, and a resolution of 16us for other intervals
// On 8 MHz Arduino boards, this function has a resolution of 8us, for intervals <= 520000, and a resolution of 32us for other intervals

Unfortunately I forgot to add this limitation to README.md (I only described the limitation for functions startCountingTimer#() and for startSlowCountingTimer#()). I will correct the file README.md, and add this warning explicitly.

In fact, I do not use 1024 prescaler basically because I thought it would be too messy to have 3 resolutions to deal with. See... I created microsFromCounting() for the 64 prescaler and microsFromSlowCounting() for the 256 prescaler.

But... I think I could add something like UltraSlowCounting.

Only thing is, the maximum interval would be approximately 4.19 s for 16 MHz boards, and not 8.