!!! never clear Interruptflags at the last line of interrupt function
One time more, i have found that the LPC serie has a big timing problem if clearing interrupt flags .
This problem only occures if you clear the Interrupt flag at the very last line of your interrupt function
and additional you set the compiler optimization to -O3
The processor needs time to clear the internal interrupt flag, but before the interrupt flag
was cleared we get a next interrupt.
This problem i have found in the LPC1768 and LPC1347
To solve the problem you need only a litte bit time or you clear the interruptflag
NOT at the very last line.
Now i always put the "DSB" instruction after clearing the interrupt flag in my functions.
In my currently project i get a I2C interrupt and the status ist 0xF8
this is an mismatch status and not described in the manual.
i think the error is an result of the internal write buffers of the CPU.
if i use one of the following action it works fine.
- a) clear interrupt flag NOT at the last line
- b) do an dummy operation after clearing the interrupt flag
- c) do not use the compiler optimization
- d) use an "dsb" instruction after clearing the interrupt flag
i think this behavior must described in the user manual.