I'm trying to checkpoint (store RAM, GPR and peripherals into FRAM before a power failure) inside a Comparator_D interruption, but when the system is restored, the PC is placed again inside the Interruption. Is possible to modify the PC value in order to move it somewhere else? Below the code with comments in red.
#pragma vector=COMP_D_VECTOR
__interrupt void COMP_D_ISR(void)
{
if (int_edge==0)
{
//falling edge handling Vcomp < VH
int_edge=1;
P1OUT &= ~BIT5;
CDCTL1 ^= CDIES; // Toggles interrupt edge
CheckPoint(); //HERE IS STORED THE CURRENT STATE AND AFTER THAT A POWER FAILURE OCCURS, BUT WHEN RESTORED, PC IS PLCED BELOW, ENTERING AGAIN IN LPM4 WHICH IS NOT DESIRABLE.
__bis_SR_register_on_exit(LPM4_bits + GIE); //after exiting ISR, go to LPM4 and wait for the next comp interrupt, rising edge
}
else
{
//rising edge handling Vcomp > VR
CDCTL1 ^= CDIES; // Toggles interrupt edge.
int_edge=0;
__bic_SR_register_on_exit(LPM4_bits); //wake part up and go back to main when exiting ISR this time
m=(void*)__get_SP_register();
}
CDINT &= ~(CDIFG); //clear flag
}