0
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ I'm not sure why the on-chip voltage would do you any good if it can't be used as ADC reference. Whatever you use as ADC reference is all that matters. \$\endgroup\$
    – Lundin
    Commented Nov 20, 2023 at 15:46
  • \$\begingroup\$ @LundinMaybe my statement was not clear, but I am planning to use on-chip voltage as the ADC reference. \$\endgroup\$
    – Bravo
    Commented Nov 21, 2023 at 4:28
  • \$\begingroup\$ What exactly is the battery chemistry? Fully charged it will probably have more than 1.5V. Meaning that if your Vref is 1.5V you need to protect it. Why not use something derived from the MCU supply voltage instead? 3.3V gives much better margins. \$\endgroup\$
    – Lundin
    Commented Nov 22, 2023 at 7:27

0