Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RTC Details
- Does not respond to normal PIF Status commands.
- 01 03 06 RTC status
- 2 device type (LE) [1000]
- 1 status
- 80 busy
- 02 D Down (program time generation failure--cycle power)
- 01 B Down (backup time generation failure)
- 02 09 07 read RTC
- send:
- 1 address
- 0 flags
- 1 RAM
- 2 time
- receive:
- 8 data
- 1 status
- 0A 01 08 write RTC
- send:
- 1 address
- 8 data
- receive:
- 1 status
- Bank details:
- Control Flags (bank 0)
- 02 00 00 00 00 00 00 00 write-protect bank 2: Time
- 01 00 00 00 00 00 00 00 write-protect bank 1: RAM
- 00 80 00 00 00 00 00 00 Ealarm (enable alarm)
- 00 20 00 00 00 00 00 00 alarm (read-only)
- 00 04 00 00 00 00 00 00 modify
- 00 02 00 00 00 00 00 00 child (set to stop time when reading)
- 00 01 00 00 00 00 00 00 adjust (set when changing time to sync timers)
- 00 00 00 00 FF 00 00 00 alarm minute
- 00 00 00 00 00 FF 00 00 alarm hour
- FC 58 FF FF 00 00 FF FF RESERVED (read-only)
- RAM (bank 1)
- Eight free bytes. Set WPB1 in flags to modify.
- Time (bank 2)
- All time values are binary decimals; ie. 0x21 = 21, not 33.
- FF 00 00 00 00 00 00 00 seconds
- 00 FF 00 00 00 00 00 00 minutes
- 00 00 80 00 00 00 00 00 always set?; may not be the case with all models
- 00 00 7F 00 00 00 00 00 hours
- 00 00 00 FF 00 00 00 00 day
- 00 00 00 00 FF 00 00 00 day of week
- 00 00 00 00 00 FF 00 00 month
- 00 00 00 00 00 00 FF 00 year
- 00 00 00 00 00 00 00 FF year + (100 * v)
- Initializing:
- Send Status cmd. If ID not 0100 quit.
- If Status.busy set:
- read Flags to buffer
- if no error or Status.busy set:
- buffer &= ~(Flags.modify | Flags.child)
- Write buffer back to Flags.
- return (Status.DDown | Status.BDown) # Neither should be set, but only DDown is fatal.
- # In practical application the adjust, child, and modify flags do not need to be toggled for the operation to be successful.
- Set Time:
- Read Flags to buffer.
- If Status clear:
- buffer &= ~Flags.WPB2
- buffer |= Flags.adjust
- Write buffer to Flags.
- If Status.busy set:
- Fill buffer with current time.
- Write buffer to Time.
- If Status.busy set:
- Write back original Flags.
- Get Time:
- Read Flags to buffer.
- If Status clear:
- buffer |= Flags.child
- Write buffer to Flags.
- If Status.busy set:
- Read Time to buffer.
- If Status.busy set:
- buffer &= ~Flags.child
- Write buffer to Flags.
- Set Data:
- Send Status cmd.
- If Status clear:
- buffer &= ~Flags.WPB1
- Write buffer to Flags.
- If Status.busy set:
- Write data to RAM.
- If Status.busy set:
- buffer |= Flags.WPB1
- Write buffer to Flags.
- Get Data:
- Send Status cmd.
- If Status clear:
- Read data from RAM.
- # Note: the 0x80 flag on the hours set on at least some models of RTC prevent the alarm from triggering.
- # Alarm should "sound" at hr:mn, just like an alarm clock.
- Set Alarm:
- Read Flags to buffer.
- Set buffer.AlarmMinute and buffer.AlarmHour
- Write buffer to Flags.
- Get Alarm:
- Read Flags to buffer.
- if buffer & (Flags.Ealarm | Flags.Alarm) == (Flags.Ealarm | Flags.Alarm):
- minutes = buffer.AlarmMinute
- hours = buffer.AlarmHour
- return True
- return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement