eddy12345
Joined: 22 Jan 2008 Posts: 4 Location: united kingdom
|
14 Feb 2008 8:24 understanding timers in PIC16F84 |
|
|
|
|
Hi guys,
I have a problem trying to make a counter that can handle a wide range of time.
Assuming that my prescaler is 4 and i mov 231 into TMR0
i get 4(256-231)uS = 100uS
and every time it overflows, i increase the value of a counter. In this case it will take 100uS for every count(untill the maximum value have been reached, which is 125).
How do i make a counter that can handle values between 1 to 5000? I want it to be that way because i will produce a set of time delay for the output :
1) 0mS for 600<count<5000
2) 4mS for 0<count<75
3)call table delay values for 75<count<600
4) restart program count>5000
|
|
adidav
Joined: 19 Apr 2006 Posts: 15 Helped: 1 Location: Romania
|
14 Feb 2008 11:40 Re: understanding timers in PIC16F84 |
|
|
|
|
Hi eddy12345,
Don't you use the timer1. Is a 16bit timer and you can have time period from a few us till ms.
Example:
Fquartz = 4MHz, Prescaler = 2
for TMR1 = 0 the time is 131.07ms
for TMR1 = 65500 the time is 70us
The calculations was made using the formula:
time = ((Fquartz * Prescaler) / 4) * (65535 - TMR1), the result is in us.
Greetings,
ADi
|
|