
SDA 20C440
Semiconductor Group
20
used, the P2PFR is to be set to 00H, which is default value after reset. Writing of other values than
00H or 03H to P2PFR is not alllowed.
2.5.4
Read-Modify-Write Feature
“Read-modify-write” commands are instructions that read a value, possibly change it, and then
rewrite it to the latch. When the destination operand is a port or a port bit, these instructions read the
latch rather than the pin. The read-modify-write instructions are listed below:
INC, DEC, JB, JBC, SET, CL, MV P.X., DJNZ, AND, OR, and XOR.
The read-modify-write instructions are directed to the latch rather than the pin in order to avoid a
possible misinterpretation of the voltage level at the pin. For example, a port bit might be used to
drive the base of a transistor. When a “one” is written to the bit, the transistor is turned on.
If the CPU then reads the same port bit at the pin rather than the latch, it will read the base voltage
of the transistor and interpret it as a 0. Reading the latch rather than the pin will return the correct
value of “one”.
2.6
Timer
A 16-bit timer with auto-reload is provided. The timer clock is derived from the external oscillator
clock rate (4 MHz) by a programmable prescaler in five steps (1 – 1/2 – 1/4 –1/8 – 1/16).
An interrupt request is generated by timer overflow which may be masked by use of the interrupt
enable registers IENA0 and IENA2 (see chapter ‘Interrupt System’). The timer is started/stopped by
setting/clearing bit RUN in register TCON. The prescale factor is selected by setting a three bit value
(bits PS0, PS1 and PS2) in register TCON. If a 16-bit timer value is to be written to the timer register
or to the timer reload register, the high byte (TH, TRH) is to be written first. After writing the low byte
(TL, TRL), the complete 16-bit word will be transferred from a 16-bit shadow register into the internal
pair of registers (timer registers TH/TL, reload registers TRH/TRL). If a 16-bit value is to be read
from the timer registers or timer reload registers, the low byte has to be read first to transfer the
16 bit value into a 16-bit shadow register. After this, the high byte can be read. Please note, that for
correct operation always two read or write access in the right order are necessary. After reset, the
values of the timer registers, the reload registers and the two pairs of shadow registers are
undefined and the timer is stopped.
PS0..2
prescaler
= 000: factor 1
= 001: factor 1/2
= 010: factor 1/4
= 011: factor 1/8
= 100: factor 1/16
MSB
SFR-Address: DCH
LSB
TCON: Timer Control Register
...
RUN
PS2
PS1
PS0