?

Log in

No account? Create an account
ez430 Interrupt snags... - Sarah's Blog — LiveJournal [entries|archive|friends|userinfo]
Sarah

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

ez430 Interrupt snags... [Apr. 13th, 2009|12:50 pm]
Sarah
If you compile the example programs for interrupt routines in Code Composer Essentials compiler, you may come across the error "unrecognized #pragma".

The reason is, the header files for this compiler have different vector definitions than the IAR Embedded Workbench program which also ships with the device. (IAR sucks for keeping the code size small).

To save you a bit of time hunting through the headers - here's the changes that are needed:

#include <msp430x20x3.h>

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;       // Stop WDT
  P1DIR |= 0x01;                  // P1.0 output
  CCTL0 = CCIE;                   // CCR0 interrupt enabled
  CCR0 = 50000;
  TACTL = TASSEL_2 + MC_2;        // SMCLK, contmode

  _BIS_SR(LPM0_bits + GIE);       // Enter LPM0 w/ interrupt
}

// Timer A0 interrupt service routine
UNREGOGNIZED PRAGMA
#pragma vector=TIMERA0_VECTOR  
__interrupt void Timer_A (void)
{
  P1OUT ^= 0x01;                  // Toggle P1.0
  CCR0 += 50000;                  // Add Offset to CCR0
}

--- --- --- --- --- --- --- --- --- 

#include <msp430x20x3.h>

void main(void)
	{
	WDTCTL = WDTPW + WDTHOLD;  
	P1DIR |= 0x01;
	CCTL0 = CCIE;
	CCR0 = 5000;
	TACTL = TASSEL_2 + MC_2;
	_BIS_SR(LPM0_bits + GIE); 
	}

__interrupt void Timer_A (void)
	{
	P1OUT ^= 0x01; 
	CCR0 += 5000; 
	}

TIMERA0_ISR(Timer_A)
linkReply