Hi,
I am looking for a simple example on how to use the timer and interrupts on the M430G2553. I have used timers and interrupts on other microcontrollers and compilers but am having difficulty compiling the examples I have found on the net for the M430G2553 on CCS.
I have created a new project on CCS v6.1 for the M430G2553 and entered the following based on an example I found on the internet ( I just changed the header file to msp430g2553):
/* * MSP430 Timer Tutorial Example Code 1 * Anthony Scranney * www.Coder-Tronics.com * August 2014 * * Switching the MSP430G2253 Launchpad LED's on and off */ #include <msp430g2553.h> int Control = 0; int main(void) { /*** Watchdog timer and clock Set-Up ***/ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer DCOCTL = 0; // Select lowest DCOx and MODx BCSCTL1 = CALBC1_1MHZ; // Set range DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation /*** GPIO Set-Up ***/ P1DIR |= BIT0; // P1.0 set as output P1OUT &= ~BIT0; // P1.0 set LOW (Red LED) P1DIR |= BIT6; // P1.6 set as output P1OUT &= ~BIT6; // P1.6 set LOW (Green LED) /*** Timer0_A Set-Up ***/ TA0CCR0 |= 3000; // Counter value TA0CCTL0 |= CCIE; // Enable Timer0_A interrupts TA0CTL |= TASSEL_1 + MC_1; // ACLK, Up Mode (Counts to TA0CCR0) _BIS_SR(LPM0_bits + GIE); // Enter Low power mode 0 with interrupts enabled } #pragma vector=TIMER0_A0_VECTOR // Timer0 A0 interrupt service routine __interrupt void Timer0_A0 (void) { Control++; P1OUT ^= BIT0; // P1.0 Toggle (Red LED) if (Control == 4) { P1OUT ^= BIT6; // P1.6 Toggle (Green LED) Control = 0; } }
When I compile I receive the following error at the interrupt service routine on line 37:
expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
I receive the same error when trying to compile other example programs using the timer and interrupts. Looking at the header file msp430g2553.h shows that TIMER0_A0_VECTOR is correct.
Could someone please point out what is wrong in the code above or provide a very simple example using the timer and interrupts for the MSP430G2553. I just need to know the correct way to include the interrupt service routine in my code.
Dan