Timer AVR

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.

Reply to
dynio
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.