/* * www.microDigitalEd.com * Ex5-13 */ #include "msp.h" int main(void) { /* initialize P2.0 for red LED */ P2->SEL1 &= ~1; /* configure P2.0 as simple I/O */ P2->SEL0 &= ~1; P2->DIR |= 1; /* P2.0 set as output */ TIMER_A1->CTL= 0x0211; /* SMCLK, ID= /1, up mode, TA clear */ TIMER_A1->EX0= 0; /* Divider2 = 1/(0+1) = 1/1 */ TIMER_A1->CCR[0]= 30 - 1; while (1) { while((TIMER_A1->CCTL[0]& 1) == 0); /* wait until the CCIFG is set */ TIMER_A1->CCTL[0]&= ~1; /* clear interrupt flag */ P2->OUT ^= 1; /* toggle red LED */ } }