again about cmos [2/2]

ZXNet echo conference «real.speccy»

From Aleksandr Majorov To All 7 June 1998


Hello, Andrey!

===========================================================================

REGISTER B (individual bits)
───────────────────────────

7 SET "1" - update prohibition
(to set the time).

6 PIE interrupt enable with period
specified in the RS bits of register A.
Resets by Reset.

5 AIE alarm clock interrupt resolution. Reset by Reset.

4 UIE interrupt permission at the end
of the update cycle. Reset
by Reset.

3 SQWE permission to issue information to the
SQW output. Reset by Reset.

2 DM data type: 0 - binary decimal
1 - binary

1 24/12 count: 0 - 12 hours each
1 - 24 hours each

0 DSE "1" allows automatic transition from summer to winter time and
back.
The transition to summer time is carried out at
3 o'clock in the morning the last Sunday in April, and in the winter at 1 o'clock in the morning on the last Sunday in October.


REGISTER C (individual bits)
All bits are reset by Reset or when register C is read.

7 IRQF flag interrupt request. -
is set to "1" under the condition :
(PF and PIE) or (AF and AIE) or
(UF and UIE).
IfIRQF="1", then the IRQ
pin (19) is set to "0".

6 PF is set to 1 by the edge of the signal
at the output of the internal frequency divider
, selected in accordance
with the RS-bits.

5 AF is set to 1 when the current time coincides
with the alarm clock time.

4 UF is set to 1 after the end
of the update cycle.

3 =0
...
0 =0

REGISTER D (individual bits)
────────────────────────────

7 is set to log. "0" if
the power is lost and the information
is unreliable.
Set to "1" by Reset
or when reading register D.

6 =0
...
0 =0


DATA FORMAT
───────────────

Sunday = 1, Monday. = 2, etc.

January = 1, February = 2, etc.

1997 = 97, 1998 = 98, etc.

The number of days in a month is taken into account and leap years are taken into account. If a number in the interval
#C0...#FF is written into registers
#00...#09, this is an indifferent state.
I.e. if the alarm clock = #FF, then it will go off every hour.


SEEKING A SOUND SIGNAL
WHEN THE ALARM GOES GOING
─────────────────────────────

It is necessary to set
AIE=SQWE=1 in register {B}UIE=PIE=0.
The audio frequency at the SQW output is set
by the RS bits of register {A}. When the
alarm clock is triggered, the IRQ output will be set to
log. "0". Those. to generate sound, you need
to OR the outputs SQW and IRQ
You can install an RC-chain, which after
some time after setting IRQ to
#0 will form a reset signal, and the sound will stop.


Switching circuits
─═══════════════─

If you have a SMUG controller, then
all you need to do is plug the CMOS clock chip into the appropriate socket.

Well, what if you "unlucky", then you'll have
to solder a little...

Generator
───────────

┌──────────── 2 (OSC1)
│
│ 22M
├─▒▒▒▒──┬──── 3 (OSC2)
│ │
│ ▒ 470k
│ ▒
│ ▒
│ │
│ │┌┐│ │ quartz resonator:
┌┴─┤││├──┤
10│ │└┘│ │20 32.768 kHz
┴ ┴ * 1.048576 MHz
┬ ┬ 4.194304 MHz
│ │
│ │
─┴─ ─┴─

Crystal selection and voltage control

5.1K
┌─▒▒▒▒▒──── 24 (+Up)
│
┌─ │
│ /│ 5.1K /─┴────────── 13(/CE)
│/ │ │/ k
──┤ ├──▒▒▒▒▒───┤ KT315
+5 │\ │ │\ e
│ \│ \
│
KS133 │
│
─┴─


5.1K
24 (+Up) ─────▒▒▒▒▒──────────── 22 (PS)

Chip power supply
────────────────────

│\ │
│ \│
+5B ───┤ /├────┬─────────── 24 (+Up)
│/ │ │
│
│
│\ │ │
│ \│ │
┌────│ /├────┘
│ │/ │
│
──┴─── +
─┬─ 3.6V battery
│
─┴─

Connecting to a computer
──────────────────────────

Must be connected signals AD0...AD7
to the processor data bus.
The /RES signal (18) is connected to /RESET
processor (26th pin)

The remaining pins - AS, R/W, /DS must be
connected to address decoders.

Signal state
──────────────────

AS R/W /DC
nothing 0 1 1
select register number 1 1 1
read from register 0 1 0
write to register 0 0 1


For example, on the yellow Scorpio board, pins AS, /DS, R/W signals can befeed
from m/s D54:

D54/13 through an inverter to AS
D54/11 to /DS
D54/15 to R/W

In this case, the addresses of the CMOS clock ports
will be located in the TR-DOS area.

With this connection scheme, only bits 1 and 7 are analyzed, but in order to avoid conflicts with other ports, the following port addresses are recommended

Select register #D8
Read from register #58
Write to register #58

When using Scorpio to write/read data, you can use p/n
TR-DOS:

#3FF0 - OUT (C),A
RET

#3FF3 - IN A,(C)
RET


On computers that do not have such commands in the TR-DOS ROM
the following program is recommended:

;writing data to the register
;in:
;[C] - CMOS clock register number
;[B] - written value
WRREG LD A,C
CALL SETREG
LD A,B
LD C,#58
JR OUTPAR


;reading data from the register
;in
;[C] - CMOS clock register number

;out:
;[A] - value read from the register
RDREG LD A,C
CALL SETREG
LD A,#D8
LD C,#1F
CALL OUTPAR
LD C,#58
LD IX,#3EF3
CALL JPTR
LD A,H
RET

SETREG LD C,#D8
OUTPAR LD IX,#2A53
JPTR PUSH IX
JP #3D2F


__________________________
────────────────────

Hу вот и все
*MAS* с кувалдой