Hi. I'm trying to blink led with 1second frequency using SMCLK sourcing from DCO. I set clock frequency to 1Mhz. When i set the CCRO=50000 and interrupt counter(led_counter) to 20 the led blinks wiith a faster frequency(faster than 1 second). If i change CCR0=25000 and interrupt counter to 40 the blinks significantly slower (approx 2 second) than the previous situation. Again with CCR0=12500 and interrupt counter = 80 blinking rate falls nearly 3-4 second.
I couldn't find out where the fault is. Can someone explain this problem ?
include <msp430.h> volatile int led_counter=0; // Interrupt counter void main(void) { WDTCTL = WDTPW | WDTHOLD; . BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1DIR |= BIT0; // Port1.0 output. CCTL0 = CCIE; CCR0 = 50000; // TACTL = TASSEL_2 + MC_1; _BIS_SR(LPM0_bits + GIE); while(1); return 0; } #pragma vector=TIMER0_A0_VECTOR __interrupt void timer_isr(void) { led_counter++; if(led_counter==20) { P1OUT ^= BIT0; // Port1.0'ı tersle. led_counter = 0; } CCR0 += 50000; }