Part Number: MSP430FR2522 I am developing an application with the MSP430FR2522 where I need Very low average power consumption (1-10 uA at 3V) To keep track of time using the RTC module Basing on TI's examples I have made the following code snippet, which sources the whole clock system, RTC included from a watch crystal (LFXT1 at 32768 Hz). The device then enters LPM4 and wakes up every second to toggle a pin using an interrupt sourced from the RTC: /* * lpm4_rtc.c * 25.06.2019 */ #include int main() { WDTCTL = WDTPW | WDTHOLD; // Stop the watchdog timer P1OUT &= ~BIT0; // Set P1.0 to digital low P1DIR |= (BIT0); // Set P1.0 direction to output PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode P2SEL1 |= BIT0 | BIT1; // Select XT1 function on P2.0 and P2.1 do { CSCTL7 &= ~(XT1OFFG | DCOFFG); // Clear XT1 and DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault interrupt flag __delay_cycles(25000); // Wait some cycles to stabilize XT1 } while (SFRIFG1 & OFIFG); // Repeat until no more faults occur CSCTL4 = SELMS__XT1CLK | SELA__XT1CLK; // Set MCLK = ACLK = XT1CLK = 32768Hz CSCTL5 |= DIVM__1; // MCLK Divider = 1 RTCMOD = 32; // Set the value in the RTC Modulo Register to have an interrupt every second (32768/1024 = 32) // Explanation of the RTC Control Register (RTCCTL) settings // RTCSS__XT1CLK : Select XT1CLK as the clock source for the RTC Counter (RTCCNT) // RTCPS__1024 : Predivide XT1CLK by 1024 before feeding it to the RTC Counter (RTCCNT) // RTCSR : Software reset to trigger the loading of Modulo Register (RTCMOD) into the Shadow Register (RTCSR) // RTCIE : Enable RTC Interrupt RTCCTL = RTCSS__XT1CLK | RTCPS__1024 | RTCSR | RTCIE; // Configure the RTC Control Register __bis_SR_register(LPM4_bits | GIE); // Enter LPM4 } // ISR for the RTC ------------------------------------------------------------ #pragma vector = RTC_VECTOR __interrupt void RTC_ISR(void) { switch(__even_in_range(RTCIV, RTCIV_RTCIF)) { case RTCIV_NONE: break; // No interrupt pending case RTCIV_RTCIF: // RTC Overflow P1OUT ^= BIT0; // Toggle P1.0 break; default: break; } } The code seems to work but the current consumption (measured using the EnergyTrace feature) is much higher than expected, about 100 uA whereas from the datasheet it should be around 1 uA. What could the problem be? More details on my setup: Microcontroller: MSP430FR2522 (QFN-20 package) on a MSP-TS430RHL20 target board Compiler: TI v18.12.2 Debugger: MSP-FET IDE: Code Composer 9 Best, P
↧