[att.sys.pc6300] accessing the clock/calendar chip on PC6300

bill@ssbn.UUCP (09/06/87)

In article <590@euraiv1.UUCP> aiv@euraiv1.UUCP (Eelco van Asperen) writes:
>
>Hi, I'm trying to access the real-time clock/calendar chip in the 
>Olivetti M24 I use (aka. ATT PC6300) and I'm kinda puzzled on the
>way years are handled. According to the Hardware Architecture Guide,
>the chip does _not_ know about years; this is consistent with the
>results of a program I wrote to read the chip's ports. So: *how* 
>does MS-DOS remember it's 1987 ?  Is there some undocumented port 
>they use ?

The following is from the PC 6300 PLUS System Programmer's Guide but I
am reasonably sure that the clock/calendar is the same, at least I have
a friend with a 6300 that uses this stuff and he says it works.  I am
*certain* that it works on a PLUS.

Ports 70-7f address the MM 58274 chip and all registers (except seconds)
can be written as well as read:

70  Control  0=normal, 1=test mode
71  Tenths of seconds
72  Seconds units
73  Seconds tens
74  Minutes units
75  Minutes tens
76  Hours units
77  Hours tens
78  Days units
79  Days tens
7a  Months units
7b  Months tens
7c  Years units
7d  Years tens
7e  Day of the week 0=Sunday, 6=Saturday
7f  Clock setting/Interrupt register

In the control register the bits are as follows:
b3 0=normal, 1=test mode
b2 0=clock run, 1 =clock stop
b1 Interrupt selection 0=clock setting register, 1=interrupt register
b0 Interrupt status 0=interrupt run, 1=interrupt stop

In the clock setting register the bits are
b3-b2 Leap year counter 0=leap year, anything else leap year + that
b1 AM/PM indicator 1=PM
b0 12/24 hour mode select 1=24hour mode

In the interrupt register the bits are
b3 Type of interrupt, 0=single interrupt, 1=repeated interrupt
b0-b2 Duration of the interrupt 0=no interrupt, 1=.1sec, 2=.5sec,
      3=1sec, 4=5sec, 5=10sec, 6=30sec, 7=60sec
Note that the clock setting register and interrupt register share the
same port address which is selected by b1 in the control register.

The following is typed in from the manual-
To write data to the clock and time registers the unit must be out of test
mode and stopped.  After writing to the clock, it must be restarted.  To
initialize interrupts, set Bit 4 in the Interrupt/Year mod 8 register.  Write
the register once and then read it three times.  If an update [digit is rolling]
the illegal code of F is returned.
This program sets the time to 12 noon:
test_port	equ 70   [they don't have an "h", it *should* be there]
stop_start	equ 7e
tens_hours	equ 77
write_time:	xor ax,ax
		mov dx,test_port
		out dx,al	;Out of test mode
		out start_stop,al ;stop the clock
		mov dx,tens_hours
		mov	al,1
		out dx,al
		dec dx
		mov al,2
		out dx,al
		dec dx
		xor al,al
		out dx,al
		dec dx
		out dx,al
		mov	al,0fh
		out start_stop,al ;Start the clock
		ret
That was rather a lengthy discussion but since your documentation is
sketchy I thought it was important to send you complete information.


-- 
Bill Kennedy  {cbosgd | ihnp4!petro | sun!texsun!rrm}!ssbn!bill