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.
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
Is there some reason why it is easier to waste someone else's time than to run this code and see that it doesn't work? And then fix it?
Sir David Schmidt, If you got some other more important job please go and do that, don't waste your time here!
Anyways, The reason I asked a TI expert to look at my code is that, the code enters and exits the low power but still I notice a significant energy consumption. I want someone to help me understand why the MSP430FR2433 has high energyconsumption even if the device is entering LMP3 mode.
Thank you!
Best regards,
Pukhraj Singh
Well there is some useful information that you were keeping a secret. Not the best way to get help.
1) The timer isn't configured for one second.
2) The ISR wakes up the main program after every interrupt.
So, basically the interrupt was set for 30 seconds. I guess its working then why is the energy consumption still high like 4mW in LMP3 mode. I think it should be more lower because the current consumption is lower power mode should be in 1 or 2 micro amps
No. The timer is set to generate an interrupt every 2 seconds.
Whoever wrote the comment in the timer configuration section seemed to think it was set for 1 second.
**Attention** This is a public forum