Hi, I'm having some difficulties in determining when and how (external) interrupts remain pending. In the users manual for the XC167ci it states that hardware arbitration leaves interrupts pending if they cannot be handled at that moment (i.e. the ILVL of the PSW is too high). I use a few macros to raise or lower the ILVL temporarily. This works great, I never miss interrupts. I figure that if an interrupt occurs when the ILVL is too high, the interrupt is buffered (pending) and it is handled the moment I lower the ILVL again. But I now would like to turn of ONE specific interrupt. I do that by clearing and setting of the CC10IE bit. It seems that interrupts that occur during the time that the CC10IE bit is of are completely gone. I.e. they do not stay 'pending', they are not buffered and handled whenever I enable the CC10IE bit again. Can anyone tell me how and when the XC167 keeps interrupts pending? Did anyone else run into this same problem? Should I enable/disable one specific interrupt in another way? Thanks for your help
@Mike Yes you are right, there must one instruction after clearing the interrupt enable bit. I checked this in the disassembler that the next instruction doesent need protection. But my tests got also the same problem with a nop after clearing the enable bit and I dont know why? Reagarding the usage of the atomic instructions, _atomic(0); ...; _endatomic_(); supports only 4 instructions and the compiler will not stack them. Ok, if I need more than one atomic instruction, than I can also disable the global interrupt flag. Still strange why it was not working disabling the SOTIE interrupt enable flag. Bert
Still strange why it was not working disabling the SOTIE interrupt enable flag. After a long look at the code you posted the only thing I can come up with is that maybe s_iTxRead or s_iTxWrite are not declared as volatile?
Only s_iTxRead and the restartflag are declared as volatile, because only this two are change inside the interrupt function.