I am using bit flags to control access to shared variables between the loop function and interrupt service routines. To make my code as beginner friendly as possible I used the bit functions (bitSet,bitRead,bitWrite,bitClear).
Everything works fine for my first 3 variables, but the 4th is never accessible.
The reason is very simple and if I had been paying attention I would have spotted it hours ago. The Arduino bit functions quite reasonably regard the bits in a byte as numbered 0-7, so there is no bit 8 to set.
Its obvious enough, but if you are used to using bits directly through powers of 2, you like me will have a problem.
If you have a 10-element array and you read Array[10], you are reading something random/unknown beyond the array which holds elements 0 thru 9. Worse, if you write beyond the end of the array screwy thingc can happen and you can even crash your program!
P.S.
If you always start counting at "zero', you might be a programmer! ...How many kids do you have? "Four", "0, 1, 2, 3"