Part Number: MSP430FR5994
Tool/software: Code Composer Studio
Hi all,
In my project, I wanna back up registers and RAM when power fails and restore them right after power turns on again (power check by ADC12).
void Hibernate (void){
// copy core registers to a new created segment of FRAM
asm(" MOVA R1,&0x42800");
asm(" MOVA R2,&0x42804");
asm(" MOVA R3,&0x42808");
asm(" MOVA R4,&0x4280C");
asm(" MOVA R5,&0x42810");
asm(" MOVA R6,&0x42814");
asm(" MOVA R7,&0x42818");
asm(" MOVA R8,&0x4281C");
asm(" MOVA R9,&0x42820");
asm(" MOVA R10,&0x42824");
asm(" MOVA R11,&0x42828");
asm(" MOVA R12,&0x4282C");
asm(" MOVA R13,&0x42830");
asm(" MOVA R14,&0x42834");
asm(" MOVA R15,&0x42838");
// copy all the RAM onto another created segment of FRAM by DMA
Save_RAM();
}
void Restore (void){
// Restore RAM by DMA
restore_RAM();
// Core registers
asm(" MOVA &0x42800,R1");
asm(" MOVA &0x42804,R2");
asm(" MOVA &0x42808,R3");
asm(" MOVA &0x4280C,R4");
asm(" MOVA &0x42810,R5");
asm(" MOVA &0x42814,R6");
asm(" MOVA &0x42818,R7");
asm(" MOVA &0x4281C,R8");
asm(" MOVA &0x42820,R9");
asm(" MOVA &0x42824,R10");
asm(" MOVA &0x42828,R11");
asm(" MOVA &0x4282C,R12");
asm(" MOVA &0x42830,R13");
asm(" MOVA &0x42834,R14");
asm(" MOVA &0x42838,R15");
// set flag, type = NOINIT, in FRAM
*flag = 0;
if (*flag == 0)
{
P1DIR |= BIT0;
P1OUT |= BIT0;
}
}
The problem is that *flag can't be set to 0 because the red LED is not turned on. I also tried different methods to determine whether *flag == 0 and I'm quite sure that it's can be set to 0. Using a variable like volatile int flag (in FRAM, type = NOINIT) doesn't make the code work.
Thank you in advance for all of your helps.