Hello
I ma actually working on Davis anemometer following that tuto
I am surprised to see a millis in an interrupt, I was sure that a millis can not used in a intterrupt.
It's works but is it reliable?
Cheers
Hello
I ma actually working on Davis anemometer following that tuto
I am surprised to see a millis in an interrupt, I was sure that a millis can not used in a intterrupt.
It's works but is it reliable?
Cheers
Why do you think it can't be used?
It's important to know.
Yes, it works fine.
If your interrupt function lasts more than a millisecond, millis() won't update. That should not be a problem though.
You can use millis() in an ISR but its value will not change whilst in an ISR. Not that an ISR should last that long anyway
taking snapshots of millis() or micros() is no problem
using them for timing might be a problem if you are doing it in a blocking way.
I looked up the code
it is doing
void isr_rotation () {
if ((millis() - ContactBounceTime) > 15 ) { // debounce the switch contact.
Rotations++;
ContactBounceTime = millis();
}
}
it does just a checking but no delay. Anyway timing based on millis() is non-blocking so the isr runs through as fast as possible. A delay would do what its name says delay.
the isr above does its check and that's all
best regards Stefan