Hello(Guten Tag) 1.Do you post answers in english, too? 2.If YES, can someone help me with a timer ISR problem in IAR EW for Msp430f149?
I did a simple C program for a target board.
I was supposed to blink 2 leds (one in main function and one from
TimerA ISR). The one from main() works (it blinks). The one from TimerA
doesn't (stays off).
When I inspected registers from IAR EW (Debugging with FETDebugger = on
the target board)I noticed that TAR doesn't change.
I'm puzzled...why doesn't timer A start? Is there a problem with the
source code? Is there something about IAR?
I initialised registers for basic clock, watchdog(so it won't reset
the software), timer A, port.
Also on the hardware side: board is powered.
There is an inpuit clock at around ~5MHz available...but for now I went
with DCO.
I can't find anything wrong in C
Below is the source code:
#include <msp430x14x.h>
#include "types.h"
//u8=unsigned char u16=unsigned int
u16 counter=0;
u32 counter2=0;
u8 toggle=0;
u8 toggle2=0;
#pragma vector = TIMERA1_VECTOR //interupt syntax for IAR 2.x
__interrupt void timer_isr(void)
{
counter++;
if (counter>32) //999
{
counter=0;
if (toggle)
P2OUT &= ~0x04;
else
P2OUT |= 0x04;
toggle ^=1;
}
}
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P2SEL = 0x00;
P2DIR = 0xff;
P2OUT = 0xff;
P2IE = 0x00;
P2IFG = 0x00;
P2IES = 0x00;
DCOCTL = DCO0 + DCO1 + DCO2;
BCSCTL1 = XT2OFF + RSEL0 + RSEL1 + RSEL2 ;
BCSCTL2 = 0;
TAR = 0;
TACTL = MC_0;
//external input clock ~5MHz although not used
TACCR0=999;
TACTL = TASSEL_1 + ID_0 + MC_1 +TAIE;
//TACTL= TASSEL_2 + ID_3+MC_1+TAIE;
_EINT();
__bis_SR_register(GIE);
while(1)
{
counter2++;
if (counter2>20000)
{
counter2=0;
if (toggle2)
P2OUT &= ~0x02;
//P2OUT=0x00;
else
//P2OUT &= ~0x02; //0x4;
P2OUT|=0x02;
toggle2 ^=1;
}
}
}
Hi I think you have forget to enable the Capture/compare Interrupt. Add to your source : TACCTL0 = CCIE; // IRQ enable TACTL = TASSEL_1 + ID_0 + MC_1 +TAIE; hope this will work CU Bepi
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.