• 32 K × 8 ROM respectively FEEPROM (Flash-EEPROM),
expandable externally to 64 Kbytes
• ROM/FEEPROM Code protection
• 1024 × 8 RAM, expandable externally to 64 Kbytes
• Two standard 16-bit timer/counters
• An additional 16-bit timer/counter coupled to four capture
registers and three compare registers
• A 10-bit ADC with eight multiplexed analog inputs and
programmable autoscan
• Two 8-bit resolution, pulse width modulation outputs
• Five 8-bit I/O ports plus one 8-bit input port shared with analog
inputs
2
• I
C-bus serial I/O port with byte oriented master and slave
functions
• Full-duplex UART compatible with the standard 80C51
• On-chip watchdog timer
• 15 interrupt sources with 2 priority levels (2 to 6 external sources
possible)
• Extended temperature range (–40 to +85°C)
• 4.5 to 5.5 V supply voltage range
• Frequency range for 80C51-family standard oscillator:
3.5 MHz to 16 MHz
• PLL oscillator with 32 kHz reference and software-selectable
system clock frequency
• Seconds Timer
• Software enable/disable of ALE output pulse
• Electromagnetic compatibility improvements
• Wake-up from Power-down by external or seconds interrupt
2. GENERAL DESCRIPTION
The P80C557E4/P83C557E4/P89C557E4 (hereafter generically
referred to as P8xC557E4) single-chip 8-bit microcontroller is
manufactured in an advanced CMOS process and is a derivative of
the 80C51 microcontroller family. The P8xC557E4 has the same
instruction set as the 80C51. Three versions of the derivative exist:
• P83C557E4 — 32 Kbytes mask programmable ROM
• P80C557E4 — ROMless version of the P83C557E4
• P89C557E4 — 32 Kbytes FEEPROM (Flash-EEPROM)
The P8xC557E4 contains a non-volatile 32 Kbytes mask
programmable ROM (P83C557E4) or electrically erasable
FEEPROM respectively (P89C557E4), a volatile 1024 × 8 read/write
data memory , five 8-bit I/O ports, one 8-bit input port, two 16-bit
timer/event counters (identical to the timers of the 80C51), an
additional 16-bit timer coupled to capture and compare latches, a
15-source, two-priority-level, nested interrupt structure, an 8-input
ADC, a dual DAC pulse width modulated interface, two serial
interfaces (UART and I2C-bus), a “watchdog” timer, an on-chip
oscillator and timing circuits. For systems that require extra
capability the P8xC557E4 can be expanded using standard TTL
compatible memories and logic.
In addition, the P8xC557E4 has two software selectable modes of
power reduction — Idle Mode and power-down mode. The Idle
Mode freezes the CPU while allowing the RAM, timers, serial ports,
and interrupt system to continue functioning. The power-down mode
saves the RAM contents but freezes the oscillator, causing all other
chip functions to be inoperative.
The device also functions as an arithmetic processor having
facilities for both binary and BCD arithmetic as well as bit-handling
capabilities. The instruction set consists of over 100 instructions: 49
one-byte, 45 two-byte, and 17 three- byte. With a 16 MHz system
clock, 58% of the instructions are executed in 0.75 µs and 40% in
1.5 µs. Multiply and divide instructions require 3 µs.
ADEXS15Start ADC operation: Input starting analog to digital conversion triggered by a programmable edge (ADC
PWM016Pulse width modulation output 0
PWM117Pulse width modulation output 1
EW18Enable watchdog timer: Enable for T3 watchdog timer and disable Power-down Mode.This pin must not
P4.0 – P4.719 – 22
RSTIN 30Reset: Input to reset the P8xC557E4.
RSTOUT 23Reset: Output of the P8xC557E4 for resetting peripheral devices during initialization and Watchdog Timer
P1.0 – P1.731 – 38Port 1
1
2
3
4
77
76
Low end of analog to digital conversion reference resistor
High end of analog to digital conversion reference resistor.
Analog ground for ADC
Analog power supply (+5 V) for ADC
Analog ground; for PLL oscillator
Analog power supply; (+5 V) for PLL oscillator
Port 5
8-bit input port
Port pinAlternative function
P5.0–P5.7Eight input channels to ADC (ADC0–ADC7)
14, 28,
53, 66
13, 29,
Digital power supply: +5 V power supply pins during normal operation and power reduction modes. All pins
must be connected.
Digital ground: circuit ground potential. All pins must be connected.
54, 67
operation can also be started by software). This pin must not float
float.
Port 4
8-bit quasi-bidirectional I/O port
24 – 27
Port pinAlternative function
P4.0CMSR0 }
P4.1CMSR1 }
P4.2CMSR2 } compare and set/reset
P4.3CMSR3 } outputs on a match with timer T2
P4.4CMSR4 }
P4.5CMSR5 }
P4.6CMT0 } compare and toggle outputs
P4.7CMT1 }on a match with timer T2
P3.0 – P3.7 41 – 488-bit quasi-bidirectional I/O port
N.C.49 – 50Not connected pins.
XTAL2 51Crystal pin 2: output of the inverting amplifier that forms the oscillator. Left open-circuit when an external
XTAL1 52Crystal pin 1: input to the inverting amplifier that forms the oscillator, and input to the internal clock
P2.0 – P2.7 55 – 62Port2: 8-bit quasi-bidirectional I/O port with internal pull-ups.During access to external memories
PSEN 63Program Store Enable output: read strobe to the external program memory via Port 0 and 2. Is activated
ALE/WE
EA 65External Access Input: If, during RESET, EA is held at a TTL level HIGH the CPU executes out of the
P0.7–P0.0 68 –75Port 0: 8-bit open drain bidirectional I/O port. It is also the multiplexed low-order address and data bus during
XTAL3 78Crystal pin, output of the inverting amplifier that forms the 32 kHz oscillator
XTAL4 79Crystal pin, input to the inverting amplifier that forms the 32 kHz oscillator. XT AL3 and XTAL4 are pulled
SELXTAL1 80Must be connected to logic HIGH level to select the HF oscillator, using the XT AL1/XTAL2 crystal. If pulled low
64Address Latch Enable output: latches the low byte of the address during access of external memory in
Port pinAlternative function
P3.0RXD:Serial input port
P3.1TXD:Serial output port
P3.2INT0
P3.3INT1
P3.4T0:Timer 0 external input
P3.5T1:Timer 1 external input
P3.6WR
P3.7RD
oscillator clock is used.
generator. Receives the external oscillator clock signal when an external oscillator is used. Must be
connected to logic HIGH if the PLL oscillator is selected (SELXTAL1 = LOW).
(RAM/ROM) that use 16-bit addresses (MOVX@DPTR) Port 2 emits the high order address byte. The
alternative function of P2.7 for the P89C557E4 is the output enable signal for verify/read modes (active low).
Port 2 can sink/source one TTL (=4 LSTTL) input. It can drive CMOS inputs without external pull-ups.
twice each machine cycle during fetches from external program memory. When executing out of external
program memory two activations of PSEN
is not activated (remains HIGH) during no fetches from external program memory. PSEN can sink/source 8
LSTTL inputs. It can drive CMOS inputs without external pull-ups.
normal operation. It is activated every six oscillator periods except during an external data memory access.
ALE/WE
alternative function for the P89C557E4 is the programming pulse input WE
To prohibit the toggling of ALE pin (RFI noise reduction) the bit RFI in the PCON Register (PCON.5) must be
set by software. This bit is cleared on RESET and can be set and cleared by software. When set, ALE pin
will be pulled down internally, switching an external address latch to a quiet state. The MOVX instruction will
still toggle ALE if external memory is accessed.
ALE will retain its normal high value during Idle Mode and a low value during Power-down Mode while in the
“RFI” mode. Additionally during internal access (EA
the internal program memory size. During external access (EA
the flag “RFI” is set or not.
internal program memory, provided the program counter is less than 32768. If, during RESET, EA
TTL level LOW the CPU executes out of external program memory via Port 0 and Port 2. EA
to float. EA
accesses to external memory (during theses accesses internal pull-ups are activated). Port 0 can sink/source
8 LSTTL inputs.
LOW if the PLL oscillator is not selected (SELXTAL1 = HIGH) or if Reset is active.
the PLL is selected for clocking of the controller, using the XTAL3/ XTAL4 crystal.
can sink/-source 8 LSTTL inputs. It can drive CMOS inputs without an external pull-up. The
is latched during RESET and don’t care after RESET.
:External interrupt
:External interrupt
:External data memory write strobe
:External data memory read strobe
are skipped during each access to external data memory. PSEN
.
= 1) ALE will toggle normally when the address exceeds
= 0) ALE will always toggle normally, whether
is held at a
is not allowed
NOTE:
1. To avoid a ‘latch-up’ effect at Power-on, the voltage at any pin at any time must not be higher or lower than V
respectively.
Primary attention was paid on the reduction of electromagnetic
emission of the microcontroller P8xC557E4.
The following features effect in reducing the electromagnetic
emission and additionally improve the electromagnetic susceptibility:
• Four supply voltage pins (V
pairs of V
package.
• Separated V
and VSS at two adjacent pins at each side of the
DD
pins for the internal logic and the port buffers
DD
) and four ground pins (VSS) with
DD
• Internal decoupling capacitance improves the EMC radiation
behavior and the EMC immunity
• External capacitors are to be located as close as possible
between pins V
well as V
recommended (100nF).
DD4
DD1
and V
and V
SS4
V
DD2
and V
SS1,
; ceramic chip capacitors are
Useful in applications that require no external memory or temporarily
no external memory:
• The ALE output signal (pulses at a frequency of f
disabled under software control (bit 5 in the SFR PCON: “RFI”); if
disabled, no ALE pulse will occur. ALE pin will be pulled down
internally , switching an external address latch to a quiet state.
The MOVX instruction will still toggle ALE (external data memory
is accessed). ALE will retain its normal HIGH value during Idle
Mode and a LOW value during Power-down mode while in the
“RFI” reduction mode. Additionally during internal access
(EA
= 1) ALE will toggle normally when the address exceeds the
internal program memory size. During external access (EA
ALE will always toggle normally, whether the flag “RFI” is set or
not.
SS2,
V
DD3
CLK
and V
SS3
/6) can be
= 0)
as
6. FUNCTIONAL DESCRIPTION
6.1 General
The P8xC557E4 is a stand-alone high-performance microcontroller
designed for use in real time applications such as instrumentation,
industrial control, medium to high-end consumer applications and
specific automotive control applications.
In addition to the 80C51 standard functions, the device provides a
number of dedicated hardware functions for these applications.
The P8xC557E4 is a control-oriented CPU with on-chip program
and data memory. It can be extended with external program memory
up to 64 Kbytes. It can also access up to 64 Kbytes of external data
memory. For systems requiring extra capability, the P8xC557E4 can
be expanded using standard memories and peripherals.
The P8xC557E4 has two software selectable modes of reduced
activity for further power reduction – Idle and Power-down. The Idle
Mode freezes the CPU while allowing the RAM, timers, serial ports
and interrupt system to continue functioning. The Power-down Mode
saves the RAM contents but freezes the oscillator causing all other
chip functions to be inoperative. The Power-down Mode can be
terminated by an external Reset, by the seconds interrupt and by
any one of the two external interrupts. (See description Wake-up
from Power-down Mode.)
6.2 Memory organization
The central processing unit (CPU) manipulates operands in three
memory spaces; these are the 64 Kbytes external data memory,
1024 bytes internal data memory (consisting of 256 bytes standard
RAM and 768 bytes AUX-RAM) and the 32 Kbytes internal and/or
64 Kbytes external program memory (see Figure 4).
The program memory of the P8xC557E4 consists of 32 Kbytes
ROM respectively FEEPROM (”Flash Memory”) on-chip, externally
expandable up to 64 Kbytes. If, during RESET, the EA
HIGH, the P8xC557E4 executes out of the internal program memory
unless the address exceeds 7FFFH. Locations 8000H through
0FFFFH are then fetched from the external program memory. If the
EA
pin was held LOW during RESET the P8xC557E4 fetches all
instructions from the external program memory. The EA
latched during RESET and is don’t care after RESET.
The internal program memory content is protected, by setting a
mask programmable security bit (ROM) or by the software
programmable security byte (FEEPROM) respectively, i.e. it cannot
be read out at any time by any test mode or by any instruction in the
external program memory space. The MOVC instructions are the
only ones which have access to program code in the internal or
external program memory. The EA
and is ’don’t care’ after RESET. This implementation prevents from
reading internal program code by switching from external program
memory to internal program memory during MOVC instruction or an
instruction that handles immediate data. Table 1 lists the access to
the internal and external program memory with MOVC instructions
when the security feature has been activated.
6.2.2 Internal Data Memory
The internal data memory is divided into three physically separated
parts:
256 bytes of RAM, 768 bytes of AUX-RAM, and a 128 bytes special
function area. These can be addressed each in a different way (see
also Table 2).
– RAM 0 to 127 can be addressed directly and indirectly as in the
80C51. Address pointers are R0 and R1 of the selected
registerbank.
input is latched during RESET
pin was held
input is
– RAM 128 to 255 can only be addressed indirectly.
Address pointers are R0 and R1 of the selected registerbank.
– AUX-RAM 0 to 767 is also indirectly addressable as external
DATA MEMORY locations 0 to 767 via MOVX-Datapointer
instruction, unless it is disabled by setting ARD = 1.
AUX-RAM 0 to 767 is indirectly addressable via pageregister
(XRAMP) and MOVX-Ri instructions, unless it is disabled by
setting ARD = 1 (see Figure 5).
When executing from internal program memory, an access to
AUX-RAM 0 to 767 will not affect the ports P0, P2, P3.6 and P3.7.
An access to external DATA MEMORY locations higher than 767
will be performed with the MOVX @ DPTR instructions in the
same way as in the 80C51 structure, so with P0 and P2 as
data/address bus and P3.6 and P3.7 as write and read timing
signals. Note that the external DATA MEMORY cannot be
accessed with R0 and R1 as address pointer if the AUX-RAM is
enabled (ARD = 0, default).
– The Special Function Registers (SFR) can only be addressed
directly in the address range from 128 to 255 (see Table 5).
– Four register banks, each 8 registers wide, occupy locations 0
through 31 in the lower RAM area. Only one of these banks may
be enabled at a time. The next 16 bytes, locations 32 through 47,
contain 128 directly addressable bit locations.The stack can be
located anywhere in the internal 256 bytes RAM.The stack depth
is only limited by the available internal RAM space of 256 bytes
(see Figure 7).
All registers except the program counter and the four register
banks reside in the Special Function Register address space.
Table 1.Memory Access by the MOVC Instruction for Protected ROMs
MOVC LOCATION
MOVC in internal program memoryYESYES
MOVC in external program memoryNOYES
NOTE:
1.
If the security feature has not been activated, there are no restrictions for MOVC instructions.
ACCESS TO INTERNAL
PROGRAM MEMORY
ACCESS TO EXTERNAL
PROGRAM MEMORY
Table 2.Internal Data Memory Map
LOCATIONADDRESSED
RAM 0 to 127Direct and indirect
AUX-RAM 0 to 767Indirect only with MOVX
RAM128 to 255Indirect only
SFR128 to 255Direct only
Figure 5. Indirect addressing of AUX-RAM (768 Bytes), ARD bit in PCON = 0
6.2.2.1 AUX-RAM Page Register XRAMP
The AUX-RAM Page Register is used to select one of three 256
bytes pages of the internal 768 bytes AUX-RAM for
MOVX-accesses via R0 or R1. Its reset value is (XXXXXX00).
7654 3 210
XRAMP (FAH)
xxxx x xXRAMP1XRAMP0
255
(XRAMP) = 01 H
0
255
(XRAMP) = 00 H
0
767
512
511
MOVX @DPTR,A
MOVX A,@DPTR
256
255
0
x: undefined during read, a write operation must write “0” to these locations
Figure 6. AUX-RAM page register.
Table 3.Description of XRAMP Bits
BITSYMBOLFUNCTION
XRAMP.2–7XRAMPxreserved for future use
XRAMP.1XRAMP1AUX-RAM page select bit 1
XRAMP.0XRAMP0AUX-RAM page select bit 0
Table 4.Memory Locations for All Possible MOVX Accesses
Table 5.Special Function Register Memory Map and Reset Values
HIGH NIBBLE OF SFR ADDRESS
LOW89ABCDEF
0P0 %
11111111
1SP 00000111
2DPL
00000000
3 DPH
00000000
4
5
6ADRSL0 #
XXXXXXXX
7PCON
00000000
8TCON %
00000000
9 TMOD
00000000
ATL0
00000000
BTL1
00000000
CTH0
00000000
DTH1
00000000
E CTL2 #
F CTL3 #
NOTES:
%=Bit addressable register
#=Read only register
X=Undefined
* = FMCON only in P89C557E4
P1 %
11111111
ADRSL1 #
XXXXXXXX
S0CON %
00000000
S0BUF
XXXXXXXX
P2 %
11111111
ADRSL2 #
XXXXXXXX
IEN0 %
00000000
CML0
00000000
CML1
00000000
CML2
00000000
CTL0 #
XXXXXXXX
CTL1 #
XXXXXXXX
XXXXXXXX
XXXXXXXX
P3 %
11111111
ADRSL3 #
XXXXXXXX
IP0 %
X0000000
P4 %
11111111
ADRSL4 #
XXXXXXXX
P5 #
XXXXXXXX
TM2IR %
00000000
CMH0
00000000
CMH1
00000000
CMH2
00000000
CTH0 #
XXXXXXXX
CTH1 #
XXXXXXXX
CTH2 #
XXXXXXXX
CTH3 #
XXXXXXXX
PSW %
00000000
ADRSL5 #
XXXXXXXX
ADCON
00000000
S1CON %
00000000
S1STA #
11111000
S1DAT
00000000
S1ADR
00000000
ACC %
00000000
ADRSL6 #
XXXXXXXX
ADPSS
00000000
IEN1 %
00000000
TM2CON
00000000
CTCON
00000000
TML2 #
00000000
TMH2 #
00000000
STE
11000000
RTE
00000000
B %
00000000
ADRSL7 #
XXXXXXXX
ADRSH #
000000XX
IP1 %
00000000
PLLCON
00001 101
XRAMP
XXXXXX00
FMCON *
000X0000
PWM0
00000000
PWM1
00000000
PWMP
00000000
T3
00000000
6.3 Addressing
The P8xC557E4 has five methods for addressing:
•Register
•Direct
•Register-Indirect
•Immediate
•Base-Register plus Index-Register-Indirect
The first three methods can be used for addressing destination
operands. Most instructions have a “destination/source” field that
specifies the data type, addressing methods and operands involved.
For operations other than MOVs, the destination operand is also a
source operand.
1999 Mar 02
Access to memory addresses is as follows:
•Register in one of the four register banks through Register, Direct
or Register-Indirect addressing
•1024 bytes of internal RAM through Direct or Register-Indirect
addressing.
– Bytes 0–127 of internal RAM may be addressed
directly/indirectly . Bytes 128–255 of internal RAM share their
address location with the SFRs and so may only be addressed
indirectly as data RAM.
– Bytes 0–767 of AUX-RAM can only be addressed indirectly via
MOVX.
•Special Function Register through direct addressing at address
locations 128–255 (see Figure 8).
•External data memory through Register-Indirect addressing
•Program memory look-up tables through Base-Register plus
The P8xC557E4 has six 8-bit ports. Ports 0 to 3 are the same as in
the 80C51, with the exception of the additional functions of Port 1.
The parallel I/O function of Port 4 is equal to that of Ports 1, 2 and 3.
Port 5 has a parallel input port function, but has no function as an
output port.
The SDA and SCL lines serve the serial port SIO1 (I
2
the I
C-bus may be active while the device is disconnected from
V
these pins, are provided with open drain drivers.
DD,
Ports 0, 1, 2, 3, 4 and 5 perform the following alternative functions:
Port 0 :provides the multiplexed low-order address and data
bus used for expanding the P8xC557E4 with standard
memories and peripherals.
Port 1 : Port 1 is used for a number of special functions:
4 capture inputs (or external interrupt request inputs if
capture information is not utilized)
Port 2 : provides the high-order address bus when the
P8xC557E4 is expanded with external Program
Memory and/or external Data Memory.
Port 3 :pins can be configured individually to provide:
– external interrupt request inputs
– counter inputs
– receiver input and transmitter output of seri port
SIO 0 (UART)
– control signals to read and write external Data
Memory
2
C). Because
Port 4 :can be configured to provide signals indicating a match
between timer counter T2 and its compare registers.
Port 5 : may be used in conjunction with the ADC interface.
Unused analog inputs can be used as digital inputs. As
Port 5 lines may be used as inputs to the ADC, these
digital inputs have an inherent hysteresis to prevent the
input logic from drawing too much current from the
power lines when driven by analog signals. Channel to
channel crosstalk should be taken into consideration
when both digital and analog signals are simultaneously
input to Port 5 (see DC characteristics).
All ports are bidirectional with the exception of Port 5 which is an
input port.
Pins of which the alternative function is not used may be used as
normal bidirectional I/Os.
The generation or use of a Port 1, Port 3 or Port 4 pin as an
alternative function is carried out automatically by the P8xC557E4
provided the associated Special Function Register bit is set HIGH.
The pull-up arrangements of Ports 1 – 4 are shown in Figure 9.
QN
From Port
Latch
2 System Clock Periods
V
V
DD
P1P2P3
DD
V
DD
n
Input Data
Read Port Pin
P1 is turned on for 2 system clock periods after QN makes a 1-to-0 transition.
During this time, P1 also turns on P3 through the inverter to form an additional pull up.
Figure 9. I/O buffers in the P8xC557E4 (Ports 1, 2, 3 and 4)
The P8xC557E4 contains two pulse width modulated output
channels (see Figure 13). These channels generate pulses of
programmable length and interval. The repetition frequency is
defined by an 8-bit prescaler PWMP, which supplies the clock for the
counter. The prescaler and counter are common to both PWM
channels. The 8-bit counter counts module 255, i.e., from 0 to 254
inclusive. The value of the 8-bit counter is compared to the contents
of two registers: PWM0 and PWM1. Provided the contents of either
of these registers is greater than the counter value, the
corresponding PWM0
these registers are equal to, or less than the counter value, the
output will be HIGH. The pulse-width-ratio is therefore defined by the
contents of the registers PWM0 and PWM1. The pulse-width-ratio is
in the range of 0/255 to 255/255 and may be programmed in
increments of 1/255.
Buffered PWM outputs may be used to drive DC motors. The
rotation speed of the motor would be proportional to the contents of
PWMn. The PWM outputs may also be configured as a dual DAC. In
this application, the PWM outputs must be integrated using
Figure 10. Prescaler frequency control register PWMP.
conventional operational amplifier circuitry. If the resulting output
voltages have to be accurate, external buffers with their own analog
supply should be used to buffer the PWM outputs before they are
integrated. The repetition frequency fpwm, at the PWMn outputs is
give by:
f
fpwm
This gives a repetition frequency range of 123 Hz to 31.4 kHz (f
= 16 MHz). By loading the PWM registers with either 00H or FFH,
the PWM channels will output a constant HIGH or LOW level,
respectively. Since the 8-bit counter counts modulo 255, it can never
actually reach the value of the PWM registers when they are loaded
with FFH.
When a compare register (PWM0 or PWM1) is loaded with a new
value, the associated output is updated immediately. It does not
have to wait until the end of the current counter period. Both PWMn
output pins are driven by push-pull drivers. These pins are not used
for any other purpose.
2 (1 PWMP) 255
CLK
CLK
Table 6.Description of PWMP Bits
BITFUNCTION
PWMP.0 to 7Prescaler division factor = (PWMP) + 1
NOTE:
1. Reading PWMP gives the current reload value. The actual count of the prescaler cannot be read.
The P8xC557E4 A/D Converter is a 10-bit, successive
approximation ADC with 8 multiplexed analog input channels. It
additionally contains a high input impedance comparator, a DAC
built with 1024 series resistors and analog switches, registers and
control logic.
Input voltage range is from AV
A set of 8 buffer registers (10-bit) store the conversion results of the
proper analog input channel each.
11 Special Function Registers (SFR) perform the user software
interface to the ADC: a control SFR (ADCON), an analog port
scan-select SFR (ADPSS), 8 input channel related conversion result
SFR with the 8 lower result bits (ADRSL0...ADRSL7), one common
result SFR for the upper 2 result bits (ADRSH). An extra SFR (P5)
allows for reading digital input port data as an alternative function of
the 8 analog input pins.
In order to have a minimum of ADC service overhead in the
microcontroller program, the ADC is able to operate autonomously
within its user configurable autoscan function.
The functional diagram of the ADC is shown in Figure 15.
Feature Overview:
(typical 0V) to AV
ref–
(typical +5V).
ref+
•10-bit resolution.
•8 multiplexed analog inputs.
•Programmable autoscan of the analog inputs.
•Bit oriented 8-bit scan-select register to select analog inputs.
•Continuous scan or one time scan configurable from 1 to 8 analog
inputs.
•Start of a conversion by software or with an external signal.
•Eight 10-bit buffer registers, one register for each analog input
channel.
•Interrupt request after one channel scan loop.
•Programmable prescaler (dividing by 2, 4, 6, 8) to adapt to
different system clock frequencies.
•Conversion time for one A/D conversion: 15 µs ... 50 µs
•Differential non-linearity: DLe ±1 LSB.
•Integral non-linearity: ILe ±2 LSB.
•Offset error: OSe ±2LSB.
•Gain error: Ge ±0.4 %.
•Absolute voltage error: Ae ±3 LSB.
•Channel to channel matching:Mctc ±1LSB.
•Crosstalk between analog inputs : Ct < –60dB. @100 kHz.
•Monotonic and no missing codes.
•Separated analog (AV
voltages.
•Reference voltage at two special pins : AV
For further information on the ADC characteristics, refer to the
“DC CHARACTERISTICS” section.
, AVSS) and digital (VDD, VSS) supply
DD
and AV
REF–
REF+
.
6.1.1 Functional description:
Table 9.A/D Special Function Registers
SYMBOLNAMEACCESS
ADCONA/D control registerread/write
ADPSSAnalog port scan-select registerread/write
ADRSLn8 A/D result registers, the 8 lower bits (n: 0...7)read only
ADRSHA/D result register, the 2 higher bitsread only
P5Digital input port (shared with analog inputs)read only
A/D Control Register ADCON
The Special Function Register ADCON contains control and status
bits for the A/D Converter peripheral block. The reset value of
ADCON is (00000000). Its hardware address is D7H. ADCON is not
bit addressable.
ADCON.7ADPR1Control bit for the prescaler.
ADCON.6ADPR0Control bit for the prescaler.
ADCON.5ADPOSADPOS is reserved for future use. Must be ’0’ if ADCON is written.
ADCON.4ADINTADC interrupt flag. This flag is set when all selected analog inputs are converted, as well in continuous
ADCON.3ADSSTADC start and status. Setting this bit by software or by hardware (via ADEXS input) starts the A/D
ADCON.2ADCSA1= Continuous scan of the selected analog inputs after a start of an A/D conversion.
ADCON.1ADSRE1= A rising edge at input ADEXS will start the A/D conversion and generate a capture signal.
ADCON.0ADSFE1 = A falling edge at input ADEXS will start the A/D conversion and generate a capture signal.
ADPR1=0 ADPR0=0 Prescaler divides by 2 (default by reset)
ADPR1=0 ADPR0=1 Prescaler divides by 4
ADPR1=1 ADPR0=0 Prescaler divides by 6
ADPR1=1 ADPR0=1 Prescaler divides by 8
scan as in one-time scan mode. An interrupt is invoked if this interrupt is enabled. ADINT must be cleared
by software. It cannot be set by software.
conversion of the selected analog inputs. ADSST stays a ‘one’ in continuous scan mode. In one-time scan
mode, ADSST is cleared by hardware when the last selected analog input channel has been converted. As
long as ADSST is ’1’, new start commands to the ADC-block are ignored.
An A/D conversion in progress is aborted if ADSST is cleared by software.
0 = One-time scan of the selected analog inputs after a start of an A/D conversion.
The Special Function Register ADPSS contains control bits to select
the analog input channel(s) to be scanned for A/D conversion. The
reset value of ADPSS is (00000000). Its hardware address is E7H.
ADPSS is not bit addressable.
If all bits are ‘0’ then no A/D conversion can be started. If ADPSS is
written while an A/D conversion is in progress (ADSST in the
ADCON register is ‘1’) then the autoscan loop with the previous
selected analog inputs is completed first. The next autoscan loop is
performed with the new selected analog inputs.
ADPSS7–0 For each individual bit position:0 = The corresponding analog input is skipped in the auto-scan loop.
Figure 16. A/D input port scan-select register.
1 = The corresponding analog input is included in the auto-scan loop.
A/D Result Registers ADRSLn and ADRSH:
The binary result code of A/D conversions is accessed by these
Special Function Registers. The result SFR are read only registers.
The read value after reset is indeterminate. Their data are not
affected by chip reset. They are not bit addressable.
There are 8 Special Function Registers ADRSLn
(ADRSL0...ADRSL7) – A/D Result Low byte – and one general SFR
ADRSH – A/D Result High byte – . Each of ADRSLn is associated
with the coincidently indexed analog input channel ADCn
(ADC0/P5.0...ADC7/P5.7). Reading an ADRSLn register by
software copies at the same time the two highest bits of the 10-bit
conversion result into two latches, thus preserving them until the
next read of any ADRSLn register. These two latches form bit
positions 0 and 1 of SFR ADRSH, the upper 6 bits of ADRSH are
always read as ’0’.
Thus it is ensured to get the 10-bit result of the same single A/D
conversion by reading any register ADRSLn first and after it the
register ADRSH.
Port 5 Special Function Register P5 always represents the binary
value of the logic level at input pins P5.0/ADC0...P5.7/ADC7. P5 is
not affected by chip reset. P5 is a read only register . Its hardware
address is C7H. P5 is not bit addressable.
Reading Special Function Register P5 does not affect A/D
conversions. But it is recommended to use the digital input port
function of the hardware Port 5 only as an alternative to analog input
voltage conversions. Simultaneous mixed operation is discouraged
for the sake of A/D conversion result reliability and accuracy.
For further information on Port 5, refer to the “I/O facilities” section.
For further information on A/D Special Function Registers, refer to
the “Internal Data Memory” section.
76543210
P5 (C7H)P5.7P5.6P5.5P5.4P5.3P5.2P5.1P5.0
Figure 18. Digital input port register P5.
Reset
After a RESET of the microcontroller the ADCON and ADPSS
register bits are initialized to zero. Registers ADRSLn and ADRSH
are not initialized by a RESET.
Idle and Power-down Mode
The A/D Converter is active only when the microcontroller is in
normal operating mode. If the Idle or Power-down Mode is activated,
then the ADC is switched off and put into a power saving idle state –
a conversion in progress is aborted, a previously set ADSST flag is
cleared and the internal clock is halted. The conversion result
registers are not affected.
The interrupt flag ADINT will not be set by activation of Idle or
Power-down Mode. A previously set flag ADINT will not be cleared
by the hardware. (Note: ADINT cannot be cleared by hardware at
all, except for a RESET – it must be cleared by the user software.)
After a wakeup from Idle or Power-down Mode a set flag ADINT
indicates that at least one autoscan loop was finished completely
before the microcontroller was put into the respective power
reduction mode and it indicates that the stored result data may be
fetched now – if desired.
For further information on Idle and Power-down Mode, refer to the
“Power reduction modes” section.
Timing
A programmable prescaler is controlled by the bits ADPR1 and
ADPR0 in register ADCON to adapt the conversion time for different
microcontroller clock frequencies.
Table 11 shows conversion times (tconv) for one A/D conversion at
some convenient system clock frequencies (fclk) and ADC prescaler
divisors (m), which are user selectable by the bits ADCON.7/ADPR1
and ADCON.6/ADPR0.
For conversion times outside the limits for tconv the specified ADC
characteristics are not guaranteed; (prohibited conversion times are
put in brackets):
Table 11. Conversion time configuration
examples (tconv/µs)
f
CLK
m6 MHz8 MHz12 MHz16 MHz
2
4
6
8
Conversion time tconv = (6 m + 1) machine cycles
A conversion time tconv consists of one sample time period (which
equals two bit conversion times), 10 bit conversion time periods and
one machine cycle to store the result.
After result storage an extra initializing time period follows to select
the next analog input channel (according to the contents of SFR
ADPSS), before the input signal is sampled.
Thus the time period between two adjacent conversions within an
autoscan loop is larger than the pure time tconv. This autoscan cycle
time is ( 7 m ) machine cycles.
At the start of an autoscan conversion the time between writing to
SFR ADCON and the first analog input signal sampling depends on
the current prescaler value (m) and the relative time offset between
this write operation and the internal (divided) ADC clock. This gives
a variation range for the A/D conversion start time of ( m / 2 )
machine cycles.
Every A/D conversion is an autoscan conversion. The two user
selectable general operation modes are continuous scan and
one-time scan mode.
The desired analog input port channel/s for conversion is/are
selected by programming A/D input port scan-select bits in SFR
ADPSS. An analog input channel is included in the autoscan loop if
the corresponding bit in ADPSS is 1, a channel is skipped if the
corresponding bit in ADPSS is 0.
An autoscan is always started according to the lowest bit position of
ADPSS that contains a 1.
An autoscan conversion is started by setting the flag ADSST in
register ADCON either by software or by an external start signal at
input pin ADEXS, if enabled. Either no edge (external start totally
disabled), a rising edge or/and a falling edge of ADEXS is selectable
for external conversion start by the bits ADSRE and ADSFE in
register ADCON.
After completion of an A/D conversion the 10-bit result is stored in
the corresponding 10-bit buffer register . Then the next analog input
is selected according to the next higher set bit position in ADPSS,
converted and stored, and so on. When the result of the last
conversion of this autoscan loop is stored, flag ADCON.4/ADINT,
the ADC interrupt flag, is set. It is not cleared by interrupt hardware
– it must be cleared by software.
In continuous scan mode (ADCON.2/ADCSA=1) the ADC start and
status flag ADCON.3/ADSST retains the set state and the autoscan
loop restarts from the beginning. In one-time scan mode (ADCSA=0)
conversions stop after the last selected analog input was converted,
ADINT is set and ADSST is cleared automatically.
ADSST cannot be set (neither externally nor by software) as long as
ADINT=1, i.e. as long as ADINT is set, a new conversion start – by
setting flag ADSST – is inhibited; actually it is only delayed until
ADINT is cleared.
(If a ‘1’ is written to ADSST while ADINT=1, this new value is
internally latched and preserved, not setting ADSST until
ADCON.4/ADINT=0. In this state, a read of SFR ADCON will display
ADCON.3/ADSST=0, because always the effective ADC status is
read.)
Note that under software control the analog inputs can also be
converted in arbitrary order, when one-time scan mode is selected
and in SFR ADPSS only one bit is set at a time. In this case ADINT
is set and ADSST is cleared after every conversion.
6.6.3 Resolution and Characteristics
The ADC system has its own analog supply pins AV
is referenced by two special reference voltage input pins sourcing
the resistance ladder of the DAC: AV
between AV
the 10-bit resolution the full scale range is divided into 1024 unit
steps. The unit step voltage is 1 LSB, which is typically 5 mV
(AV
= 5.12 V, AV
ref+
The DAC’s resistance ladder has 1023 equally spaced taps,
separated by a unit resistance ’R’. The first tap is located 0.5 x R
above AV
results in a total ladder resistance of 1024 x R. This structure
ensures that the DAC is monotonic and results in a symmetrical
quantization error. For input voltages between AV
+ 1/2 LSB) the 10-bit conversion result code will be
(AV
ref–
00 0000 0000 B = 000H = 0D. For input voltages between
and AV
REF+
ref–
, the last tap is located 1.5 x R below AV
ref–
defines the full-scale range. Due to
REF–
= 0 V = AVSS).
ref+
and AV
and AVSS. It
DD
. The voltage
ref–
ref+
and
ref–
. This
– 3/2 LSB) and AV
ref+
be 11 11 11 1 111 B = 3FFH = 1023D.
The result code corresponding to an analog input voltage (AV
be calculated from the formula:
ResultCode + 1024
The analog input voltage should be stable when it is sampled for
conversion. At any times the input voltage slew rate must be less
than 10 V/ms (5 V conversion range) in order to prevent an
undefined result.
This maximum input voltage slew rate can be ensured by an RC low
pass filter with R = 2k2 and C = 100 nF. The capacitor between
analog input pin and analog ground pin shall be placed close to the
pins in order to have maximum effect in minimizing input noise
coupling.
6.7 Timer/Counters
The P8xC557E4 contains three 16-bit timer/event counters: Timer 0,
Timer 1 and Timer T2 and one 8-bit timer, T3. Timer 0 and Timer 1
may be programmed to carry out the following functions:
•Measure time intervals and pulse durations
•Count events
•Generate interrupt requests
6.7.1 Timer 0 and Timer 1
Timers 0 and 1 each have a control bit in SFR TMOD that selects
the timer or counter function of the corresponding timer.
In the timer function, the register is incremented every machine
cycle. Thus, one can think of it as counting machine cycles. Since a
machine cycle consists of 12 oscillator periods, the count rate is
1/12 of the oscillator frequency.
In the counter function, the register is incremented in response to a
1-to-0 transition at the corresponding external input pin, T0 or T1. In
this function, the external input is sampled during S5P2 of every
machine cycle. When the samples show a HIGH in one cycle and a
LOW in the next cycle, the counter is incremented. Thus, it takes
two machine cycles (24 oscillator periods) to recognize a 1-to-0
transition. There are no restrictions on the duty cycle of the external
input signal, but to insure that a given level is sampled at least once
before it changes, it should be held for at least one full machine
cycle.
Timer 0 and Timer 1 can be programmed independently to operate
in one of four modes:
•Mode 0:
8-bit timer or 8-bit counter each with divide-by-32 prescaler
•Mode 1:
16-bit time-interval or event counter
•Mode 2:
8-bit time-interval or event counter with automatic reload
upon overflow
•Mode 3:
–Timer 0: one 8-bit time-interval or event counter and
When Timer 0 is in Mode 3, Timer 1 can be programmed to operate
in Modes 0, 1 or 2 but cannot set an interrupt request flag or
generate an interrupt. However the overflow from Timer 1 can be
used to pulse the serial port baud-rate generator.
With a 16 MHz crystal, the counting frequency of these
timer/counters is as follows:
•In the timer function, the timer is incremented at a frequency of
1.33 MHz – a division by 12 of the system clock frequency
•0 Hz to an upper limit of 0.66 MHz (1/24 of the system clock
frequency) when programmed for external inputs
76543210
TMOD (89H)GATEC/TM1M0GATEC/TM1M0
Timer 1
Figure 19. Timer/Counter mode control (TMOD) register.
Both internal and external inputs can be gated to the counter by a
second external source for directly measuring pulse durations.
When configured as a counter, the register is incremented on every
falling edge on the corresponding input pin, T0 or T1. The
incremented register value can be read earliest during the second
machine cycle after that one, during which the incrementing pulse
occurred.
The counters are started and stopped under software control. Each
one sets its interrupt request flag when it overflows from all HIGHs
to all LOWs (or automatic reload value), with the exception of mode
3 as previously described.
Table 12.Description of TMOD bits
SYMBOL BITFUNCTION
GateTMOD.7
C/TTMOD.6
M1
M0
TMOD.3
TMOD.2
TMOD.5
TMOD.1
TMOD.4
TMOD.0
Gating control when set. Timer/Counter “x” is enabled only while “INTx” pin is high and “TRx” control pin is set.
When cleared Timer “x” is enabled whenever “TRx” control bit is set.
Timer or Counter Selector cleared for Timer operation (input from internal system clock). Set for Counter
operation (input from “Tx” input pin).
Timer 0, Timer 1 mode select see Table 13.
Timer 0
Table 13.T imer 0 / Timer 1 operation select
M1 M0OPERATING
008048 Timer “TLx” serves as 5-bit prescaler.
0116-bit Timer/Counter “THx” and “TLx” are cascaded; there is no prescaler.
108-bit auto-reload Timer/Counter “THx” holds a value which is to be reloaded into “TLx” each time it overflows.
11(Timer 0) TL0 is an 8-bit Timer/Counter controlled by the standard Timer 0 control bits. TH0 is an 8-bit timer
11(Timer 1) Timer/Counter 1 stopped.
1999 Mar 02
only controlled by Timer 1 control bits.
22
Loading...
+ 50 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.