Hi every one,
I have some questions about the part of a code which is shown below:
interrupt [TIM1_OVF] void timer1_ovf_isr(void)
{
rtc_cnt+=2.097152;
if(rtc_cnt>60){
rtc_cnt-=60;
timer_refresh=1;
if(off_timer>0){
off_timer--;
if(off_timer==0){
timer_ovf=1;
rtc_cnt=0;
}
}
TCCR1B=0x04;
TIMSK=0x24;
}
}
this code is for atmega8 and I can't understand how it generate one second with this and after initialize the off_timer we can generate a timer for everything? why rtc_cnt which we defined in the code is equal to 2.097152? and if we want to use timer/counter0 or 2 how much this value should be?
could be possible to use two timer/counter to generate 1 second for different purposes because I don't want to conflict my period_times and off_timers?
with best regards,
Matin