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.

MSP430FR2422: RTC not behaving --- how to?

Part Number: MSP430FR2422

I have an application that I want to boot into LPM3 with P1.1 enabled as a switch....Upon pushing this switch I want a PWM to operate AND I enable the RTC at once per second.  I exit P1 interrupt still sleeping.  The hope is that after 100 seconds a counter in the RTC recognizes this and puts the device into LPM3.5.  Upon coming out of 3.5 I attempt to clear PMMREGOFF and force a brownout which puts me back at 'normal' mode.  None of this seems to be happening correctly....The code below after pushing the button starts the PWM then after about 2 seconds of flashing the LED just stays on.  I am finding it EXTREMELY difficult to work with this LPM3.5/RTC.  I constantly am trying to pause the debugger to reboot but CCS will have non of it and tends to lock up.  Can someone give me suggestions on both what I am doing wrong in the code as well as why CCS keeps wanting to lock up?  BTW. The RTC #2 program under this part and resource explorer does similar.  I've cut and pasted it just changing the IO to my IO and CCS still wanders off.  I have loaded the RTC #1 program onto the board and it works fine (every second it just toggles the IO in the RTC).

I would ultimately like to go into LPM3 after the PWM is over (my understanding is PWM won't work below LPM3) and reboot to a state of just very low power ie 3.5 until someone pushes the button again.

Thanks

CCS when pause is pushed responds with:

MSP430: Trouble Halting Target CPU: Internal error

#include <msp430.h> 
#include "funct.h"

volatile unsigned int count;
volatile unsigned int flag = 0;

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer

    //small macro to flash LED to show a reset has occured.
    configGPIO();
    PM5CTL0 &= ~LOCKLPM5;
    __delay_cycles(80000);
    P1OUT &= ~BIT4;
    configACLK();
	if (SYSRSTIV == SYSRSTIV_LPM5WU) { //wake up from LPM3.5?
	    flag = 0;
	    configGPIO();
	    PMMCTL0 = PMMPW;
	    PMMCTL0 &= ~PMMREGOFF; //clear LPM3.5 bit
	    PMMCTL0 |= PMMSWBOR; // force reboot to normal
	}
	else { //no?
	    __bis_SR_register(LPM3_bits + GIE); //LPM3.5 entry point
	}
	return 0;
}

#pragma vector = RTC_VECTOR
__interrupt void thirtyMinuteCounter(void)
{
    switch(__even_in_range(RTCIV, RTCIV_RTCIF))
    {
        case RTCIV_NONE : break;            // No interrupt pending
        case RTCIV_RTCIF:                   // RTC Overflow
            count++;
            if (count >= 100)
            {
                count = 0;
                PMMCTL0 = PMMPW; // Open PMM Registers for write
                PMMCTL0_L |= PMMREGOFF; //sets LPM3.5
            }
            break;
        default:
            break;
    }
}

#pragma vector = PORT1_VECTOR
__interrupt void ifNonLPM3_5(void)
{
    switch (__even_in_range(P1IV, 4))
    {
        case 4: //P1.1
            configTA0_PWM(16384, 4); //3276
            configRTC(33); //1800
            break;
        default:
            break;
    }
}

  • I don't quite understand why you're doing a BOR after restarting from LPM3.5 -- I'm pretty sure you're in "normal" mode already. I think example msp430fr235x_lpm3_5_01.c shows this, but it's not very didactic since it doesn't have anything else interesting to do.

    Keep in mind that your variables (count and flag) go back to 0 on a wakeup.

    Unsolicited: I've never seen someone go into LPM3.5 by "return"ing to LPM3. I don't see any reason why it wouldn't work. On the other hand (being old and cynical) I'm a bit wary of any construct that (I suspect) no one has ever tried. Just keep an eye on it, that's all.

  • Bruce....

    I copied this from the other thread.....This is ultimately what I want to do but I'm not sure I can do this....I would like to copy a variable to back up memory....See questions below....

    Let me ask you this.....

    Should I be able to do the following?

    At power up wait until a switch is pushed.  After switch is pushed have a pwm operate for a period of time (this is governed by a counter in the RTCIV).  After this expires within the RTCIV I would then invoke LPM3.5 by setting PMMREGOFF.  I would like to come awake then again by the use of the same switch that was pushed earlier and at this action I would like the RTCIV to count to a different value.  So for instance you push 1.4 the PWM will operate for let's say 1/2 hour, then I go into LPM3.5 for a really long time let's say 50 hours (let's say all RTC registers stay the same (ie 30 minute interrupt) it is just a count variable that changes here).  At the same time as LPM3.5  is running and you are in the 50 hour window I would like the a press of 1.4 to awake you and turn on the PWM again.  

    Questions:

    Is the above possible to do in code or won't the RTC allow me to do this?

    Just prior going into LPM3.5 do I have to use some form of *(unsigned int *)BKMEM_BASE and if so how do I use this?  (I care about P1.4 having a pulldown and being interrupt capable)

    My next question is if I have a count variable within the RTCIV how do I store that value into let's say backup memory so that when I come out of LPM3.5?

    thanks

  • Hi

    Maybe this document can help you with this application

      

  • Hi Gary...

    This looks interesting....I will look at this

    Thank you

**Attention** This is a public forum