Matthew
I can confirm that the PE generated code will cause any interrupt event to be lost that occurs between the entry into the interrupt handler and resetting the flag.
1.
IRQ()
{
FTM0_SC &= ~(FTM_SC_TOF);
do stuff...
}
any further interrupt event that arrives after FTM0_SC is read will be pending at the end of the handler and cause it to be re-entered again.
2.
IRQ()
{
(void)FTM0_SC;
do stuff...
FTM0_SC &= ~(FTM_SC_TOF);
}
any further interrupt event that arrives after FTM0_SC is read will reset by the FTM0_SC &= ~(FTM_SC_TOF); and thus lost
3.
IRQ()
{
unsigned long temp = FTM0_SC;
do stuff...
FTM0_SC = (temp & ~(FTM_SC_TOF));
}
any further interrupt event that arrives after FTM0_SC is read on entry will be pending at the end of the handler (will not be reset by the clear of FTM_SC_TOF) and cause it to be re-entered again.
There are some instances where method 2 has an advantage because interrupt arriving faster than the handling rate will not cause the interrupt to always remain pending. In 99.999% of real use 2. is however incorrect code.
PE code may appear to work correctly but it makes sense to always check carefully because it may not satisfy real developments requirements without some "tuning".
Regards
Mark