Device: Clock

The clock device provides access to the time and date, and to four countdown timers.

PortNameDescriptionReadWrite
0x30YearCurrent year.
0x31MonthCurrent month.
0x32DayCurrent day.
0x33HourCurrent hour.
0x34MinuteCurrent minute.
0x35SecondCurrent second.
0x36UptimeUptime counter.
0x37continuedcontinued
0x38Timer 1Countdown timer 1.
0x39continuedcontinued
0x3ATimer 2Countdown timer 2.
0x3Bcontinuedcontinued
0x3CTimer 3Countdown timer 3.
0x3Dcontinuedcontinued
0x3ETimer 4Countdown timer 4.
0x3Fcontinuedcontinued

Ports

Year

Reading from this port will return the number of full years elapsed since midnight of January 1st 2000. A value of zero represents the year 2000, and the maximum value 0xff represents the year 2255. The value returned past the year 2255 is implementation defined.

Writing to this port will set the year stored in the system clock to the year represented by the value written, if supported by the host system.

Month

Reading from this port will return the number of full months elapsed since midnight of January 1st. A value of zero represents the month of January, and the maximum value 0x0b represents the month of December.

Writing to this port will set the month stored in the system clock to the month represented by the value written, if supported by the host system.

Day

Reading from this port will return the number of full days elapsed since midnight of the first day of the month. A value of zero represents the first day of the month, and the maximum value 0x1e represents the thirty-first day of the month.

Writing to this port will set the day stored in the system clock to the day represented by the value written, if supported by the host system.

Hour

Reading from this port will return the number of full hours elapsed since midnight. A value of zero represents 12 o’clock midnight, and the maximum value 0x17 represents 11 o’clock at night.

Writing to this port will set the hour stored in the system clock to the hour represented by the value written, if supported by the host system.

Minute

Reading from this port will return the number of full minutes elapsed since the start of the hour. A value of zero represents the zeroth minute, and the maximum value 0x3b represents the fifty-nineth minute.

Writing to this port will set the minute stored in the system clock to the minute represented by the value written, if supported by the host system.

Second

Reading from this port will return the number of full seconds elapsed since the start of the minute. A value of zero represents the zeroth second, and the maximum value 0x3b represents the fifty-nineth second. The behaviour around leap seconds is implementation defined.

Writing to this port will set the second stored in the system clock to the second represented by the value written, if supported by the host system.

Uptime

Reading from this port will perform a cached read, returning the number of full 1/256 second durations elapsed since the beginning of program evaluation. The value will wrap to zero on overflow.

Timer

Reading from a timer port group will perform a cached read, returning the duration remaining until the associated timer expires. The initial value of each timer is zero.

Writing to a timer port group will perform a cached write, setting the duration of the timer to the value written.

Each timer port group is associated with one of four countdown timers. The duration of each timer is given as a number of full 1/256 second durations, with the maximum value 0xffff representing a duration of approximately four minutes and sixteen seconds. Each timer counts continuously down to zero, expiring when the remaining duration transitions from one to zero.

System wake

This device will send a wake request to the system device when a countdown timer expires.