Hi, I need to produce a timer in which P1.0 and P1.6 will turn on/off alternately every 1 sec. I already made a program and I can't seem to get my desired output. Can anyone be able to help?
This is my program:
#include <msp430g2553.h>
int i;
void main(void){
WDTCTL = WDTPW + WDTHOLD; //Stop Watchdog Timer
P1DIR |= 0x41; //Setting P1.0 and P1.6 as output direction
CCTL0 = CCIE; //Enable CCR0 interrupt
CCR0 = 32768; //32768/32768=1Hz
TACTL = TASSEL_1 + MC_1; //ACLK,UPMODE
i=0;
while(1){
_BIS_SR(GIE); //enter LPM0 with interrupt
if (i<2) //turn LED1 on and turn off LED2 for 1sec.
{P1OUT = 0X01;}
if (i>2) //turn on LED2 and turn off LED1 for 1sec.
{P1OUT = 0X40;}
if (i==3)
{i=0;}
}}
//timer A0 interrupt service routine
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A(void)
{i++;}