CMOS clock running too fast

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
adeelmahmood1

CMOS clock running too fast

Post by adeelmahmood1 »

hi
while i was using CMOS to get the current time i m having a strange problem.
at the booting time i initilize the CMOS and then get the current time which is exactly right time. but after that first time when i try to use that same function to show current time it shows that the clock is running too fast
e.g for the first time (mean booting time) it showed
Current Time: 9:40:00
then when i try to call this function again after say 4 seconds it will show
Current Time: 9:41:30
now as u see actually it was just 4 seconds and the clock has gone by a minute. and it continues to run this fast
so i need to ask u that why is this happening .. why is it going so fast .. now if i have to use the timer interrupt for keeping record of time ca some one tell me how fast does that go .. i mean how many times it get fired in one second
thans for ur help
Chris Giese

Re:CMOS clock running too fast

Post by Chris Giese »

Your timer advanced 90 seconds in 4 seconds of "real" time.

90 / 4 = 22.5

>i mean how many times it get fired in one second

Unless you reprogram the 8253 timer chip, you get interrupts at the rate of 18.2 Hz -- which is pretty close to 22.5 -- hmmmm...
Tim

Re:CMOS clock running too fast

Post by Tim »

Are you testing on Bochs or on a real machine? Bochs is notorious for having its clock running too fast.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:CMOS clock running too fast

Post by Pype.Clicker »

if on real hardware, you probably set the PIT frequency to a higher value (18.2*22.5 Hz =~ 400 Hz) and forgot to reset it to a proper frequency (18.2Hz) when you return to DOS ...
As dos calls the INT 18h (iirc) to update the CMOS periodically from IRQ0, a higher timer frequency means a drifting cmos clock ...
adeelmahmood1

Re:CMOS clock running too fast

Post by adeelmahmood1 »

oh yeah :D
it was just because of bochs .. on the real computer it works just fine
thanx for ur help
srg

Re:CMOS clock running too fast

Post by srg »

Tim Robinson wrote: Are you testing on Bochs or on a real machine? Bochs is notorious for having its clock running too fast.
hehe Too fast, that's an understatement! I have in front of me a custom timer ISR that counts to 18 (it doesn't bother with the .2) and changed a char in vid mem.
On a real PC it changes once a second. In bochs it's a blurr!

BTW on a Win98 boot floppy in Bochs, the 30 secs you get flash in about 5!

Why don't they sort this bug out? surely it's going to really break someones code (like in this example).

srg
Post Reply