This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR2433: I want an TI expert to check this code and confirm me that the device enters the low power mode and stays there for 30 seconds

Part Number: MSP430FR2433


Hello TI team,

I want someone to check this low power code that is written for MSP430FR2433. I want to confirm that does this code take the device in LMP3 mode for 30 seconds and then wake up to blink the LED. Could someone confirm.

#include <msp430.h>

void Init_GPIO(void);
void Init_TimerA(void);

volatile unsigned int blinkCounter = 0;

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

// Configure one FRAM waitstate as required by the device datasheet for MCLK
// operation beyond 8MHz _before_ configuring the clock system.
FRCTL0 = FRCTLPW | NWAITS_1;

// Configure GPIO
Init_GPIO();

// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
PM5CTL0 &= ~LOCKLPM5;

__bis_SR_register(SCG0); // disable FLL
CSCTL3 |= SELREF__REFOCLK; // Set REFO as FLL reference source
CSCTL0 = 0; // clear DCO and MOD registers
CSCTL1 &= ~(DCORSEL_7); // Clear DCO frequency select bits first
CSCTL1 |= DCORSEL_5; // Set DCO = 16MHz
CSCTL2 = FLLD_0 + 487; // DCOCLKDIV = 16MHz
__delay_cycles(3);
__bic_SR_register(SCG0); // enable FLL
while (CSCTL7 & (FLLUNLOCK0 | FLLUNLOCK1)); // FLL locked
CSCTL4 = SELMS__DCOCLKDIV | SELA__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz

// Configure TimerA
Init_TimerA();

// Enter LPM3
__bis_SR_register(LPM3_bits | GIE);

while (1)
{
// This part of the code won't be reached as we are in LPM3
// The TimerA interrupt will handle the LED blinking and LPM3 exit
}
}

void Init_TimerA(void)
{
TA0CCTL0 = CCIE; // Enable Timer A0 interrupt
TA0CCR0 = 62768; // Set the period for 1 second (ACLK frequency is 32768 Hz)
TA0CTL = TASSEL__ACLK | MC__UP; // ACLK, Up mode
}

// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TimerA_ISR(void)
#elif defined(__GNUC__)
void __attribute__((interrupt(TIMER0_A0_VECTOR))) TimerA_ISR(void)
#else
#error Compiler not supported!
#endif
{


if(blinkCounter == 1)
{
P1OUT |= BIT0;
}
else
{
P1OUT &= ~BIT0;
}
blinkCounter++;
if(blinkCounter > 30)
{
blinkCounter = 0;
}

// Exit LPM3 on return from interrupt
__bic_SR_register_on_exit(LPM3_bits);
}

void Init_GPIO()
{
P1DIR = BIT0; // Set P1.0 as output
P1OUT &= ~BIT0; // Turn off LED initially
}

Thank you!

Best regards,

Pukhraj Singh

**Attention** This is a public forum