Advertisement
Zoinkity

RTCK-NUS Details

Aug 13th, 2020 (edited)
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. RTC Details
  2.  
  3. Does not respond to normal PIF Status commands.
  4. 01 03 06 RTC status
  5. 2 device type (LE) [1000]
  6. 1 status
  7. 80 busy
  8. 02 D Down (program time generation failure--cycle power)
  9. 01 B Down (backup time generation failure)
  10.  
  11. 02 09 07 read RTC
  12. send:
  13. 1 address
  14. 0 flags
  15. 1 RAM
  16. 2 time
  17. receive:
  18. 8 data
  19. 1 status
  20.  
  21. 0A 01 08 write RTC
  22. send:
  23. 1 address
  24. 8 data
  25. receive:
  26. 1 status
  27.  
  28. Bank details:
  29. Control Flags (bank 0)
  30. 02 00 00 00 00 00 00 00 write-protect bank 2: Time
  31. 01 00 00 00 00 00 00 00 write-protect bank 1: RAM
  32. 00 80 00 00 00 00 00 00 Ealarm (enable alarm)
  33. 00 20 00 00 00 00 00 00 alarm (read-only)
  34. 00 04 00 00 00 00 00 00 modify
  35. 00 02 00 00 00 00 00 00 child (set to stop time when reading)
  36. 00 01 00 00 00 00 00 00 adjust (set when changing time to sync timers)
  37. 00 00 00 00 FF 00 00 00 alarm minute
  38. 00 00 00 00 00 FF 00 00 alarm hour
  39. FC 58 FF FF 00 00 FF FF RESERVED (read-only)
  40. RAM (bank 1)
  41. Eight free bytes. Set WPB1 in flags to modify.
  42. Time (bank 2)
  43. All time values are binary decimals; ie. 0x21 = 21, not 33.
  44. FF 00 00 00 00 00 00 00 seconds
  45. 00 FF 00 00 00 00 00 00 minutes
  46. 00 00 80 00 00 00 00 00 always set?; may not be the case with all models
  47. 00 00 7F 00 00 00 00 00 hours
  48. 00 00 00 FF 00 00 00 00 day
  49. 00 00 00 00 FF 00 00 00 day of week
  50. 00 00 00 00 00 FF 00 00 month
  51. 00 00 00 00 00 00 FF 00 year
  52. 00 00 00 00 00 00 00 FF year + (100 * v)
  53.  
  54. Initializing:
  55. Send Status cmd. If ID not 0100 quit.
  56. If Status.busy set:
  57. read Flags to buffer
  58. if no error or Status.busy set:
  59. buffer &= ~(Flags.modify | Flags.child)
  60. Write buffer back to Flags.
  61. return (Status.DDown | Status.BDown) # Neither should be set, but only DDown is fatal.
  62.  
  63. # In practical application the adjust, child, and modify flags do not need to be toggled for the operation to be successful.
  64. Set Time:
  65. Read Flags to buffer.
  66. If Status clear:
  67. buffer &= ~Flags.WPB2
  68. buffer |= Flags.adjust
  69. Write buffer to Flags.
  70. If Status.busy set:
  71. Fill buffer with current time.
  72. Write buffer to Time.
  73. If Status.busy set:
  74. Write back original Flags.
  75.  
  76. Get Time:
  77. Read Flags to buffer.
  78. If Status clear:
  79. buffer |= Flags.child
  80. Write buffer to Flags.
  81. If Status.busy set:
  82. Read Time to buffer.
  83. If Status.busy set:
  84. buffer &= ~Flags.child
  85. Write buffer to Flags.
  86.  
  87. Set Data:
  88. Send Status cmd.
  89. If Status clear:
  90. buffer &= ~Flags.WPB1
  91. Write buffer to Flags.
  92. If Status.busy set:
  93. Write data to RAM.
  94. If Status.busy set:
  95. buffer |= Flags.WPB1
  96. Write buffer to Flags.
  97.  
  98. Get Data:
  99. Send Status cmd.
  100. If Status clear:
  101. Read data from RAM.
  102.  
  103. # Note: the 0x80 flag on the hours set on at least some models of RTC prevent the alarm from triggering.
  104. # Alarm should "sound" at hr:mn, just like an alarm clock.
  105. Set Alarm:
  106. Read Flags to buffer.
  107. Set buffer.AlarmMinute and buffer.AlarmHour
  108. Write buffer to Flags.
  109.  
  110. Get Alarm:
  111. Read Flags to buffer.
  112. if buffer & (Flags.Ealarm | Flags.Alarm) == (Flags.Ealarm | Flags.Alarm):
  113. minutes = buffer.AlarmMinute
  114. hours = buffer.AlarmHour
  115. return True
  116. return False
  117.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement