Hi, I want that two LEDs blink at specific times using the compare module of the timer A of the MSP430F5438A.I was thinking use the up mode of the ccomparator.
The program works great when I use just one register ( In my case, the TA1CCTL0), but when I do the same, with other register, for example TA1CCTL0, the program just restart, I can not see why. if anybody can help me, I will really appreciate that. This is my code:
#include "msp430x54xA.h"
unsigned int i=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1OUT = 0x00;
P1DIR |= BIT0;
P1DIR |= BIT1;
//LEDs sequence
P1OUT=0x01;
for(i=15000;i>0;i--);
P1OUT=0x02;
for(i=15000;i>0;i--);
P1OUT=0x01;
for(i=15000;i>0;i--);
P1OUT=0x02;
for(i=15000;i>0;i--);
P1OUT=0x00;
P7SEL|=0x03;//XIN XOUT
UCSCTL4=0;//ACLK
UCSCTL5=0;
UCSCTL6=18;
TA1CCR0=32768;
TA1CTL=0x116;// ACLK source, ACLK/1, up mode, ISR enable
TA1CCTL0=16;
// TA1CCTL1=16; if I uncomment this, the program just RESTART
__bis_SR_register(GIE);
while(1);
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
switch(TA1IV)
{
case 2:
P1OUT ^= 0x02;
break;
case 14:
P1OUT^=0x01;
break;
default:
break;
}
TA1CTL=0x116;
}
#include "msp430x54xA.h"
unsigned int i=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1OUT = 0x00;
P1DIR |= BIT0;
P1DIR |= BIT1;
//LEDs sequence
P1OUT=0x01;
for(i=15000;i>0;i--);
P1OUT=0x02;
for(i=15000;i>0;i--);
P1OUT=0x01;
for(i=15000;i>0;i--);
P1OUT=0x02;
for(i=15000;i>0;i--);
P1OUT=0x00;
P7SEL|=0x03;//XIN XOUT
UCSCTL4=0;//ACLK
UCSCTL5=0;
UCSCTL6=18;
TA1CCR0=32768;
TA1CTL=0x116;// ACLK source, ACLK/1, up mode, ISR enable
TA1CCTL0=16;
// TA1CCTL1=16;
__bis_SR_register(GIE);
while(1);
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
TA1CTL=0x116;
P1OUT ^= 0x02;
}