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.

How to exactly verify LPM4.5 entry? LOCKLPM5 reg not getting set... :-(

Other Parts Discussed in Thread: MSP430FR5739

Hi friends,

I would like to know how exactly to verify that the system has entered the LPM4.5 mode. The following is my code where I try to enter the LPM4.5 mode and then come out of it using a switch-press, which is indicated by a simple counter on LEDs.

I have followed the exact pattern to be written in the PMM registers for entry into LPM4.5, but am NOT able to see the LOCKLPM5 getting set automatically..

Please suggest where I have went wrong?

--------------------------------------------------------------------------------------------------

// Operating Mode here = LPM4.5 (Attempted.. Not working :-()

#include "msp430fr5739.h"

extern void SystemInit(void);
extern void debouncetimer(void);
volatile unsigned int i;

void main( void )
{
    // Stop watchdog timer to prevent time out reset
    WDTCTL = WDTPW + WDTHOLD;
    SystemInit();
    P3OUT = 0xF0;            // Initial pattern in LEDs - '1111'
    while (1)
    {
        // !!!!!! HOW TO ENTER LPM4.5???????? !!!!!!

          PMMCTL0_H = PMMPW_H;                      // open PMM
          PM5CTL0 &= ~(LOCKLPM5);
          PMMCTL0_L |= PMMREGOFF;                   // set Flag to enter LPM4.5 with LPM4 request
          PMMCTL0_H = 0x00;                         // Close PMM

          __bis_SR_register(GIE + CPUOFF + OSCOFF + SCG1 + SCG0);     // Enter LPM4.5 by setting PMMREGOFF w/interrupt

    }
}

// Simple Counter on LED as per vibrations...

#pragma vector=PORT4_VECTOR
__interrupt void Port_4 (void) {

      // disable switches
      P4IFG = 0;                                // P4 IFG cleared
      P4IE &= ~(BIT0);                          // P4.0 interrupt disabled

      debouncetimer();

       i = 1;

       PM5CTL0 &= ~(LOCKLPM5);

      P3OUT += 0x10;         // Counter on LEDs on Switch Press, whenever system comes out of LPM4.5

}

#pragma vector = TIMER1_A0_VECTOR
__interrupt void Timer1_A0_ISR(void)
{
  TA1CCTL0 = 0;
  TA1CTL = 0;
  // enable switches
  P4IFG = 0;                                // P4 IFG cleared
  P4IE = (BIT0);                            // P4.0 interrupt enabled
}

void SystemInit(void)
{
   CSCTL0_H = 0xA5;                          // Unlock register
  CSCTL2 = SELA_1 + SELS_1 + SELM_1;        // set ACLK = VLO; MCLK = VLO
  CSCTL0_H = 0x01;                          // Lock Register
 

//CSCTL1 |= DCOFSEL0 + DCOFSEL1;            // Set max. DCO setting
  //CSCTL2 = SELA_1 + SELS_3 + SELM_3;        // set ACLK = vlo; MCLK = DCO
  //CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0;        // set all dividers
 
  // Turn off temp.
  REFCTL0 |= REFTCOFF;
  REFCTL0 &= ~REFON;

  // Enable switches
  // P4.0 configured as switch

  P4OUT |= BIT0;                     // Configure pullup resistor
  P4DIR &= ~(BIT0);                  // Direction = input
  P4REN |= BIT0;                     // Enable pullup resistor
  P4IES |= (BIT0);                  // P4.0 High to Low edge interrupt
  P4IE = BIT0;                       // P4.0 interrupt enabled
  P4IFG = 0;                         // P4 IFG cleared

//

// more code here to configure all pins as Inputs and Pulling them up.

//

}

void debouncetimer(void)
{

      TA1CCTL0 = CCIE;                          // TACCR0 interrupt enabled
        TA1CCR0 = 1500;
      TA1CTL = TASSEL_1 + MC_1;                 // ACLK, up mode

}


  • Sorry to say this. But it seems to me you know not what you do.

    Once LPMx.5 is entered, LOCKLPM5 is automatically set, and the I/O pins are locked. But CPU, RAM, and most registers are powered off. Wen you press the switch connected to P4.0, it will not generate an P4 interrupt. Instead, a BOR is generated. Thus in main(), you need to examine the cause of the reset. When SYSRSTVEC == 8, that reset is caused by waking up from LPMx.5 and you will see that LOCKLPM5 is already set.

    Edit: P4.0, not P4.1

**Attention** This is a public forum