Can breakpoints be used in ISRs?

suresh picture suresh · Nov 28, 2008 · Viewed 7.9k times · Source

Can breakpoints be used in interrupt service routines (ISRs)?

Answer

Artelius picture Artelius · Dec 29, 2008

Yes - in an emulator.

Otherwise, no. It's difficult to pull off, and a bad idea in any case. ISRs are (usually) supposed to work with the hardware, and hardware can easily behave very differently when you leave a gap of half a second between each instruction.

Set up some sort of logging system instead.

ISRs also ungracefully "steal" the CPU from other processes, so many operating systems recommend keeping your ISRs extremely short and doing only what is strictly necessary (such as dealing with any urgent hardware stuff, and scheduling a task that will deal with the event properly). So in theory, ISRs should be so simple that they don't need to be debugged.

If it's hardware behaviour that's the problem, use some sort of logging instead, as I've suggested. If the hardware doesn't really mind long gaps of time between instructions, then you could just write most of the driver in user space - and you can use a debugger on that!