Timer AVR

Nov 25, 2005 0 Replies

Potrzebuje wydluzyc programowo 8bit timer do 16bit. (M8535) Wmyslilem sobie (skracajac) tak:



TCCR0 = 0x02; //Nie jest wlaczony tryb CTC (clear on compare) TIMSK = 0x05; //Wlaczone przerwania TIMERa 0 i 1



void timer_overflow () { //overflow interrupt



unsigned char temp = time_var >> 8;



if ( clk < temp ) {



clk++;



} else {



TIMSK |= 0x02; //OCIE0=1 clk = 0;



}
}

void timer_compare_match () { //compare match interrupt



TIMSK &= ~0x02; //OCIE0=0 test = TCNT0; //kontrolnie OCR0 = time_var & 0x00FF;



}

Zmienna "test" jest wyswietlana w glownej petli na LCD i przybiera wartosc 1 lub czasem 2 Wg mnie powinna miec wartosc OCR0 + 1 albo OCR0 + 2 i o to mi chodzi. Moglby mnie ktos oswiecic gdzie popelniam blad.



Pozdr d.


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required