Page 1 of 1

Interrupts and service routines

PostPosted: Thu Feb 10, 2005 3:25 am
by Gerard
I know this is a kind of noob question but I though you guys might be able to help me out.

I'm using Salvo on a TI MSP430 and I'm using the Crossworks IDE.

Can someone give me a clear example of how to register an ISR with an interrupt in the INTVEC. I don't seem to be able to find it anywhere... Thanks a lot in advance!

Gerard


Re: Interrupts and service routines

PostPosted: Thu Feb 10, 2005 6:44 am
by aek
Hi Gerard.

Look in salvo ut u1isr.c, in the section where you see

#elif defined(SYSX)

That's an MSP430 ISR, with the proper syntax for each of the four MSP430 compilers that Salvo supports. (SYSX is for the Rowley compiler).

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


Re: Interrupts and service routines

PostPosted: Fri Feb 11, 2005 2:51 am
by Gerard
Thanks, gave me a good point to start from. Found this on the Internet making it clear for me, especially the use of the timer's registers:

code:
#include "msp430x14x.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT

BCSCTL1 |= XTS; // ACLK= LFXT1= HF XTAL(8MHz)

do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?

BCSCTL2 |= SELM_3; // MCLK= LFXT1 (safe)


P1OUT = 0x00;
P1DIR = 0xFF;

CCR0 = 10000; // (1/8000000) x 10000 = 0.00125S
CCR1 = 20000; // (1/8000000) x 20000 = 0.0025S
CCR2 = 30000; // (1/8000000) x 30000 = 0.00375S

CCTL0 = CCIE; // CCR0 interrupt enabled
CCTL1 = CCIE; // CCR1 interrupt enabled
CCTL2 = CCIE; // CCR2 interrupt enabled
TACTL = TASSEL_1 + MC_2 + TAIE; // ACLK, Contmode, interrupt enabled

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

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0 (void)
{
CCR0 += 10000; // Add Offset to CCR0
P1OUT ^= BIT0; // TIMERA0 test // (1/8000000) x 10000 = 0.00125S
}

// Timer_A3 Interrupt Vector (TAIV) handler
#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1(void)
{
switch( TAIV )
{
case 2: CCR1 += 20000; // Add Offset to CCR1 // (1/8000000) x 20000 = 0.0025S
P1OUT ^= BIT1; // TIMERA1 test
break;
case 4: CCR2 += 30000; // Add Offset to CCR2 // (1/8000000) x 30000 = 0.00375S
P1OUT ^= BIT2; // TIMERA1 test
break;
case 10: P1OUT ^= 0x01; // Timer_A3 overflow (1/8000000 x 65535) = 0.008191875S
P1OUT ^= BIT3; // TIMERA1 test
break;
}
}


[This message has been edited by Gerard (edited February 11, 2005).]