We are developing our product using TI microcontroller MSP430F5325,Our DVCC supply is 3.3 V and we want to monitor the supply voltage during power fail condition. During power fail we want to write external EEPROM.
Our SMCLK is 8 MHz and required threshold voltage during power fail is 2.90 V so As per the datasheet and user guide of MSP430F5325 we have selected the SVS and SVM high-side reset release voltage level 7 (SVSMHRRL_7;) .
But during power fail we are not able to write the external EEPROM and in normal condition there is no issue to write and read the external EEPROM. During power fail sometime we got the interrupt and write is successful but sometime we didn’t get the interrupt and not able to write so Kindly suggest the solution .
pl refer the below relevant code section .
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
///////////////////////Initialization///////////////////////////////////////////////////////
PMMCTL0_H = PMMPW_H;
__no_operation();
SVSMHCTL =0x4400;
SVSMHCTL = SVMHE + SVSMHRRL_0;
SVSMHCTL &= ~SVSHE;
SVSMLCTL &= ~(SVMLE+SVSLE); // Disable Low side SVS/SVM
PMMIFG &= ~SVMHIFG;
PMMRIE=SVMHIE;
// Lock PMM registers for access
PMMCTL0_H = 0x00;
__no_operation();
SetVCoreUp(1);
SetVCoreUp(2);
SetVCoreUp(3);
PMMCTL0_H = PMMPW_H;
__no_operation();
SVSMHCTL = SVMHE + SVSMHRRL_7;
SVSMHCTL &= ~SVSHE;
SVSMLCTL &= ~(SVMLE+SVSLE); // Disable Low side SVS/SVM
PMMIFG &= ~SVMHIFG;
PMMRIE=SVMHIE;
// Lock PMM registers for write access
PMMCTL0_H = 0x00;
__no_operation();
while(1)
{
/////// C- Code
/////// C- Code
/////// C- Code
/////// C- Code
/////// C- Code
/////// C- Code
}// while(1) end
}//main end
//////////////////////////////////// SetVCoreUp function ///////////////////////////
void SetVCoreUp (unsigned int level)
{
// Open PMM registers for write access
PMMCTL0_H = 0xA5;
// Make sure no flags are set for iterative sequences
while ((PMMIFG & SVSMHDLYIFG) == 0);
while ((PMMIFG & SVSMLDLYIFG) == 0);
// Set SVS/SVM high side new level
SVSMHCTL = SVSHE + SVSHRVL0 * level + SVMHE + SVSMHRRL0 * level;
// Set SVM low side to new level
SVSMLCTL = SVSLE + SVMLE + SVSMLRRL0 * level;
// Wait till SVM is settled
while ((PMMIFG & SVSMLDLYIFG) == 0);
// Clear already set flags
PMMIFG &= ~(SVMLVLRIFG + SVMLIFG);
// Set VCore to new level
PMMCTL0_L = PMMCOREV0 * level;
// Wait till new level reached
if ((PMMIFG & SVMLIFG))
while ((PMMIFG & SVMLVLRIFG) == 0);
// Set SVS/SVM low side to new level
SVSMLCTL = SVSLE + SVSLRVL0 * level + SVMLE + SVSMLRRL0 * level;
// Lock PMM registers for write access
PMMCTL0_H = 0x00;
}
/////////////////////////////////////// Interrupt vector //////////////////////////////
#pragma vector=SYSNMI_VECTOR
__interrupt void SYSNMI_ISR(void)
{
switch(__even_in_range(SYSSNIV,0x12))
{
case 0 : break;
case 2 : break;
case 4 :
Code for writing EEPROM;
// __no_operation(); ß break point is here.
// __no_operation();
break;
case 6 :
break;
case 8:
break;
case 0x0A:
break;
case 0x0C:
break;
default:
break;
}
}
//////////////////////////////////////////////////////////////// PMM Setting in datasheet///////////////////////////////////