Here is the code I used to configure and monitor my voltage that when it becomes 1.2V, BATTERY_ON symbol on my LCD is ON. The checking of voltage is every 10 seconds. This code below works using MSP430F427 microcontroller.
volatile unsigned char num_of_batt_check = 0;
void Init_Timer_A (void)
{
TAR = 8192; // (33 = 1ms)
TACTL = TASSEL1 | ID_0 | MC_2 | TAIE; // ACLK | input divider 0 | Continuous up mode | Interrupt enable
}
void Init_SVS (void)
{
P2SEL |= SVS_PIN; // Select peripheral module function (supply voltage supervisor)
P2DIR &= ~SVS_PIN; // Set SVSIN pin as input
SVSCTL &= ~SVSFG; // Clear low voltage condition
SVSCTL = VLD3 | VLD2 | VLD1 | VLD0; // Set VLDx as 15 - 1111 for 1.2 Vref
}
void batt_check()
{
if (SVSCTL & SVSOP) // Check SVS status, if SVS comparator high, set low power detected
{BATT_ON;} // Macro of battery symbol ON
else
{BATT_OFF;} // Macro of battery symbol OFF
num_of_batt_check = 0;
}
/************************************************/
/***************** Main function ****************/
/************************************************/
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watch-dog timer
Init_SVS();
Init_Timer_A();
while (1)
{
if (num_of_batt_check >= 46)
{
batt_check();
}
}
}
I would like to ask on how can I implement this using MSP430FR4133. I have read that I can use the on-chip reference voltage fixed at 1.5V. My battery is also 1.5V and I only have to monitor when it becomes 1.2V and detect the voltage every 10 seconds. I am not sure on how to start with the right configuration. I am using an external crystal 32kHz.