Lab 1: Bitwise Helpers And RTC
Generated folder: labs/rtc/
This lab starts with masks, shifts, fixed-width integers, output pointers, and small helpers that can be tested before touching a device.
The device part reads the virtual CMOS/RTC through two ports:
| Port | Role |
|---|---|
RTC_ADDR_REG (0x70) | select the register |
RTC_DATA_REG (0x71) | read the selected value |
Device Model
Important registers:
| Register | Meaning |
|---|---|
RTC_REG_A | update-in-progress status bit |
RTC_REG_B | data-mode bit: BCD or binary |
RTC_DAY, RTC_MONTH, RTC_YEAR | date fields |
RTC_SECONDS, RTC_MINUTES, RTC_HOURS | time fields |
BCD stores decimal digits in nibbles. 0x42 means decimal 42, not binary 66.
Plan
- Implement pure bit helpers.
- Wait until the RTC update bit is clear.
- Read register B to detect BCD or binary mode.
- Read date and time registers.
- Convert only when the RTC reports BCD mode.
Next: implementation tasks.