Micro controller timer functioning ?

Status
Not open for further replies.

agnivesh

Member level 2
Joined
Apr 24, 2004
Messages
45
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
UK
Activity points
549
considering each machine cycle of 8051 consisting of 12 external oscillator pulses and, let's say external oscillator frequency is 'f', then each machine cycle will take 12/f seconds to complete (am i right ?). timers and counters use this machine cycle to increment the registor bits.

how timers use this info to calculate 1 sec time interval ?
how timers adapt to calculate 1 sec time interval again if we change the external oscillator frequency ?

when we write code, we say wait for 'n' seconds and then raise 'x' pin state to logic 1, how microcontroller calculates those 'n' seconds interval ? how it will calculate the same n second interval if we change the external oscilllator frequency ?

with regards
agnivesh
 

yes it is true , if you are using 8051 family , timer counts one up each F/12
but if you are using a compiler , when you say wait for 1s , you should say how much your osciator frequency is . then compiler calculates number that should be loaded to timer and places it in your program .

if you change oscilator frequency , for example if you enter 12MH in your compiler as oscilator frequency , and when you are using MCU , you use 24MH crystal , then 1s would be 0.5s.

regards.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…