MSP430F123 Timer "A" Interrupts (C code)

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!

// M. Buccini

// Texas Instruments Inc.

// Feb 2005

// Built with IAR Embedded Workbench Version: 3.21A

and

I am using the (free) IAR Embedded Workbench V 2.31E from the TI website.

Consider downloading an updated version.

http://focus.ti.com/docs/toolsw/folders … start.html

#pragma vector=TIMERA1_VECTOR

__interrupt; void Timer_A(void)

Try removing the ;

Old Cow–

Thank-you for the suggestion; I should have done that first!

After downloading the newest version I still have two warnings no blinking LED. The warnings (and their associated code lines) are:


Warning[Pe064]: declaration does not declare anything C:\MSP430_LCD_Counter\fet120_ta_04.c 39

Warning[Pe609]: this kind of pragma may not be used here C:\MSP430_LCD_Counter\fet120_ta_04.c 38


#pragma vector=TIMERA1_VECTOR

__interrupt; void Timer_A(void)


I will play with this some more over the weekend and am still open to suggestions.

Thank-you.

Dixon–

I will try your suggestion, also.

Thank-you.

All–

After loading the latest version of IAR Kickstart (V3.41) from TI, I still could not get things to work. After much hair-pulling, I did the following:

  1. Uninstall the old version of Kickstart

  2. Go to c:\program files\iar and remove the old directories left behind

  3. Install new version

  4. Start a new project bringing only my example code source file along and making sure I set Project>Options>Debugger for Debugger (not Simulator).

  5. Reseat my MSP430F123 in its socket!

All is much better now.

Thank-you for the suggestions!