Realtime clock issue [SOLVED]

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
User avatar
TyrelHaveman
Member
Member
Posts: 40
Joined: Thu Sep 20, 2007 11:20 pm
Location: Bellingham, WA
Contact:

Realtime clock issue [SOLVED]

Post by TyrelHaveman »

Hi guys,

I'm adding calendar-date/time tracking to my clock driver (rather than just counting ticks). I'm working on grabbing the current date and time from the RTC. It mostly works, except for one odd thing. Note (in case it's relevant) that I'm testing with Bochs 2.4.5.

The one thing that's not working is this: If I read "Status Register B" by doing an outb 11 (address for this register) on port 0x70 and an inb on port 0x71, bit 2 is not set, indicating that the numbers returned if I read the time will not be in BCD. However they are, in fact, in BCD. For example at 37 minutes past the hour, I got 0x37 (55) rather than 0x25 (37). Why is the status register lying to me?

The info I got on this status register comes from my copy of "The Indepensible PC Hardware Book", which is somewhat out of date, but I don't imagine this has changed. The only thing I found in the wiki was that it may be in BCD, but it doesn't say how to check whether it's in BCD or not. :-)

Any help would be appreciated!

Thanks,
Tyrel
Last edited by TyrelHaveman on Sat Jun 19, 2010 9:28 am, edited 1 time in total.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Realtime clock issue

Post by gerryg400 »

0 means BCD.
If a trainstation is where trains stop, what is a workstation ?
User avatar
TyrelHaveman
Member
Member
Posts: 40
Joined: Thu Sep 20, 2007 11:20 pm
Location: Bellingham, WA
Contact:

Re: Realtime clock issue

Post by TyrelHaveman »

gerryg400 wrote:0 means BCD.
So the book is wrong?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Realtime clock issue

Post by gerryg400 »

I don't have the book so I can't check, but maybe.

Edit: what I mean is that my source says 0 means bcd, so I think the book is wrong. We need others to comment.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Realtime clock issue

Post by Brendan »

Hi,
gerryg400 wrote:Edit: what I mean is that my source says 0 means bcd, so I think the book is wrong. We need others to comment.
My information says 0 = BCD, 1 = binary; and I know this is right because I've used it to read the RTC correctly (on a variety of computers) in the past.

The information I use is from a text file called "pctim003.txt". It's old, but very complete and covers just about everything you could want to know about timers and timing for older hardware; and is the best reference for RTC and PIT that I've ever seen. I did a quick search and found it online: here!. :)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Realtime clock issue

Post by bewing »

The wiki CMOS article says very clearly:

Status Register B, Bit 1 (value = 2): Enables 24 hour format if set
Status Register B, Bit 2 (value = 4): Enables Binary mode if set (which means BCD mode is 0)

-- so yes, your book is totally wrong.

And I hope that when you access Status register B, that that's a decimal 11 you are using for the IO port.
User avatar
TyrelHaveman
Member
Member
Posts: 40
Joined: Thu Sep 20, 2007 11:20 pm
Location: Bellingham, WA
Contact:

Re: Realtime clock issue

Post by TyrelHaveman »

Thanks to all of you! I've written the correction in my copy of that book in case I ever run across that again. :-)

Also, thanks, bewing, for pointing that out on the CMOS article. I see now that the "Time And Date" article I was reading does indeed point to the CMOS article, I just missed it somehow.
Post Reply