Skip to content

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:

PortRole
RTC_ADDR_REG (0x70)select the register
RTC_DATA_REG (0x71)read the selected value

Device Model

Important registers:

RegisterMeaning
RTC_REG_Aupdate-in-progress status bit
RTC_REG_Bdata-mode bit: BCD or binary
RTC_DAY, RTC_MONTH, RTC_YEARdate fields
RTC_SECONDS, RTC_MINUTES, RTC_HOURStime fields

BCD stores decimal digits in nibbles. 0x42 means decimal 42, not binary 66.

Plan

  1. Implement pure bit helpers.
  2. Wait until the RTC update bit is clear.
  3. Read register B to detect BCD or binary mode.
  4. Read date and time registers.
  5. Convert only when the RTC reports BCD mode.

Next: implementation tasks.

Course/docs licensed CC BY 4.0. Code licensed MIT.