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.

MSP430F5529: Timer0 interrupt not working

Part Number: MSP430F5529
Other Parts Discussed in Thread: MSP-EXP430F5529LP

Hello,

I am having troubles making the interrupt to work. I want the red led to toggle every 1s.

After 1 toggle the code stays trapped in SFR trap. In debug I see GIE is cleared. In normal mode, after a reset, it toggles once or twice (randomly) and then nothing happens.

What am I missing?

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <msp430.h>
#include <lcd.h>
#include <stdlib.h>
#include <stdio.h>
#define RED_LED_ON() P1OUT |= BIT0
#define RED_LED_OFF() P1OUT &= ~BIT0
#define RED_LED_TOGGLE() P1OUT ^= BIT0
void SetupUCS(void);
void SetupTimers(void);
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= BIT0; // configure P1.0 as output
P4DIR |= BIT7; // configure P4.7 as output
SetupUCS();
SetupTimers();
while(1)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thank you,

Catalin

  • You enabled the TAIFG interrupt but there is not an ISR for it. (TIMER0_A1_VECTOR) Well, sort of. Your ISR is written as if it were using the A1 vector although it wouldn't work since you use the CCR1 value. The A0_VECTOR services only the CCR0 interrupt.

    Leave TAIE clear since you don't need or want a second interrupt just after the CCR0 interrupt.

  • Thanks David,

    Reading your message along with Timer_A Block diagram made me understand what I did wrong. Thanks for the quick answer. Posting below the working code, just in case someone else wants to use it as a reference. For the record, I am using a MSP-EXP430F5529LP board.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <msp430.h>
    #include <lcd.h>
    #include <stdlib.h>
    #include <stdio.h>
    #define RED_LED_ON() P1OUT |= BIT0
    #define RED_LED_OFF() P1OUT &= ~BIT0
    #define RED_LED_TOGGLE() P1OUT ^= BIT0
    void SetupUCS(void);
    void SetupTimers(void);
    void main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
    P1DIR |= BIT0; // configure P1.0 as output
    P4DIR |= BIT7; // configure P4.7 as output
    SetupUCS();
    SetupTimers();
    while(1)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Cheers,

    Catalin

**Attention** This is a public forum