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.

MSP430G2553: Failing to setup timer interrupt with LPM3

Part Number: MSP430G2553

Hello,

I made a project that used the DCO and a timer interrupt with LPM3 that worked fine. Now I am trying to do the same just with the VLOCLK and I simply cannot get it to work. Reason why the VLOCLK is because I don't need a lot of calculating power when awake and the device is usually in LPM4 with button interrupts (not in the code) and it only runns on a CR2032 and should last as long as possible. The interrupt does not fire. I tested the clock and it had about 10 KHZ which seems correct for the VLOCLK (although the range that is specified from 4 to 20 KHz seems rediculous).

#include <msp430.h> 

void sleep_ms()
{
    TACTL = (TASSEL1 | TACLR | TAIE);
    CCTL0 = CCIE;
    CCR0 = 0;
    TACCR0 = 3;
    TACTL |= MC_1;
    __bis_SR_register(LPM3_bits | GIE);
}

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;

    P1OUT = 0x00;
    P1DIR = 0xFF;
    P2OUT = 0x00;
    P2DIR = 0xFF;
    P3OUT = 0x00;
    P3DIR = 0xFF;

//P1SEL = BIT0  // to test the frequency

BCSCTL3 |= LFXT1S_2; //_bis_SR_register(SCG1 | SCG0); _NOP(); _NOP(); _NOP(); BCSCTL2 |= SELM_3 + DIVM_3; IFG1 &= ~OFIFG; __enable_interrupt(); while(1) { P1OUT |= 0x02; sleep_ms(); P1OUT &= ~0x02; sleep_ms(); } } #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { LPM3_EXIT; TACTL = 0; CCTL0 = 0; }

So what am I missing? I simply don't see anymore what is going on.

Thanks for any tip.

  • >    TACTL = (TASSEL1 | TACLR | TAIE);

    TASSEL1 is a bit setting, not a field setting, so this sets TASSEL=2 (SMCLK). To get ACLK (TASSEL=1), use something like:

    >   TACTL = (TASSEL_1 | TACLR | TAIE);

    Unsolicited: It looks like you're setting MCLK=10kHz/8=1.25kHz, which is pretty slow. I encourage you to measure how much power you're actually saving. When I did that experiment (many years ago), I observed that power didn't scale (down) linearly with MCLK speed; I concluded it was better to run MCLK moderately fast (0.5-1.0MHz) so as to spend more time in LPM.

    [Edit: I just noticed you're setting both TAIE and CCTL0:CCIE, but you only have an ISR for the latter. I think you don't need both, so I suggest you remove TAIE.]

  • Seems its working now halfway. Could it be that the external 32KHz oscillator is the lowest power clocksource?

**Attention** This is a public forum