PDA

View Full Version : Timer Usage with 18F252



eshatara
- 2nd July 2008, 07:28
I'm trying to implement a simple timer with PBPro using the 18F252. I need to know when 30 minutes are up after a given event. I figured I'd use the timer function to give me a 1 sec or 6 second "overflow" and use that to increment a software counter until I get to the desired time lapse.

I understand the concept of pre-loading the TMR0L and TMR0H bytes. I'm using a 4MHz oscillator. Not clear what clock rate the Timer is operating at (1 MHz?)

Also does the prescaler basically reduce this clocking frequency by the prescale value, for example if I use a prescale of 100, would the frequency into the time become the clockrate/32?

Thanks...Chris Shatara
[email protected]

locko
- 2nd July 2008, 10:25
Hi Chris,

You are right on with your thought process, all you have to do is put it together and try it out. The basic clock freq for the timer is 1uS for a 4MHz osc (fosc/4).
You will find plenty of code examples by searching the forum, use the better search under the FAQ thread. Also do a search for DTs (i think) inturrupt and PWM calculator, it will help you decide which values to use for everthing. There is also a good example of a clock that has code for tracking seconds minutes and hours somewhere on here.

Good luck.

Paul

mackrackit
- 2nd July 2008, 12:00
http://www.mister-e.org/pages/utilitiespag.html

misterE has the above. Most everything you need in one package!

eshatara
- 2nd July 2008, 14:46
Thanks for the prompt reply. I'll try it out later and get back if there are any questions.

/chris

locko
- 2nd July 2008, 15:44
http://www.mister-e.org/pages/utilitiespag.html

misterE has the above. Most everything you need in one package!

Humble appologies to Mister-e :), it was a long time ago I saw the util......

Paul

eshatara
- 3rd July 2008, 01:20
Downloaded the program and quite impressed with the tool. Takes all the drudgery out of coming up with the preload numbers.

Thanks to all of you for your help...Chris