home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / BEEHIVE / UTILITYS / BEERTC.ARC / RTC.DOC next >
Text File  |  1990-07-21  |  14KB  |  316 lines

  1.     Notes on Microbee RTC ( brief)
  2.  
  3. Part 1 Construction
  4.  
  5. If you have a Premium mother board type 8501-3-03C (inscribed in copper) and
  6. 8501-3-04CR ( silk-screened ) or later than the following parts can be fitted
  7. directly to the mother board.
  8.  
  9. IC18  146818
  10. IC15  74HC00
  11. D1    1N4148 or similar diode
  12. D2    1N4148 or similar diode
  13. G1    32.768 KHz crystal
  14. R1    22 ohm resistor
  15. R2    1M ohm resistor
  16. R3    150K ohm resistor
  17. R4    4.7M ohm resistor
  18. R7    1.8K ohm resistor
  19. R14   1K ohm resistor
  20. CV2   approx 6-60 pf trimmer capacitor ( adjust so clock keeps accurate time )
  21. C1    10 mfd tantalum 16 volt
  22. C6    .0047 mfd greencap capacitor
  23. C7    33 pf capacitor
  24. C8    33 pf capacitor
  25. C15   .1 mfd monolithic capacitor
  26. BB    3.6 volt Nicad Varta type 3/60DK (add this last)
  27. 24 pin socket   optional - use a good quality dual wipe type if used
  28. 14 pin socket     "         "  "  "     "      "    "    "   "   "
  29.  
  30.    In addition three wire jumpers need to be added :-
  31.  
  32. 1. W1 pads are near the colour connector. Add a jumper between W1-A2 and W1-B2.
  33.    Also check there is no connection between W1-A1 and W1-B1 or between W1-A3
  34.    and W1-B3 on either side on the board.
  35.  
  36. 2. Connect a long insulated wire jumper between L1 and L1 pads. One is located
  37.    on the right side of the board to the right of IC71 a 74LS138 just above the
  38.    back-space key, the other is to the left of IC24 a 74LS32.
  39.  
  40. 3. Connect a long insulated wire jumper between L2 and L2 pads. One is located
  41.    on the left side of the board just under the metal-work which supports the
  42.    keys almost directly underneath the top hole of the metal-work beside the
  43.    ESCAPE key. Again the other is near to IC24 a 74LS32, just to the right of
  44.    that IC.
  45.  
  46. N.B. Do not forget the little piece of wire around the crystal to hold it in
  47.    position.
  48.  
  49.    Those with earlier Premiums or other types of Bee can get a kit and 
  50. instructions from MicroBee Systems for about $80 including an additional PC
  51. board. These parts are also usable for those adding components directly to 
  52. the mother board.
  53.  
  54.                --------========--------
  55.  
  56. Part 2 Chip details
  57.  
  58.     The 146818 RTC chip consists of 50 general purpose registers, ten registers
  59. which normally contain the time, calendar, and alarm data, and four control and
  60. status registers. The 50 registers can be used as general purpose memory. All
  61. are battery backed up. All 64 bytes are directly readable and writable by
  62. the processor program except registers C and D which are read only.
  63.  
  64.     The addresses on the MicroBee are as follows :-
  65.  
  66.     Address        04
  67.     Write        06
  68.     Read        07
  69.  
  70.     For example to read RTC register 2 the sequence would be :-
  71.  
  72.  Write 02 to port     address 04
  73.  input data from port address 07
  74.  
  75.  
  76.  in basic this would be
  77. 10 OUT 4,2 : REM select register 2
  78. 20 A=IN(7) : REM the variable A will equal the contents of register 2 
  79.  
  80.  
  81.  in assembler this would be
  82.     ld    a,002h        ; load a with the required RTC register address
  83.     out    (004h),a    ; output to RTC address register
  84.     in    a,(007h)    ; read data from the required RTC register
  85.                 ; to Z80 register a
  86.   
  87.  
  88. Similarly to write to RTC register 9 the sequence would be :-
  89.  
  90.  Write 09 to port     address 04
  91.  write data to port   address 06
  92.  
  93.  in basic this would be
  94. 10 OUT 4,9 : REM select register 9
  95. 20 OUT 6,B : REM the variable B will be written to register 9
  96.  
  97.  in assembler this would be
  98.     ld    a,009h        ; load a with the required RTC register address
  99.     out    (004h),a    ; output to RTC address register
  100.     ld    a,data        ; load Z80 register a with the required data
  101.     out    (data),a    ; write data to RTC register 9
  102.  
  103.  
  104.     RTC Time, Calendar and Alarm register Functions
  105.  
  106. -------------------------------------------------------------------------------
  107. Address  | Function   |Decimal| Range of RAM in HEX       |Example(Nums in Hex)
  108. Location |            | Range | Binary Mode | BCD Mode    |Binary mode|Hex Mode
  109. -------------------------------------------------------------------------------
  110.    0     | Seconds    | 0-59  |   X00-X3B   | X00-X59     |    15    |   21
  111. -------------------------------------------------------------------------------
  112.    1     | Seconds    | 0-59  |   X00-X3B   | X00-X59     |    0F    |   15
  113.          | Alarm      |       |             |             |          |
  114. -------------------------------------------------------------------------------
  115.    2     | Minutes    | 0-59  |   X00-X3B   | X00-X59     |    3A    |   58
  116. -------------------------------------------------------------------------------
  117.    1     | Minutes    | 0-59  |   X00-X3B   | X00-X59     |    1E    |   30
  118.          | Alarm      |       |             |             |          |
  119. -------------------------------------------------------------------------------
  120.          | Hours      | 1-12  | X01-X0C(AM) | X01-X12(AM) |    05    |   05
  121.          |(12 hr mode)|       | X81-X8C(PM) | X81-X92(PM) |          |
  122.    4     |            |       |             |             |          |
  123.          | Hours      | 0-23  |   X00-X17   |   X00-X23   |    05    |   05
  124.          |(24 hr mode)|       |             |             |          |
  125. -------------------------------------------------------------------------------
  126.          | Hours Alarm| 1-12  | X01-X0C(AM) | X01-X12(AM) |    06    |   06
  127.          |(12 hr mode)|       | X81-X8C(PM) | X81-X92(PM) |          |
  128.    5     |            |       |             |             |          |
  129.          | Hours Alarm| 0-23  |   X00-X17   |   X00-X23   |    06    |   06
  130.          |(24 hr mode)|       |             |             |          |
  131. -------------------------------------------------------------------------------
  132.    6     | Day of Week| 1-7   |  X01-X07    |  X01-X07    |    01    |   01
  133.          | Sunday=1   |       |             |             |          |
  134. -------------------------------------------------------------------------------
  135.    7     |Day of Month| 1-31  |  X01-X1F    |  X01-X31    |    0B    |   11
  136. -------------------------------------------------------------------------------
  137.    8     | Month      | 1-12  |  X01-X0C    |  X01-X12    |    02    |   02
  138. -------------------------------------------------------------------------------
  139.    9     | Year       | 0-99  |  X00-X63    |  X00-X99    |    4F    |   79
  140. -------------------------------------------------------------------------------
  141. Example is for 5:58:21 Sunday February 11th 1979
  142. Alarm set for 6:30:15
  143.  
  144.                --------========--------
  145.  
  146. REGISTER A     Read/Write except bit UIP which is read only
  147.  
  148.   -------------------------------------------------------------------------
  149.   |   b7   |   b6   |   b5   |   b4   |   b3   |   b2   |   b1   |   b0   |
  150.   -------------------------------------------------------------------------
  151.   |  UIP   |  DV2   |  DV1   |  DV0   |  RS3   |  RS2   |  RS1   |  RS0   |
  152.   -------------------------------------------------------------------------
  153.  
  154. UIP - This Update In Progress (UIP) bit is a staus flag that may be monitored
  155. by the program. When UIP is a "1" the update cycle is in progress or will soon
  156. begin. When UIP is a "0" the update cycle is not in progress and will not be
  157. for at least 244 microsecs.
  158.  
  159. DV2,DV1,DV0 - Crystal frequency selection use 0,1,0 for the MicroBee
  160. i.e. DV2=0 DV1=1 DV0=0
  161.  
  162. RS3,RS2,RS1,RS0 - Square-wave or Periodic Interrupt frequency select. On the
  163. MicroBee only the Periodic Interrupt can be used (via IRQ to PIO B bit 7)
  164. Chose the frequency / rate from the following chart
  165.  
  166.   -----------------------------------------------------------
  167.   | RS3 | RS2 | RS1 | RS0 |    Rate       |    Frequency    |
  168.   -----------------------------------------------------------
  169.   |  0  |  0  |  0  |  0  |   None        |   None          |
  170.   -----------------------------------------------------------
  171.   |  0  |  0  |  0  |  1  |   3.90625 ms  |     256 Hz      |
  172.   -----------------------------------------------------------
  173.   |  0  |  0  |  1  |  0  |   7.81250 ms  |     128 HZ      |
  174.   -----------------------------------------------------------
  175.   |  0  |  0  |  1  |  1  |   122.070 us  |   8.192 kHz     |
  176.   -----------------------------------------------------------
  177.   |  0  |  1  |  0  |  0  |   244.141 us  |   4.096 kHz     |
  178.   -----------------------------------------------------------
  179.   |  0  |  1  |  0  |  1  |   488.281 us  |   2.048 kHz     |
  180.   -----------------------------------------------------------
  181.   |  0  |  1  |  1  |  0  |   976.562 us  |   1.024 kHz     |
  182.   -----------------------------------------------------------
  183.   |  0  |  1  |  1  |  1  |  1.953125 ms  |     512 Hz      |
  184.   -----------------------------------------------------------
  185.   |  1  |  0  |  0  |  0  |   3.90625 ms  |     256 Hz      |
  186.   -----------------------------------------------------------
  187.   |  1  |  0  |  0  |  1  |   7.81250 ms  |     128 Hz      |
  188.   -----------------------------------------------------------
  189.   |  1  |  0  |  1  |  0  |    15.625 ms  |      64 Hz      |
  190.   -----------------------------------------------------------
  191.   |  1  |  0  |  1  |  1  |    31.250 ms  |      32 Hz      |
  192.   -----------------------------------------------------------
  193.   |  1  |  1  |  0  |  0  |    62.50  ms  |      16 Hz      |
  194.   -----------------------------------------------------------
  195.   |  1  |  1  |  0  |  1  |      125  ms  |       8 Hz      |
  196.   -----------------------------------------------------------
  197.   |  1  |  1  |  1  |  0  |      250  ms  |       4 Hz      |
  198.   -----------------------------------------------------------
  199.   |  1  |  1  |  1  |  1  |      500  ms  |       2 Hz      |
  200.   -----------------------------------------------------------
  201.  
  202.                --------========--------
  203.  
  204.  
  205. REGISTER B     Read/Write Register
  206.  
  207.   -------------------------------------------------------------------------
  208.   |   b7   |   b6   |   b5   |   b4   |   b3   |   b2   |   b1   |   b0   |
  209.   -------------------------------------------------------------------------
  210.   |  SET   |  PIE   |  AIE   |  UIE   |  SQWE  |  DM    |  24/12 |  DSE   |
  211.   -------------------------------------------------------------------------
  212.  
  213. SET - When set to a "1" the update cycle functions normally updating the
  214. counts once per second. When set to a "0" the update cycle is inhibited. Use
  215. of this bit allows the clock to be set correctly.
  216.  
  217. PIE - When set to a "1" the periodic interrupt flag will cause the IRQ pin to
  218. become active. This rate is set by the RS3,RS2,RS1,RS0 bits. When set to a
  219. "0" the IRQ pin is not activated.
  220.  
  221. AIE - When set to a "1" the Alarm flag will cause the IRQ pin to become active
  222. when the alarm time matches the real time. When set to a "0" the IRQ pin is not
  223. activated.
  224.  
  225. UIE - When set to a "1" the Update-Ended Interrupt flag will cause the IRQ bit
  226. to become active. Since this happens once per second this is one way of getting
  227. an interrupt once per second. When set to a "0" the IRQ pin is not activated.
  228.  
  229. SQWE - This function cannot be used on the MicroBee as the relevant pin on the
  230. RTC chip is not connected. Leave as a "0".
  231.  
  232. DM - When set to a "1" the RTC chip uses binary data, when set to a "0" the RTC
  233. chip uses BCD data. Use of BCD mode is generally easier.
  234.  
  235. 24/12 - When set to a "1" the 24 hour mode is used. When set to a "0" the 12
  236. hour mode is used.
  237.  
  238. DSE - (No it is NOT the Dick Smith Electronics bit!) It is the Daylight Savings
  239. Enable bit. It was for the US, but recent changes to Daylight Saving dates in
  240. the US mean this bit is now useless even there. Always set to a "0".
  241.  
  242.  
  243.                --------========--------
  244.  
  245. REGISTER C     Read Only Register
  246.  
  247.   -------------------------------------------------------------------------
  248.   |   b7   |   b6   |   b5   |   b4   |   b3   |   b2   |   b1   |   b0   |
  249.   -------------------------------------------------------------------------
  250.   |  IRQF  |  PF    |  AF    |  UF    |   0    |   0    |   0    |   0    |
  251.   -------------------------------------------------------------------------
  252.  
  253. IRQF - Set to a one when any of the other flags are active i.e. PF, AF, or UF
  254. and indicates the IRQ pin is active. A read of this register will clear all
  255. flags so they should be saved by the user program if more than one flag is 
  256. being used for later examination.
  257.  
  258. PF - Periodic Interrupt Flag
  259.  
  260. AF - Alarm Flag
  261.  
  262. UF - Update-ended flag
  263.  
  264.  
  265.                --------========--------
  266.  
  267.  
  268. REGISTER D     Read Only Register
  269.  
  270.  
  271.   -------------------------------------------------------------------------
  272.   |   b7   |   b6   |   b5   |   b4   |   b3   |   b2   |   b1   |   b0   |
  273.   -------------------------------------------------------------------------
  274.   |  VRT   |   0    |   0    |   0    |   0    |   0    |   0    |   0    |
  275.   -------------------------------------------------------------------------
  276.  
  277. VRT - When a "1" this indicates power sense pin is at a saisfactory level
  278. and hence the registers should be valid. A "0" indicates an unsatisfactory
  279. level and thus the register contents will be invalid.
  280.  
  281.  
  282.                --------========--------
  283.  
  284. Notes on setting the alarm
  285.  
  286. The alarm may be used in two ways :-
  287.  
  288. 1. The 3 registers are set to the appropriate time and the alarm interrupt will
  289. become active accordingly.
  290.  
  291. 2. By setting any Hex code between XC0 and XFF in an alarm register, the alarm
  292. compare will become active every time at that interval, i.e. setting the hour
  293. alarm to XFF will mean the alarm interrupt becomes active each hour, setting 
  294. the hour and minute alarm registers to XFF will mean an alarm interrupt each
  295. minute and setting all three alarm registers to XFF will mean an alarm 
  296. interrupt each second.
  297.  
  298. See the manufacturer's data books for more information.
  299.  
  300.                --------========--------
  301.  
  302. Part 3 Software
  303.  
  304. 1. See RTC.MWB for a demonstration in basic
  305. 2. SETCLOCK.MAC for am assembler program to set the clock
  306. 3. TIME.MAC for a simple program displaying the time
  307.  
  308.    Thanks to Glenn Satchell for his code which saved me some time and effort.
  309.  
  310.    The information here is correct to the best of my knowledge. Please leave a
  311. message describing any omissions or needed corrections which will go into the 
  312. next version.
  313.  
  314.                                               Tony Ellis VK2ZNH 02.05.86
  315.  
  316.