This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to disable interrupts realtime safely

Hello Forum,

I wanna disable interrupts on my 80C167. As far as I understood the User Manual, writes to the PSW (containing the IEN bit and the Interrupt-Level) will take place about two cycles later, which leads to the following effect: If during this very two cycles an Interrupt Request occurs, this interrupt will be accepted and executed, while the PSW-changes took place. This means, during the execution of the interrupt service routine, all other interrupts are disabled, even the higher prioritized, which leads to problems, in particular if it takes a long time to execute. This is what I mean by "realtime unsafe".

If I use

#pragma DISABLE
the compiler genrates code which change the PSW. It inserts two NOPs, protecting the following code from being interrupted, but not preventing the system to be realtime unsafe.

As far as I know, to disable interrupts realtime safely, I have to either use the xxIC-Register, what is quite boring if I got to disable a lot of interrupts. Or, I have to protect the PSW-changing code itself by an ATOMIC.
Am I right in that point? How can I disable interrupts realtime safely in a C-Programmer-friendly way?

Thanks for all opinions and hints - Peter

0