Challenging task

electronicsLearner77

Jul 2, 2015
306
Joined
Jul 2, 2015
Messages
306
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
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
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
Nov 17, 2011
14,271
Joined
Nov 17, 2011
Messages
14,271
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).
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
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