Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 66738

Forum Post: RE: Error in Timer

$
0
0
I made another program that is more accurate and reliable than my previous programs using SMCLK since I don't have to worry about the crystal being faulty at times. Here is my program that will have an output of 2 LEDS blinking alternately every 1 sec.: #include volatile 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 = 65535; //(65535*8)/1.1MHz=0.48s TACTL = TASSEL_2 | ID_3 | MC_1; // SMCLK/8, Up mode i=0; while(1){ _BIS_SR(GIE); //enter LPM0 with interrupt if (i =2) //turn on LED2 and turn off LED1 for 1sec. {P1OUT = 0X40;} if (i==4) {i=0;} }} //timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A(void) {i++;}

Viewing all articles
Browse latest Browse all 66738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>