Real time clocks Commodore's favourite real time clock chip was the OKI6242, which has 16 four bit registers, holding digits of the data and time. The first A2000s mapped this at $D80000, while A500s and A2000Bs base it at $DC0000. The $ prefix indicates a base 16 ('hexadecimal' address). The table shows where the digits are stored in memory, as BCD (Binary Coded Decimal) values between 0 and 9. Only odd addresses are used. Day 0 is Sunday, and year numbers less than 78 are assumed to be in the new millennium. Consider this advance warning of the 2078 bug! Table - OKI6242 time registers $DC0001 Seconds $DC0003 Tens of seconds $DC0005 Minutes $DC0007 Tens of minutes $DC0009 Hours $DC000B Tens of hours $DC000D Day of month $DC000F Tens of days $DC0011 Month number $DC0003 Tens of months $DC0015 Year (units) $DC0017 Tens of years $DC0019 Weekday, 0..6 You can read the clock directly, assuming its there, without AmigaOS. Set bit 0 of register 14 to 'hold' the setting momentarily, to prevent errors. Reading 1:59:59 could otherwise give 2:59:59 if the clock ticks just after you read the minutes and before you read the hour. The 'hold' bit buffers one pending tick so you keep time as long as you clear it before a whole second has elapsed. The other bits in this register and all those in the next one are not needed on Amigas. Bits in the last register can reset or stop the clock and select 12 hour mode; bit 3 engages a 'test' setting. BASIC example The program is provided in three forms: (1) The original source, written in HiSoft Power Basic (ClockPeek.bas). Edit and recompile this to make a version of the demo suitable for 16 bit Amigas. (2) ClockPeek.pbc, the same program compiled with Power BASIC - this requires the corresponding HiSoftBASIC.library (which is not PD) to run. (3) ClockPeek, the same program compiled into a standalone task with Hisoft BASIC 2. This should run on any computer but assumes the typical address of A1200 clock expansion. The BASIC loop continuously reads and displays the clock registers. It does not set the hold bit, as that might confuse system calls. If your program needs to poll continuously calls to DOS Delay, as in DMAmon stop it hogging processor time: see Aminet util/wb DMAmon.lha, from the same series as this document. The example here assumes the A1200's base address and 32 bit bus. The clock chip uses only four data bits, so its registers appear at alternate odd bytes on a 16 bit Amiga, or every fourth byte, at offset 1, 5, 9 and so on, on A1200s. The AND operator sifts out the four least significant bits of each word. If a count does use the whole range, like a day number from 0 to 6, unused bits are generally zero, except bit 2 of the 'tens of hours' register, which distinguishes AM and PM in 12 hour mode. Permanent bits The A3000 and A4000 have a different type of clock chip, with a small amount of 'non volatile' memory as well as the battery-backed clock. This memory stores Unix and SCSI configuration on an A3000 or A4000T, but there are spare bits, especially on the IDE-only A4000. Commodore never documented the access mechanism, but provided BattMem and BattClock libraries to read and write this hardware. You will find tools elsewhere on Aminet (e.g. SetBatt, SCSIprefs) which call those libraries. Document History Based on Amiga Format copy written in December 1999 and published in February 2000, updated with text from the original article and extra explanations in March 2001. Copyright 1999-2001 Simon N Goodwin, but freely distributable with attribution and all the files, unmodified.