Reset Program Counter to absolute address and continue run.

General discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Reset Program Counter to absolute address and continue run.

#1 Post by Rotary_Ed » 06 Jan 2019 22:58

I have a WDT reset procedure that works as advertised. After the WDT timeout interval expires my PIC32MX795F512L chip reboots and starts the entire program over. That much works, my quest is to have the Program Counter jump to an address that is not at restart of the code and run from that point. I realize that there may be registers that need to be saved or modified to accomplish this but even after a lot of searching I have not found the answer.

Is it possible after the WDT interrupt to force the Program Counter to jump to a designated address to run the program rather than beginning at the program's start?

I have code that does jump the Program Counter to the desired address after the WDT reset, but the program counter does not advance further as I was expecting.

The code at the target address displays a message on the screen of my board and after the PC jumps to the target address, the message is indeed displayed on the screen indicating that whatever else - the program counter did jump to the target address.

I ensured the PC target address was on a mod 4 boundary as I understand that if it is not the program counter will fail to advance further in the code. However, the program counter apparently stops there and runs no further.

I have made jumps (jr) to the message's absolute address as well as used a "Goto Label" approach and both methods does indeed jump the PC to the appropriate address. However, in neither case does the code execution continue.

From the specifications, it appears that if the WDT resets while the chip is in "Sleep" mode that the program counter will resume at the point it stopped when it "awakes" rather than return to program start. I am wondering if that characteristic might be used to accomplish my desire to restart at a designated address.

Has anyone else have any success with such an approach and if so, would you mind sharing your details.

Thanks
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

Post Reply

Return to “mikroPascal PRO for PIC32 General”