Hi Everyone,
I have try to setup some timers with interrupt routines to handle the output result. But the timer didn't work as expected, With a single interrupt it works fine(Timer0_A0_ISR), but when I try to add more timers with interrupt into the code, the new interrupt didn't work, even the original single one didn't work as well. Is there anything I should be aware of?
#include <driverlib.h>
#include <msp430.h>
/***************************Timer Configuration Initialization********************************/
// TimerA0 UpMode Configuration Parameter A0 is for routine #0
Timer_A_initUpModeParam initUpParam_A0 =
{
TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock Source 32Khz
TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/4 = 8KHz
120, // timer period
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE , // Enable CCR0 interrupt
TIMER_A_DO_CLEAR, // Clear value
true // Start Timer
};
// TimerA1 UpMode Configuration Parameter A1 is for routine #1
Timer_A_initUpModeParam initUpParam_A1 =
{
TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock Source
TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/4 = 8kHz
2000, // Timer period 0.25 s
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE , // Disable CCR0 interrupt
TIMER_A_DO_CLEAR, // Clear value
true //start Timer
};
// TimerA2 UpMode Configuration Parameter A2 is for routine #2
Timer_A_initUpModeParam initUpParam_A2 =
{
TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock Source
TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/4 = 8kHz
16, // Timer period output
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE , // Disable CCR0 interrupt
TIMER_A_DO_CLEAR, // Clear value
true
};
int main(void) {
WDT_A_hold(WDT_A_BASE);
PMM_unlockLPM5();
// Initializations
GPIO_setAsOutputPin(GPIO_PORT_P2, GPIO_PIN1); //set as output pin for scope monitoring
GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); //setup for the two output on Luachpad
GPIO_setAsOutputPin(GPIO_PORT_P9, GPIO_PIN7);
Timer_A_initUpMode(TIMER_A0_BASE, &initUpParam_A0);
Timer_A_initUpMode(TIMER_A1_BASE, &initUpParam_A1);
Timer_A_initUpMode(TIMER_A2_BASE, &initUpParam_A2);
__enable_interrupt();
while(1){
//__bis_SR_register(LPM3_bits | GIE); // Enter LPM3, interrupts enabled
}
return (0);
}
// Timer A1 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN1); //Generate Waveform output
__bic_SR_register_on_exit(LPM3_bits); //exit LPM3
}
#pragma vector = TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR (void)
{
GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); //flash LED1
__bic_SR_register_on_exit(LPM3_bits); // exit LPM3
}
#pragma vector = TIMER2_A0_VECTOR
__interrupt void TIMER2_A0_ISR (void)
{
GPIO_toggleOutputOnPin(GPIO_PORT_P9, GPIO_PIN7); //flash LED2
__bic_SR_register_on_exit(LPM3_bits); // exit LPM3
}
The code is running based on MSP430FR6989, CCS6.0 environment.
Thanks ahead!