Maker Pro
Maker Pro

Challenging task

I want to take up a very challenging task of identifying at which point of main loop execution is the system getting interrupted. I want to know the exact point. As of now i want to go with single timer interrupt. Is it possible? Then plan to extend multiple interrupts and then interrupts within interrupts.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Let's assume you're talking about a microcontroller.

The easiest method may be too toggle some output pin. Move this code around until you find the point at which the output no longer toggles. Whatever precedes this is the problem.

Edit: I was assuming a totally different problem.
 
Last edited:

Harald Kapp

Moderator
Moderator
When the main loop is interrupted, a few registers are routinely pushed onto the stack, among them the program counter (PC). By examining the stack within the interrupt routine you may be able to read the program counter's value when the interrupt occurred - under the condition that access to the stack is not prohibited by some memory protection mechanism.
Once you know the PC's previous value, you can locate the position within the main loop from the assembler listing.

Alternatively use a debugger which includes a traceback mechanism for the software (a more or less expensive solution).
 
This question cannot be answered without knowing what processor you are talking about.

The PIC12F, 16F series, for example, cannot access the return address on the stack.

Bob
 
Top