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.

entering and exiting from low power modes LPM0

Other Parts Discussed in Thread: MSP430F5229

Hi,

I am working on a project which needs to use low power mode to save power. I want my MCU to be in sleep (low power mode)  for most of the time. The MCU should exit the sleep mode only when it detects a wake-up pulse on P2.1 pin. The wake-up pulse comes from a watch-dog receiver and it is 120 micro-second long. I have written a piece of code using the driverlib examples but that does not seem to be working fine. I am using MSP430F5229 and CCS v5. I use the MSP-FET430UIF to download and debug the code. 

After I configure the specific ports, I enter an infinite while loop. Entering the loop I try to go to sleep mode using __bis_SR_register(LPM0 | GIE) and then wait for that wake-up signal. I have a break point right after the sleep mode mode on _no_operation(). The first time I run the code it does pass the sleep mode and stops on the breakpoint but after that it never pass the __bis_SR_register line of code. I have checked and confirmed the pulse at the input of micro-controller. 

I hope that someone can help me out of this problem.

void main (void)
{
         WDT_A_hold(WDT_A_BASE);     //Stop watchdog timer

 //Initialize GPIO     //     Port_wakeRX is defined as port 2 and pin_wakeRx is defined as GPIO_pin1 separately

GPIO_setAsInputPinWithPullUpresistor( PORT_WakeRx, PIN_WakeRx );     
GPIO_enableInterrupt ( PORT_WakeRx, PIN_WakeRx );
GPIO_interruptEdgeSelect (PORT_WakeRx, PIN_WakeRx, GPIO_HIGH_TO_LOW_TRANSITION);
GPIO_clearInterruptFlag ( PORT_WakeRx, PIN_WakeRx );


while(1) {

__bis_SR_register(LPM0_bits | GIE);
__no_operation();

// Do some other stuff here after it wakes up

}

#pragma vector=PORT2_VECTOR
__interrupt void pushbutton_ISR (void)
{

switch(__even_in_range( P2IV, 10 )) {

case 0x00: break;      // None
case 0x02: break;      // Pin 0
case 0x04:                 // P2.1, WakeRx signal from AS3933

__bic_SR_register_on_exit(LPM0_bits);
break;


case 0x06:break;
case 0x08: break; // Pin 3
case 0x0A: break; // Pin 4
case 0x0C: break; // Pin 5
case 0x0E: break; // Pin 6
case 0x10: break; // Pin 7
default: _never_executed();
}
}

  • Niaz Ahmed said:
    I have a break point right after the sleep mode mode on _no_operation().

    You shall have more than one NOP operation in a row and shall *not* put breakpoint on first one.

    __bis_SR_register(LPM0_bits | GIE);
    __no_operation();
    __no_operation(); // put breakpoint here

  • Well I tried that too but did not help me out. I also used a breakpoint inside the ISR but it never went there. 

  • Ilmars is right. Since the CPU fetches the instruction after the LPM entry in the very same cycle it goes into LPM, the breakpoint on the instruction right after the LPM entry is hit before the device goes into LPM. So the ISR cannot have be called then. Put any breakpoint on the instruction after the first NOP. The breakpoint there cannot be hit then before the ISR has been called.

    BTW: there is no need to provide case statements for empty cases. It’s a waste of digital ink. Also, I fall possible cases do have a case statement, there is no default case required too. But of course it could be that the compiler isn’t smart enough. In theory, it should even complain about your case 0x0c and above, because the __even_in_range told that the values are between 0 and 10 (decimal!). (of course, it must be 0x10 in the intrinsic :) but the compiler can’t know, else the parameter would be superfluous)

  • I just figured out the problem and it turned out to be a hardware issue rather than software issue. The wake up pulse the msp was waiting for was only 1.8V. I think this amplitude was not enough for msp to read as high logic. The watch-dog receiver was providing 3V pulse but there was a resistor between the two components. Now I have removed that resistor and the msp is waking up as it was suppose to.

    However, I would like to thank you for your suggestions. I am getting the point of not having the breakpoint right after the LPM instruction. I have included couple of NOPs now in the code.

    Niaz

**Attention** This is a public forum