Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to genarate 1 second with this code?

Status
Not open for further replies.

matin-kh

Member level 3
Member level 3
Joined
Nov 9, 2013
Messages
67
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
iran
Visit site
Activity points
1,955
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
 

first yu need to tell us what UC this is for ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top