1sec delay using timer in 8051

Status
Not open for further replies.

anboli

Full Member level 2
Joined
Mar 9, 2012
Messages
144
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
2,512
hi, im using the timer newly and i dono how to create a delay value for 1sec.

please anyone help me how to program or what the value i should need to give for the timer registers.

and im using a 12MHz crystal.
 

hi, im using the timer newly and i dono how to create a delay value for 1sec.

please anyone help me how to program or what the value i should need to give for the timer registers.

and im using a 12MHz crystal.

8051 timers use 1/12 of the crystal frequency regardless of machine cycle.
Thus timer's clock frequency= 12/12=1MHz.
And T=1/1=1us.
Now by using 16 bit timer mode we can count from 0 to 65536.
which gives a delay of 65536 us.So by iterating we can get the desired delay as shown below:
No. of times to loop: 1/(65536u)=15.25
So by repeating the counts for 15 times we can get a delay of 1 sec(not accurate though).
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…