SLAA475A October 2010 – March 2019 MSP430L092
The A-Pool can be used to implement a supervision voltage monitor function. The integrated VCC divider provides the VCC divided by 8 or divided by 4 for better observation accuracy. A nearly full battery can be easily observed by the VCC divided by 8. Lower battery voltages should be observed with the VCC divided by 4 to get a higher resolution of the supply voltage.
The customer has the choice between a comparator-based and an ADC-based implementation. Using the ADC, the application can measure the internal VCC voltage and can take actions depending on the measured value. The comparator-based solution compares the desired voltage level with the divided VCC voltage.
To generate an SVM, the divided VCC input must be connected to the comparator. Furthermore, the VCCDIVEN bit must be set to 1 to enable the internal VCC ladder. The measured value shows the current VCC value divided by the selected divider. The following code shows a simple VCC observation using the comparator functionality. An SVMIFG flag is generated when the voltage falls below the selected limit. Unlike the SVM functions known from other MSP430 devices, this SVM implementation triggers only one event at the moment when the VCC crosses the selected limit. If the VCC level is below this limit, no additional SVM flag is generated by the logic.
#include "msp430l092.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT0; // Indicates VCC crosses SVM level
APOMR |= CTEN; // Enable CTEN mode
APINT = 163; // Set voltage level 1300mV / 8 = 163mV
APVDIV |= VCCDIVEN; // Enable VCC divider
APCNF = CMPON+DBON+CONVON+APREFON; // Enable comparator on +
// Enable DAC buffer +
// Enable conversion +
// Enable reference
APCTL = APPSEL2+APPSEL1+APNSEL2+APNSEL0+OSEL;
// Set voltage divider to PSEL +
// Set DAC output to NSEL +
// Select output buffer
SFRIFG1 &=~ SVMIFG; // Clear SVM flag
APCNF |= CMPON; // Start comparison
while(1)
{
if (SFRIFG1 & SVMIFG) // Check if SVM flag is set
{
P1OUT ^= BIT0; // Indicates VCC crosses SVM level
SFRIFG1 &=~ SVMIFG; // Clear SVM flag
}
}
}