Hello–
I am new to both MSP430 and programming and have some questions about using Timer A interrupts on the MSP430F123.
I am attempting to use timer A to give a periodic interrupt that I can use as a time reference. To keep things simple, I started with the following sample code from the TI website. Unfortunately, I cannot get this code to run.
//******************************************************************************
// MSP-FET430P120 Demo - Timer_A, Toggle P1.0, Overflow ISR, 32kHz ACLK
//
// Description: Toggle P1.0 using software and the Timer_A overflow ISR.
// In this example an ISR triggers when TA overflows. Inside the ISR P1.0
// is toggled. Toggle rate is exactly 0.5Hz.
// Proper use of the TAIV interrupt vector generator is demonstrated.
// ACLK = TACLK = 32768Hz, MCLK = SMCLK = DCO ~800kHz
// //* An external watch crystal on XIN XOUT is required for ACLK *//
//
// MSP430F123(2)
// -----------------
// /|| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P1.0|–>LED
//
// M. Buccini
// Texas Instruments Inc.
// Feb 2005
// Built with IAR Embedded Workbench Version: 3.21A
//******************************************************************************
#include <msp430x12x2.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
TACTL = TASSEL_1 + MC_2 + TAIE; // ACLK, contmode, interrupt
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
}
// Timer_A3 Interrupt Vector (TAIV) handler
#pragma vector=TIMERA1_VECTOR
__interrupt; void Timer_A(void)
{
switch( TAIV )
{
case 2: break; // CCR1 not used
case 4: break; // CCR2 not used
case 10: P1OUT ^= 0x01; // overflow
break;
}
}
The compiler gives me these errors:
Warning[50]: Unknown #pragma identifier: ‘vector’
Warning[14]: Type specifier missing; assumed “int”
I am using the (free) IAR Embedded Workbench V 2.31E from the TI website. This is running on a MSP-TS430DW28 demo board from TI, with the MSP430F123 installed.
This program should run Timer A from the 32 KHz crystal and toggle an LED on Port 1.0 everytime the timer overflows. In practice, the LED is off while cpu is reset, and comes on solid when the program is running.
Attempts to step through the program have been unsuccessful as C-SPY crashes when I step into this line:
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
The 32 KHz crystal oscillator has been confirmed to be running. I can make the LED blink by means of a software delay loop.
Any suggestions as to how to make this code run properly would be appreciated.
Thank-you!