A change to a 8 bit variable is atomic. Changes to larger values are not. However, interrupts are disabled during an interrupt service routine, so corruption of a multibyte variable will not occur in the ISR.
I do enable the interrupts in my function though
Quote from: JosAH on Feb 17, 2013, 04:50 pmI do enable the interrupts in my function thoughYou are enabling interrupts within an interrupt handler? That is a big red flag.
I know what I'm doing
Quote from: JosAH on Feb 17, 2013, 06:12 pmI know what I'm doingYou "know what you're doing" but don't know that eight-bit writes are atomic? This is not very reassuring.
if (foo > 100) foo = 0;
I want the millis() etc. interrupts to go on.
Quote from: PeterH on Feb 17, 2013, 05:49 pmYou are enabling interrupts within an interrupt handler? That is a big red flag.No it isn't, I know what I'm doing (<--- famous last words ;-) My interrupt function is triggered by a falling edge and then it starts decoding an IR signal from a digital pin; that can takes several milli seconds (I simply poll that pin in the interrupt function) and I want the millis() etc. interrupts to go on. At the start of my function I've detached it from the particular interrupt because I don't want it to be called recursively by another falling edge on that pin. b.t.w. I only enable interrupts after I've detached my function from that falling edge interrupt.
You are enabling interrupts within an interrupt handler? That is a big red flag.
A change to a 8 bit variable is atomic.
foo |= mask;foo &= ~mask;
I agree with Bill. Setting/clearing one bit (where the bit is known at compile time) the compiler usually generates a single atomic instruction. However doing multiple bits, or arithmetic, is unlikely to be atomic.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16