PDA

View Full Version : Real Time Clock


- 17th March 2003, 08:53
I have created a simple clock program which uses the following settings:
External Osc = 4mhz xtal (1000000 operations per second)
Tmr0 = 250
Prescaler = 32
Counter (my variable) = 125

I use Disbale and resume as instructed in the help files

My counter is incremented each time the timer and prescaler trip over to 0. This mathematically gives exactly 1.0000 second per as a time base.
However, each time I run this code, it is out by as much as 1 second per minute.

Can any one suggest why I get a varience of such a magnitude. Perhaps show mw a reliable time kleepting function or code.

Thanks for any help rendered.

Original
- 17th March 2003, 18:05
Read this site for some explainations: http://www.romanblack.com/one_sec.htm

- 18th March 2003, 01:34
I have looked at the sie for Roman Black but no good.
I have checked his code and found that he uses a simple count to tack a little bit onto the end of a second every 4 clocks. This works with the asm code but does not translate into picbasic without the same amount of error.

Thanks anyway.
Maybe I just need to use assembler only and forget the picbasic stuff.

- 18th March 2003, 15:14
Hi Bob I will see you later with a working code.
From Aaron ;-)



I have created a simple clock program which uses the following settings:
External Osc = 4mhz xtal (1000000 operations per second)
Tmr0 = 250
Prescaler = 32
Counter (my variable) = 125

I use Disbale and resume as instructed in the help files

My counter is incremented each time the timer and prescaler trip over to 0. This mathematically gives exactly 1.0000 second per as a time base.
However, each time I run this code, it is out by as much as 1 second per minute.

Can any one suggest why I get a varience of such a magnitude. Perhaps show mw a reliable time kleepting function or code.

Thanks for any help rendered.