Hi all
Is it possible that an interrupt that appears when a C statement that needs several low level opcodes
will cause losing data by the registers involved in those multi opcodes?
Thanks
Elico
Hi all
Is it possible that an interrupt that appears when a C statement that needs several low level opcodes
will cause losing data by the registers involved in those multi opcodes?
Thanks
Elico
No, not when using normal Arduino code.
I remember that there is a special way to have a very short interrupt that doesn't save all registers on the stack. But I have not used such low level programming myself. So it is possible, but it would be bad programming.
Did you use the 'volatile' keyword for global variables that can be changed in an interrupt ? The microcontroller has many registers to store variables, so without the 'volatile' keyword it is very likely to go wrong.
The ISR preamble will save all the regs used by the program unless you use ISR_NAKED in which case it's up to you to get that right.
Normally a C programmer does not concern himself with the CPU's working resisters, that will not be your problem, however you can have corrupted variables especially if they are larger than one byte.
So what exactly is your problem?
Rob