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
/
MBUG
/
MBUG088.ARC
/
RTC.DOC
< prev
next >
Wrap
Text File
|
1979-12-31
|
14KB
|
311 lines
Notes on Microbee RTC ( brief)
Part 1 Construction
If you have a Premium mother board type 8501-3-03C (inscribed in copper) and
8501-3-04CR ( silk-screened ) or later than the following parts can be fitted
directly to the mother board.
IC18 146818
IC15 74HC00
D1 1N4148 or similar diode
D2 1N4148 or similar diode
G1 32.768 KHz crystal
R1 22 ohm resistor
R2 1M ohm resistor
R3 150K ohm resistor
R4 4.7M ohm resistor
R7 1.8K ohm resistor
R14 1K ohm resistor
CV2 approx 6-60 pf trimmer capacitor ( adjust so clock keeps accurate time )
C1 10 mfd tantalum 16 volt
C6 .0047 mfd greencap capacitor
C7 33 pf capacitor
C8 33 pf capacitor
C15 .1 mfd monolithic capacitor
BB 3.6 volt Nicad Varta type 3/60DK (add this last)
24 pin socket optional - use a good quality dual wipe type if used
14 pin socket " " " " " " " " " "
In addition three wire jumpers need to be added :-
1. W1 pads are near the colour connector. Add a jumper between W1-A2 and W1-B2.
Also check there is no connection between W1-A1 and W1-B1 or between W1-A3
and W1-B3 on either side on the board.
2. Connect a long insulated wire jumper between L1 and L1 pads. One is located
on the right side of the board to the right of IC71 a 74LS138 just above the
back-space key, the other is to the left of IC24 a 74LS32.
3. Connect a long insulated wire jumper between L2 and L2 pads. One is located
on the left side of the board just under the metal-work which supports the
keys almost directly underneath the top hole of the metal-work beside the
ESCAPE key. Again the other is near to IC24 a 74LS32, just to the right of
that IC.
N.B. Do not forget the little piece of wire around the crystal to hold it in
position.
┴ buffereΣ outpu⌠ oε piε 21 oµ thσ 14681╕ i≤ availablσ for the connection
of a frequency counter. The variable capacitor is adjusted for a frequency
of 32.768KHz.
--------========--------
èPart 2 Chip details
The 146818 RTC chip consists of 50 general purpose registers, ten registers
which normally contain the time, calendar, and alarm data, and four control and
status registers. The 50 registers can be used as general purpose memory. All
are battery backed up. All 64 bytes are directly readable and writable by
the processor program except registers C and D which are read only.
The addresses on the MicroBee are as follows :-
Address 04
Write 06
Read 07
For example to read RTC register 2 the sequence would be :-
Write 02 to port address 04
input data from port address 07
in basic this would be
10 OUT 4,2 : REM select register 2
20 A=IN(7) : REM the variable A will equal the contents of register 2
in assembler this would be
ld a,002h ; load a with the required RTC register address
out (004h),a ; output to RTC address register
in a,(007h) ; read data from the required RTC register
; to Z80 register a
Similarly to write to RTC register 9 the sequence would be :-
Write 09 to port address 04
write data to port address 06
in basic this would be
10 OUT 4,9 : REM select register 9
20 OUT 6,B : REM the variable B will be written to register 9
in assembler this would be
ld a,009h ; load a with the required RTC register address
out (004h),a ; output to RTC address register
ld a,data ; load Z80 register a with the required data
out (data),a ; write data to RTC register 9
RTC Time, Calendar and Alarm register Functions
-------------------------------------------------------------------------------
Address | Function |Decimal| Range of RAM in HEX |Example(Nums in Hex)
Location | | Range | Binary Mode | BCD Mode |Binary mode|Hex Mode
-------------------------------------------------------------------------------
0 | Seconds | 0-59 | X00-X3B | X00-X59 | 15 | 21è-------------------------------------------------------------------------------
1 | Seconds | 0-59 | X00-X3B | X00-X59 | 0F | 15
| Alarm | | | | |
-------------------------------------------------------------------------------
2 | Minutes | 0-59 | X00-X3B | X00-X59 | 3A | 58
-------------------------------------------------------------------------------
1 | Minutes | 0-59 | X00-X3B | X00-X59 | 1E | 30
| Alarm | | | | |
-------------------------------------------------------------------------------
| Hours | 1-12 | X01-X0C(AM) | X01-X12(AM) | 05 | 05
|(12 hr mode)| | X81-X8C(PM) | X81-X92(PM) | |
4 | | | | | |
| Hours | 0-23 | X00-X17 | X00-X23 | 05 | 05
|(24 hr mode)| | | | |
-------------------------------------------------------------------------------
| Hours Alarm| 1-12 | X01-X0C(AM) | X01-X12(AM) | 06 | 06
|(12 hr mode)| | X81-X8C(PM) | X81-X92(PM) | |
5 | | | | | |
| Hours Alarm| 0-23 | X00-X17 | X00-X23 | 06 | 06
|(24 hr mode)| | | | |
-------------------------------------------------------------------------------
6 | Day of Week| 1-7 | X01-X07 | X01-X07 | 01 | 01
| Sunday=1 | | | | |
-------------------------------------------------------------------------------
7 |Day of Month| 1-31 | X01-X1F | X01-X31 | 0B | 11
-------------------------------------------------------------------------------
8 | Month | 1-12 | X01-X0C | X01-X12 | 02 | 02
-------------------------------------------------------------------------------
9 | Year | 0-99 | X00-X63 | X00-X99 | 4F | 79
-------------------------------------------------------------------------------
Example is for 5:58:21 Sunday February 11th 1979
Alarm set for 6:30:15
--------========--------
REGISTER A Read/Write except bit UIP which is read only
-------------------------------------------------------------------------
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
-------------------------------------------------------------------------
| UIP | DV2 | DV1 | DV0 | RS3 | RS2 | RS1 | RS0 |
-------------------------------------------------------------------------
UIP - This Update In Progress (UIP) bit is a staus flag that may be monitored
by the program. When UIP is a "1" the update cycle is in progress or will soon
begin. When UIP is a "0" the update cycle is not in progress and will not be
for at least 244 microsecs.
DV2,DV1,DV0 - Crystal frequency selection use 0,1,0 for the MicroBee
i.e. DV2=0 DV1=1 DV0=0
RS3,RS2,RS1,RS0 - Square-wave or Periodic Interrupt frequency select. On the
MicroBee only the Periodic Interrupt can be used (via IRQ to PIO B bit 7)
Chose the frequency / rate from the following chart
è -----------------------------------------------------------
| RS3 | RS2 | RS1 | RS0 | Rate | Frequency |
-----------------------------------------------------------
| 0 | 0 | 0 | 0 | None | None |
-----------------------------------------------------------
| 0 | 0 | 0 | 1 | 3.90625 ms | 256 Hz |
-----------------------------------------------------------
| 0 | 0 | 1 | 0 | 7.81250 ms | 128 HZ |
-----------------------------------------------------------
| 0 | 0 | 1 | 1 | 122.070 us | 8.192 kHz |
-----------------------------------------------------------
| 0 | 1 | 0 | 0 | 244.141 us | 4.096 kHz |
-----------------------------------------------------------
| 0 | 1 | 0 | 1 | 488.281 us | 2.048 kHz |
-----------------------------------------------------------
| 0 | 1 | 1 | 0 | 976.562 us | 1.024 kHz |
-----------------------------------------------------------
| 0 | 1 | 1 | 1 | 1.953125 ms | 512 Hz |
-----------------------------------------------------------
| 1 | 0 | 0 | 0 | 3.90625 ms | 256 Hz |
-----------------------------------------------------------
| 1 | 0 | 0 | 1 | 7.81250 ms | 128 Hz |
-----------------------------------------------------------
| 1 | 0 | 1 | 0 | 15.625 ms | 64 Hz |
-----------------------------------------------------------
| 1 | 0 | 1 | 1 | 31.250 ms | 32 Hz |
-----------------------------------------------------------
| 1 | 1 | 0 | 0 | 62.50 ms | 16 Hz |
-----------------------------------------------------------
| 1 | 1 | 0 | 1 | 125 ms | 8 Hz |
-----------------------------------------------------------
| 1 | 1 | 1 | 0 | 250 ms | 4 Hz |
-----------------------------------------------------------
| 1 | 1 | 1 | 1 | 500 ms | 2 Hz |
-----------------------------------------------------------
--------========--------
REGISTER B Read/Write Register
-------------------------------------------------------------------------
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
-------------------------------------------------------------------------
| SET | PIE | AIE | UIE | SQWE | DM | 24/12 | DSE |
-------------------------------------------------------------------------
SET - When set to a "1" the update cycle functions normally updating the
counts once per second. When set to a "0" the update cycle is inhibited. Use
of this bit allows the clock to be set correctly.
PIE - When set to a "1" the periodic interrupt flag will cause the IRQ pin to
become active. This rate is set by the RS3,RS2,RS1,RS0 bits. When set to a
"0" the IRQ pin is not activated.
èAIE - When set to a "1" the Alarm flag will cause the IRQ pin to become active
when the alarm time matches the real time. When set to a "0" the IRQ pin is not
activated.
UIE - When set to a "1" the Update-Ended Interrupt flag will cause the IRQ bit
to become active. Since this happens once per second this is one way of getting
an interrupt once per second. When set to a "0" the IRQ pin is not activated.
SQWE - This function cannot be used on the MicroBee as the relevant pin on the
RTC chip is not connected. Leave as a "0".
DM - When set to a "1" the RTC chip uses binary data, when set to a "0" the RTC
chip uses BCD data. Use of BCD mode is generally easier.
24/12 - When set to a "1" the 24 hour mode is used. When set to a "0" the 12
hour mode is used.
DSE - (No it is NOT the Dick Smith Electronics bit!) It is the Daylight Savings
Enable bit. It was for the US, but recent changes to Daylight Saving dates in
the US mean this bit is now useless even there. Always set to a "0".
--------========--------
REGISTER C Read Only Register
-------------------------------------------------------------------------
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
-------------------------------------------------------------------------
| IRQF | PF | AF | UF | 0 | 0 | 0 | 0 |
-------------------------------------------------------------------------
IRQF - Set to a one when any of the other flags are active i.e. PF, AF, or UF
and indicates the IRQ pin is active. A read of this register will clear all
flags so they should be saved by the user program if more than one flag is
being used for later examination.
PF - Periodic Interrupt Flag
AF - Alarm Flag
UF - Update-ended flag
--------========--------
REGISTER D Read Only Register
-------------------------------------------------------------------------
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
-------------------------------------------------------------------------
| VRT | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
-------------------------------------------------------------------------è
VRT - When a "1" this indicates power sense pin is at a saisfactory level
and hence the registers should be valid. A "0" indicates an unsatisfactory
level and thus the register contents will be invalid.
--------========--------
Notes on setting the alarm
The alarm may be used in two ways :-
1. The 3 registers are set to the appropriate time and the alarm interrupt will
become active accordingly.
2. By setting any Hex code between XC0 and XFF in an alarm register, the alarm
compare will become active every time at that interval, i.e. setting the hour
alarm to XFF will mean the alarm interrupt becomes active each hour, setting
the hour and minute alarm registers to XFF will mean an alarm interrupt each
minute and setting all three alarm registers to XFF will mean an alarm
interrupt each second.
See the manufacturer's data books for more information.
--------========--------
Part 3 Software
1. See RTC.MWB for a demonstration in basic
2. SETCLOCK.MAC for am assembler program to set the clock
3. TIME.MAC for a simple program displaying the time
Thanks to Glenn Satchell for his code which saved me some time and effort.
The information here is correct to the best of my knowledge. Please leave a
message describing any omissions or needed corrections which will go into the
next version.
Tony Ellis VK2ZNH 02.05.86