Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read CMOS into VxWorks clock?

146 views
Skip to first unread message

Marc Yaxley

unread,
Feb 19, 1999, 3:00:00 AM2/19/99
to
Has anyone out there read the PC's CMOS clock data into a program
then set VxWorks's system time/date with this data? I didn't see any
thing to do this built in to the PC486 BSP or otherwise?

Thanks for any ideas you may have that will help me,
Marc

Phil Ashby

unread,
Feb 19, 1999, 3:00:00 AM2/19/99
to
Marc Yaxley wrote:
>
> Has anyone out there read the PC's CMOS clock data into a program
> then set VxWorks's system time/date with this data? I didn't see any
> thing to do this built in to the PC486 BSP or otherwise?

It is certainly possible to read the CMOS clock. Use the I/O space
byte transfer routines (sysInByte/sysOutByte) to access the CMOS at
I/O address 0x70/0x71. You will need a PC hardware reference to get
all the info you need about the CMOS..

Does VxWorks have a system time/date? I can only find the POSIX
routines (clock_settime) which are optional.

I tried calling time() on my PC board which has been up for a few
hours. I got 0. I tried again. I got 3..... useful huh!
--
!--------------------------- Phil "Phlash" Ashby ---------------------!
! BT Wireplay - Lead Programmer and general technical trivia supplier !
! Phone: 01473-644348 WWW: http://www.wireplay.com/ !
! Snail: B81/G41, BT Labs, Martlesham Heath, Ipswich IP5 3RE, England.!

Steve Robertson

unread,
Feb 19, 1999, 3:00:00 AM2/19/99
to
Marc,

WRS sent me the file ds12887rtc.c which I used as the basis for reading the
real-time clock. Armed with this and a spec sheet for Dallas
Semiconductors' 12887 chip (downloaded from their web page), I was able to
read and write to the RTC. It seems like I made a few changes to their code
but I don't recall what they were right now.

Next you need to set the VxWorks clock so that all the "time" functions in
the ansiTime library will work correctly. With all disclaimer's that could
possibly apply, here is what I did:

void SysTimeInit( void )
{
struct tm tmTime;
struct timespec tsTime;

sysRtcGet( &tmTime ); /* get time from RTC */

tsTime.tv_sec = mktime( &tmTime ); /* convert to timespec */
tsTime.tv_nsec = 0;

clock_settime( CLOCK_REALTIME, &tsTime ); /* update VxWorks clock */
}

Note that "sysRtcGet" is a function in ds12887rtc.c.

Good Luck
Steve Robertson


Marc Yaxley wrote in message ...


>Has anyone out there read the PC's CMOS clock data into a program
>then set VxWorks's system time/date with this data? I didn't see any
>thing to do this built in to the PC486 BSP or otherwise?
>

Craig Gartside

unread,
Feb 19, 1999, 3:00:00 AM2/19/99
to

Make sure that you disable the interrupts when you read
the contents of 0x70/0x71 . If you don't you may find your CMOS
corrupted...

gart...@plc.com

Phil Ashby wrote in message <36CD9C...@wireplay.bt.co.uk>...


>Marc Yaxley wrote:
>>
>> Has anyone out there read the PC's CMOS clock data into a program
>> then set VxWorks's system time/date with this data? I didn't see any
>> thing to do this built in to the PC486 BSP or otherwise?
>

Alef0

unread,
Feb 21, 1999, 3:00:00 AM2/21/99
to
Marc Yaxley wrote:

> Has anyone out there read the PC's CMOS clock data into a program
> then set VxWorks's system time/date with this data? I didn't see any
> thing to do this built in to the PC486 BSP or otherwise?
>

> Thanks for any ideas you may have that will help me,
> Marc

There is a detailed solution, complete with source code, at
http://www.dejanews.com/getdoc.xp?AN=295349993

Worked for me ...
--

Alef0

---
Replace 127.0.0.1 with usa.net when replying by e-mail
C programmers never die, they are just cast into void.

Olivier STOLZENBERG

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to Marc Yaxley

Marc Yaxley a écrit:

> Has anyone out there read the PC's CMOS clock data into a program
> then set VxWorks's system time/date with this data? I didn't see any
> thing to do this built in to the PC486 BSP or otherwise?
>
> Thanks for any ideas you may have that will help me,
> Marc

Try this peace of code to access the PC RTC and do what you want with.....

I use it and it work fine.

Olivier STOLZENBERG PROSYS S.A.

unsigned char uch_Temp[7];

/* Sauvergarde de l'heure et de la date */
sysOutByte(0x70, 4); /* Hours */
uch_Temp[0] = sysInByte(0x71);
sysOutByte(0x70, 2); /* Minutes */
uch_Temp[1] = sysInByte(0x71);
sysOutByte(0x70, 0); /* Seconds */
uch_Temp[2] = sysInByte(0x71);
sysOutByte(0x70, 7); /* Month day */
uch_Temp[3] = sysInByte(0x71);
sysOutByte(0x70, 8); /* Month */
uch_Temp[4] = sysInByte(0x71);
sysOutByte(0x70, 9); /* Year */
uch_Temp[5] = sysInByte(0x71);
sysOutByte(0x70, 0x32); /* Century */
uch_Temp[6] = sysInByte(0x71);

0 new messages