Tool/software: Code Composer Studio
I am working on a small code which sets my controller (MSP430F6435), into sleep mode and get back in active mode by alarm interrupt. I referred to the sources but I am still missing on to something, the code never comes out of LPM3. I am attaching my code for referral
#include <stdio.h> #include <msp430.h> /*Sample code for testing the sleep mode(low power mode) of MSP430F6435 */ void Init_GPIO(void) { // Port Configuration P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;P5OUT = 0x00;P6OUT = 0x00; P7OUT = 0x00;P8OUT = 0x00;P9OUT = 0xFF;PJOUT = 0x00; P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;P5DIR = 0xFF;P6DIR = 0xFF; P7DIR = 0xFF;P8DIR = 0xFF;P9DIR = 0xFF;PJDIR = 0xFF; } void init_RTC_B(void) //NO PRESCALER USED { UCSCTL6 &= ~(XT1OFF); // 32Khz capacitor used for MCLK, SMCLK, ACLK UCSCTL6 |= XCAP_3; // Internal load cap 12pF configuration while(BAKCTL & LOCKBAK) // Unlock XT1 pins for operation BAKCTL &= ~(LOCKBAK); do { UCSCTL7 &= ~(XT1LFOFFG + DCOFFG); // Clear XT1,DCO fault flags in case of possible faults that could set these registers high SFRIFG1 &= ~OFIFG; // Clear oscillator fault flags }while (SFRIFG1&OFIFG); // Till the oscillator fault flags are not cleared RTCCTL0 = RTCAIE; //Alarm interrupt for wake up from low power mode RTCAMIN = 0x81; //For 1 minute interupt RTCCTL1 = RTCHOLD; //Disables the calender mode RTCHOUR = 0x5; // Hour = 0x5 RTCMIN = 0x6; // Minute = 0x15 RTCSEC = 0x7; // Seconds = 0x25 } void EnterLPM3(void) { PMMCTL0_H = PMMPW_H; // Open PMM Registers for write PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF __bis_SR_register(LPM3_bits+ GIE); // Enter LPM3.5 mode with interrupts//3.5 because minimum power consumption with backup RTC __no_operation(); // enabled } #pragma vector=RTC_VECTOR __interrupt void RTCISR (void) { PMMCTL0_H = PMMPW_H; // open PMM PM5CTL0 &= ~LOCKLPM5; // Clear LOCKBAK and enable ports PMMCTL0_H = 0x00; // close PMM RTCCTL0 &= ~RTCAIE; __bic_SR_register_on_exit(LPM3_bits+ GIE); // Exit LPM3 __no_operation(); } int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P5DIR |= BIT5; int i, sec; Init_GPIO(); init_RTC_B(); EnterLPM3(); P5OUT |= 0X0020; while(1); }
I am a newbie here and any help would be appreciable. Thank you.
Regards
-Onkar