-
Notifications
You must be signed in to change notification settings - Fork 0
RTC DS3231 Design
Przemyslaw Rachwlal edited this page May 4, 2026
·
1 revision
The RtcDevice emulates a DS3231 real-time clock connected via the system bus as a memory-mapped device.
- Base address: Configurable (default 0xFF20)
- Address range: 0xFF20–0xFF2F (16 registers)
-
Type:
IClockedDevice+IBusDevice
| Offset | Register | Access | Description |
|---|---|---|---|
| 0x00 | Seconds | R/W | 0–59 (BCD) |
| 0x01 | Minutes | R/W | 0–59 (BCD) |
| 0x02 | Hours | R/W | 0–23 (BCD, 24h mode) |
| 0x03 | Day | R/W | 1–7 |
| 0x04 | Date | R/W | 1–31 (BCD) |
| 0x05 | Month/Century | R/W | 1–12 + century bit (BCD) |
| 0x06 | Year | R/W | 0–99 (BCD) |
| 0x07–0x0E | Alarm/Control/Status | R/W | Per DS3231 spec |
| 0x0F | Temperature | R | Raw temperature (MSB+LSB) |
- Ticks advance in sync with the CPU cycle count
- Each second of real time = emulated cycles / clock speed
- Supports setting time via register writes
- BCD format throughout (matching real DS3231)
Located in CmosCpu.Devices/RtcDevice.cs:
- Implements
IBusDeviceandIClockedDevice - Internal state tracks seconds, minutes, hours, day, date, month, year
- Handles month lengths and leap year correctly
- Read-only temperature register returns simulated value (0x18 = 24°C)
The RTC is used in:
- Apple-1 machine configuration for time display
- Retro70 computer as a standard I/O device
- Any machine that includes it in its profile