W78ERD2/W78ERD2A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

Similar documents
W78ERD2 Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

W78ERD2 Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

Rev. No. History Issue Date Remark

8XC51RA RB RC Hardware Description

8.1.1 External Data Memory Access Timing...32

7.2.1 Timer 2 Capture LSB... 24

W79E201 Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

W77E532/W77E532A DATA SHEET 8-BIT MICROCONTROLLER. Table of Contents-

W77L516A DATA SHEET 8-BIT MICROCONTROLLER. Table of Contents-


Preliminary W77E58 8 BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: March Revision A1

8XC151SA and 8XC151SB Hardware Description

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

8-BIT MICROCONTROLLER

W77IE58 8-BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: December Revision A2

TK89C668 Microcontroller 64K Flash, 8K RAM, TWI

W77LE58/W77L058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents- Publication Release Date: April 17, Revision A7

W77E532 Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

W77E058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

Preliminary W77C32 8 BIT MICROCONTROLLER GENERAL DESCRIPTION FEATURES

89C51RC+/RD+ 80C51 8-bit Flash microcontroller family 32K/64K ISP FLASH with 512 1K RAM

P89V52X2. 1. General description. 2. Features. 8-bit 80C51 low power 8 kb flash microcontroller with 256 B RAM, 192 B data EEPROM

High-Speed Microcontroller User s Guide

MEGAWIN MPC89L516X2. 8-bit micro-controller. Features

TS80C52X2. 8-bit CMOS Microcontroller 0-60 MHz. Preliminary. 1. Description. 2. Features

MPC89E515A. 8-bit micro-controller

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20

TDA General description. 2. Features. Low power single card reader

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

FlashFlex51 MCU SST89E52RD2 / SST89E54RD2 / SST89E58RD2 / SST89E516RD2 SST89V52RD2 / SST89V54RD2 / SST89V58RD2 / SST89V516RD2

INTEGRATED CIRCUITS P83C660X2, P87C660X2 P83C661X2, P87C661X2

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

8-bit Microcontroller with 12K Bytes Flash and 2K Bytes EEPROM AT89S8253

8-bit Flash Microcontroller AT89S54 AT89S58 AT89S64

High-Speed Microcontroller User s Guide

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

8-bit Microcontroller 8 Kbytes ROM/OTP, ROMless TS80C32X2 TS87C52X2 TS80C52X2 AT80C32X2 AT80C52X2 AT87C52X2. Features. Description

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

MPC89x58A. 8-bit micro-controller

8051 Microcontroller

PRELIMINARY TK89H o C Microcontroller

The Final Word on 8051 Microcontroller

FlashFlex MCU SST89E52RC / SST89E54RC

DS89C420 Ultra High-Speed Microcontroller User s Guide

8-bit Microcontroller with 12K Bytes Flash and 2K Bytes EEPROM AT89S8253. Preliminary

SECTION 1: INTRODUCTION 5 SECTION 2: ORDERING INFORMATION 5 SECTION 3: ARCHITECTURE 5

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

7.1.1 External Data Memory Access Timing...51

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

High Performance 8-bit Microcontrollers

T89C51RD2. 0 to 40MHz Flash Programmable 8-bit Microcontroller. 1. Description. 2. Features

FlashFlex MCU SST89V54RD2/RD / SST89V58RD2/RD

7.1.1 External Data Memory Access Timing...52

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

AT Bit Spread- Spectrum Microcontroller. Preliminary. Features. Description. Pin Configuration

7.1.1 External Data Memory Access Timing...52

Lecture 9. Timer Operations and Programming

EE6502- MICROPROCESSOR AND MICROCONTROLLER

8051 MICROCONTROLLER

8051 Microcontroller

CS 320. Computer Architecture Core Architecture

8-bit Microcontroller with 16K/ 32K byte Flash T89C51RB2 T89C51RC2

FEATURES: FlashFlex51 MCU SST89E564RD / SST89V564RD / SST89E554RC / SST89V554RC SST89E/V564RD SST89E/VE554RC FlashFlex51 MCU Preliminary Specification

MSM80C154S MSM83C154S MSM85C154HVS USER'S MANUAL

ULTRA-HIGH-SPEED FLASH MICROCONTROLLER USER S GUIDE

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

UNIT IV MICROCONTROLLER

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

DATA SHEET. P80CL31; P80CL51 Low voltage 8-bit microcontrollers with UART INTEGRATED CIRCUITS Apr 15

8-Bit Microcontroller with 8K Bytes Flash AT89S8252. Features. Description

PGT302 Embedded Software Technology. PGT302 Embedded Software Technology

FlashFlex MCU SST89E516RD2 / SST89E516RD SST89V516RD2 / SST89V516RD

8-bit Microcontroller with 16K/ 32K Bytes Flash AT89C51RB2 AT89C51RC2. Features. Description

High Performance 8-bit Microcontroller

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 4199

8051 Serial Communication

Migrating from the 8XC251Sx to the 8XC251Tx

DS87C520/DS83C520 EPROM/ROM High-Speed Micro

P89V51RD2. 1. General description. 2. Features. 8-bit 80C51 5 V low power 64 kb Flash microcontroller with 1 kb RAM

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

8051 microcontrollers

DS87C520/DS83C520. EPROM/ROM High Speed Micro PRELIMINARY PACKAGE OUTLINE FEATURES

FlashFlex51 MCU SST89E564 / SST89V564 / SST89E554 / SST89V554

MCS-51 Serial Port A T 8 9 C 5 2 1

Introduction To MCS-51

8051 MICROCONTROLLER WITH 64K FLASH AND ISP. Latch PSW ALU. Latch. Instruction Decoder & Sequencer. Bus&Clock Controller. Port 4. Latch.

DATA SHEET. P83C524; P80C528; P83C528 8-bit microcontrollers INTEGRATED CIRCUITS Dec 15

89C51/89C52/89C54/89C58 80C51 8-bit microcontroller family 4K/8K/16K/32K Flash

Chapter C2051 Architecture and Serial Communication Link

8051 Embedded Microcontroller HD 8002

P89V660/662/664 8-bit 80C51 5 V low power 16 kb/32 kb/64 kb flash microcontroller with 512 B/1 kb/2 kb RAM, dual I 2 C-bus, SPI

8-bit Flash Microcontroller AT89C51RD2 AT89C51ED2. Features. Description

8-Bit Microcontroller with 8K Bytes QuickFlash Memory

Fig 1. Block diagram of a microcomputer

8051 Microcontroller memory Organization and its Applications

Mod-3: Interrupts,Timer operation,serial communication 1

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

20uA at VDD=5.5V 5uA at VDD=3.6V. 1T up to 20 (1T~8T can change on fly) RC ( 24MHz) Program Flash ( byte) 4K 4K RAM( byte)

Transcription:

Data Sheet Table of Contents- 8-BIT MICROCONTROLLER GENERAL DESCRIPTION 3 2 FEATURES 3 3 PIN CONFIGURATIONS 4 4 PIN DESCRIPTION 5 5 FUNCTIONAL DESCRIPTION 6 5 RAM 6 52 Timers/Counters 6 53 Clock 7 54 Power Management 7 55 Reduce EMI Emission 7 56 Reset 7 6 SPECIAL FUNCTION REGISTER 8 7 PORT 4 AND BASE ADDRESS REGISTERS 3 8 INTERRUPTS 32 8 External Interrupts 2 and 3 32 82 Interrupt Priority 32 9 PROGRAMMABLE TIMERS/COUNTERS 33 9 Timer and Timer 33 92 Timer/Counter 2 35 ENHANCED FULL DUPLEX SERIAL PORT 38 MODE 38 2 MODE 39 3 MODE 2 4 4 MODE 3 4 5 Framing Error Detection 42 6 Multi-Processor Communications 42 PROGRAMMABLE COUNTER ARRAY (PCA) 44 PCA Capture Mode 47 2 6-bit Software Timer Comparator Mode 47 3 High Speed Output Mode 48 4 Pulse Width Modulator Mode 49 5 Watchdog Timer 49 2 HARDWARE WATCHDOG TIMER (ONE-TIME ENABLED WITH RESET-OUT) 5 - - Revision A2

3 DUAL DPTR 5 4 TIMED-ACCESS PROTECTION 5 5 IN-SYSTEM PROGRAMMING (ISP) MODE 53 6 H/W REBOOT MODE (BOOT FROM LDROM) 57 7 OPTION BITS REGISTER 58 8 ELECTRICAL CHARACTERISTICS 6 8 Absolute Maximum Ratings 6 82 DC Characteristics 6 83 AC Characteristics 62 9 TIMING WAVEFORMS 64 2 TYPICAL APPLICATION CIRCUITS 66 2 External Program Memory and Crystal 66 22 Expanded External Data Memory and Oscillator 67 2 PACKAGE DIMENSIONS 68 22 APPLICATION NOTE 7 22 In-System Programming (ISP) Software Examples 7 222 How to Use Programmable Counter Array 74 23 REVISION HISTORY 75-2 - Revision A2

GENERAL DESCRIPTION The W78ERD2 is an 8-bit microcontroller which is pin- and instruction-set-compatible with the standard 8C52 The W78ERD2 contains a 64-KB Flash EPROM whose contents may be updated in-system by a loader program stored in an auxiliary, 4-KB Flash EPROM Once the contents are confirmed, it can be protected for security The W78ERD2 also contains 256 bytes of on-chip RAM; KB of auxiliary RAM; four 8-bit, bidirectional and bit-addressable I/O ports; an additional 4-bit port P4; three 6-bit timer/counters; and a serial port These peripherals are all supported by nine interrupt sources with 4 levels of priority The W78ERD2 has two power-reduction modes: idle mode and power-down mode, both of which are software-selectable Idle mode turns off the processor clock but allows peripherals to continue operating, while power-down mode stops the crystal oscillator for minimum power consumption Power-down mode can be activated at any time and in any state without affecting the processor 2 FEATURES 8-bit CMOS microcontroller Pin-compatible with standard 8C52 Instruction-set compatible with 8C52 Four 8-bit I/O ports; Port has internal pull-up resisters enabled by software One extra 4-bit I/O port with interrupt and chip-select functions Three 6-bit timers Programmable clock out Programmable Counter Array (PCA) with PWM, Capture, Compare and Watchdog functions 9 interrupt sources with 4 levels of priority Full-duplex serial port with framing-error detection and automatic address recognition 64-KB, in-system-programmable, Flash EPROM (AP Flash EPRAOM) 4-KB auxiliary Flash EPROM for loader program (LD Flash EPROM) 256-byte on-chip RAM -KB auxiliary RAM, software-selectable Software Reset 2 clocks per machine cycle operation (default) Speed up to 4 MHz 6 clocks per machine cycle operation set by the writer Speed up to 2 MHz 2 DPTR registers Low EMI (inhibit ALE) Built-in power management with idle mode and power down mode Code protection Packages: Lead Free (RoHS) DIP 4: W78ERD2A4DL Lead Free (RoHS) PLCC 44: W78ERD2A4PL Lead Free (RoHS) PQFP 44: W78ERD2A4FL - 3 - Revision A2

3 PIN CONFIGURATIONS 4-Pin DIP T2, P T2EX, P P2 P3 P4 P5 P6 P7 RST RXD, P3 TXD, P3 INT, P32 INT, P33 T, P34 T, P35 WR, P36 RD, P37 XTAL2 XTAL VSS 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 2 4 39 38 37 36 35 34 33 32 3 3 29 28 27 26 25 24 23 22 2 VDD P, AD P, AD P2, AD2 P3, AD3 P4, AD4 P5, AD5 P6, AD6 P7, AD7 EA ALE PSEN P27, A5 P26, A4 P25, A3 P24, A2 P23, A P22, A P2, A9 P2, A8 44-Pin PLCC P 4 P 3 P 2 T 2 E X, P T 2, P / I N T 3, P 4 2 V D D A D, P A D, P A D 2, P 2 A D 3, P 3 44-Pin QFP P 4 P 3 P 2 T 2 E X, P T 2, P / I N T 3, P 4 2 V D D A D, P A D, P A D 2, P 2 A D 3, P 3 P5 P6 P7 RST RXD, P3 INT2, P43 TXD, P3 INT, P32 INT, P33 T, P34 T, P35 6 5 4 3 2 44 43 42 4 4 7 8 9 2 3 4 5 6 7 39 38 37 36 35 34 33 32 3 3 29 8 9 2 2 22 23 24 25 26 27 28 P4, AD4 P5, AD5 P6, AD6 P7, AD7 EA P4 ALE PSEN P27, A5 P26, A4 P25, A3 P5 P6 P7 RST RXD, P3 INT2, P43 TXD, P3 INT, P32 INT, P33 T, P34 T, P35 44 43 42 4 4 39 38 37 36 35 34 33 2 32 3 3 4 3 5 29 6 28 7 27 8 26 9 25 24 23 2 3 4 5 6 7 8 9 2 2 22 P4, AD4 P5, AD5 P6, AD6 P7, AD7 EA P4 ALE PSEN P27, A5 P26, A4 P25, A3 P 3 6, / W R P 3 7, / R D X T A L 2 X T A L V S S P 4 P 2, A 8 P 2, A 9 P 2 2, A P 2 3, A P 2 4, A 2 P 3 6, / W R P 3 7, / R D X T A L 2 X T A L V S S P 4 P 2, A 8 P 2, A 9 P 2 2, A P 2 3, A P 2 4, A 2-4 - Revision A2

4 PIN DESCRIPTION SYMBOL TYPE* DESCRIPTIONS EA I EXTERNAL ACCESS ENABLE: This pin forces the processor to execute instructions in external ROM The ROM address and data are not presented on the bus if the EA pin is high PSEN ALE RST O H O H I L PROGRAM STORE ENABLE: PSEN indicates external ROM data is on the Port address/data bus If internal ROM is accessed, no PSEN strobe signal is present on this pin ADDRESS LATCH ENABLE: ALE is used to enable the address latch that separates the address from the data on Port ALE runs at /6th of the oscillator frequency RESET: If this pin is set high for two machine cycles while the oscillator is running, the W78ERD2 is reset XTAL I CRYSTAL : Crystal oscillator input or external clock input XTAL2 O CRYSTAL 2: Crystal oscillator output V SS I GROUND: ground potential V DD I POWER SUPPLY: Supply voltage for operation P P7 I/O D PORT : 8-bit, bi-directional I/O port, the same as that of the standard 8C52 Port has internal pull-up resisters enabled by software P P7 I/O H PORT : 8-bit, bi-directional I/O port, the same as that of the standard 8C52 P2 P27 I/O H PORT 2: 8-bit, bi-directional I/O port with internal pull-ups This port also provides the upper address bits when accessing external memory P3 P37 I/O H PORT 3: 8-bit, bi-directional I/O port, the same as that of the standard 8C52 P4 P43 I/O H PORT 4: 4-bit, bi-directional I/O port with chip-select functions * Note: TYPE I: input, O: output, I/O: bi-directional, H: pull-high, L: pull-low, D: open drain - 5 - Revision A2

5 FUNCTIONAL DESCRIPTION The W78ERD2 architecture consists of a core processor that supports different op-codes and references 64 KB of program space and 64 KB of data space It is surrounded by various registers; four general-purpose I/O ports; one special-purpose, programmable, 4-bit I/O port; 256 bytes of RAM; KB of auxiliary RAM (AUX-RAM); three timer/counters; a serial port; and an internal 74373 latch and 74244 buffer which can be switched to port 2 This section introduces the RAM, Timers/Counters, Clock, Power Management, Reduce EMI Emission, and Reset 5 RAM The W78ERD2 has two banks of RAM: 256 bytes of RAM and KB of AUX-RAM AUX-RAM is enabled by clearing bit in the AUXR register, and it is enabled after reset Different addresses in RAM are addressed in different ways RAM H 7FH can be addressed directly or indirectly, as in the 85 The address pointers are R and R of the selected bank RAM 8H FFH can only be addressed indirectly, as in the 85 The address pointers are R and R of the selected bank AUX-RAM H 3FFH is addressed indirectly in the same way external data memory is accessed with the MOVX instruction The address pointers are R and R of the selected bank and the DPTR register Addresses higher than 3FFH are stored in external memory and are accessed indirectly with the MOVX instruction, as in the 85 When AUX-RAM is enabled, the instruction "MOVX @Ri" always accesses AUX-RAM When the W78ERD2 is executing instructions from internal program memory, accessing AUX-RAM does not affect ports P, P2, WR or RD For example, ANL AUXR,#B ; Enable AUX-RAM MOV DPTR,#234H MOV A,#56H MOVX @DPTR,A ; Write 56h to address 234H in external memory MOV XRAMAH,#2H ; Only 2 LSB effective MOV R,#34H MOV A,@R ; Read AUX-RAM data at address 234H 52 Timers/Counters The W78ERD2 has three timers/counters called Timer, Timer, and Timer 2 Each timer/counter consists of two 8-bit data registers: TL and TH for Timer, TL and TH for Timer, and TL2 and TH2 for Timer 2 The operations of Timer and Timer are similar to those in the W78C52, and these timers are controlled by the TCON and TMOD registers - 6 - Revision A2

Timer 2 is controlled by the T2CON register Like Timers and, Timer 2 can operate as either an external event counter or an internal timer, depending on the setting of bit C/T2 in T2CON Timer 2 has three operating modes: capture, auto-reload, and baud rate generator In capture or auto-reload mode, RCAP2H and RCAP2L are the reload / capture registers and the clock speed is the same as that of Timers and 53 Clock The W78ERD2 is designed for either a crystal oscillator or an external clock The W78ERD2 incorporates a built-in crystal oscillator To make the oscillator work, a crystal must be connected across pins XTAL and XTAL2, and a load capacitor may be connected from each pin to ground In addition, if the crystal frequency is higher than 24 MHz, a resistor should be connected between XTAL and XTAL2 to provide a DC bias An external clock is connected to pin XTAL, while pin XTAL2 should be left disconnected The XTAL input is a CMOS-type input, as required by the crystal oscillator As a result, the logic- voltage should be higher than 35 V 54 Power Management The W78ERD2 provides two modes, idle mode and power-down mode, to reduce power consumption Both modes are entered by software The W78ERD2 enters Idle mode when the IDL bit in the PCON register is set In Idle mode, the internal clock for the processor stops while the internal clock for the peripherals and interrupt logic continues to run The W78ERD2 leaves Idle mode when an interrupt or a reset occurs The W78ERD2 enters Power-Down mode when the PD bit in the PCON register is set In Power-Down mode, all of the clocks are stopped, including the oscillator The W78ERD2 leaves Power-Down mode when there is a hardware reset or by external interrupts INT or INT, if enabled 55 Reduce EMI Emission If the crystal frequency is less than 25 MHz, set bit 7 in the option register to to reduce EMI emissions Please see Option Bits for more information 56 Reset The external RESET signal is sampled at S5P2 To take effect, it must be held high for at least two machine cycles while the oscillator is running, as the W78ERD2 has a special glitch-removal circuit that ignores glitches on the reset line During reset, the ports are initialized to FFH, the stack pointer to 7H, and all of the other SFR to H, with two exceptions SBUF does not change, and bit 4 in PCON is not cleared - 7 - Revision A2

6 SPECIAL FUNCTION REGISTER The following table identifies the Special Function Registers (SFRs) in the W78ERD2, as well as each of their addresses and reset values F8 CH CCAPH CCAPH CCAP2H CCAP3H CCAP4H FF F +B CHPENR F7 E8 +P4 xxxx CL CCAPL CCAPL CCAP2L CCAP3L CCAP4L EF E +ACC E7 D8 CCON x CMOD xxx CCAPM x CCAPM x CCAPM2 x CCAPM3 x CCAPM4 x CKCON xxxx DF D +PSW D7 C8 +T2CON T2MOD xxxxxx RCAP2L RCAP2H TL2 TH2 CF C XICON XICONH xxxxxx P4CONA P4CONB SFRAL SFRAH SFRFD SFRCN C7 B8 +IP x SADEN CHPCON xx BF B +P3 P43AL P43AH IPH x B7 A8 +IE SADDR P42AL P42AH P4CSIN AF A +P2 XRAMAH AUXR xxxxxx WDTRST A7 98 +SCON SBUF xxxxxxxx P2EAL P2EAH 9F 9 +P P4AL P4AH 97 88 +TCON TMOD TL TL TH TH AUXR 8F 8 +P SP DPL DPH P4AL P4AH PORT PCON 87 Notes: SFRs marked with a plus sign (+) are both byte- and bit-addressable 2 The text of SFR with bold type characters are extension function registers The rest of this section explains each SFR, starting with the lowest address - 8 - Revision A2

Port P7 P6 P5 P4 P3 P2 P P Mnemonic: P Address: 8h Port is an open-drain, bi-directional I/O port after chip is reset Besides, it has internal pull-up resisters enabled by setting PUP of POPT (86H) to high This port also provides a multiplexed, loworder address/data bus when the W78IRD2 accesses external memory Stack Pointer SP7 SP6 SP5 SP4 SP3 SP2 SP SP Mnemonic: SP Address: 8h The Stack Pointer stores the RAM address (scratchpad RAM, not AUX-RAM) where the stack begins It always points to the top of the stack Data Pointer Low DPL7 DPL6 DPL5 DPL4 DPL3 DPL2 DPL DPL Mnemonic: DPL Address: 82h This is the low byte of the standard-852 6-bit data pointer Data Pointer High DPH7 DPH6 DPH5 DPH4 DPH3 DPH2 DPH DPH Mnemonic: DPH Address: 83h This is the high byte of the standard-852 6-bit data pointer Port 4 Low-Address Comparator P4AL7 P4AL6 P4AL5 P4AL4 P4AL3 P4AL2 P4AL P4AL Mnemonic: P4AL Address: 84h Port 4 High-Address Comparator P4AH7 P4AH6 P4AH5 P4AH4 P4AH3 P4AH2 P4AH P4AH Mnemonic: P4AH Address: 85h - 9 - Revision A2

Port Option Register - - - - - - - PUP Mnemonic: POPT Address: 86h BIT NAME FUNCTION 7 - Reserve PUP : Port pins are open-drain : Port pins are internally pulled-up Port is structurally the same as Port 2 Power Control SMOD SMOD - POR GF GF PD IDL Mnemonic: PCON Address: 87h BIT NAME FUNCTION 7 SMOD : Double the serial-port baud rate in serial port modes, 2, and 3 6 SMOD 5 - Reserved 4 POF : Framing Error Detection Disable SCON7 acts as per the standard 852 function : Framing Error Detection Enable SCON7 indicates a Frame Error and acts as the FE (FE_) flag This bit is set to when a power-on reset has occurred It can be cleared by software 3 GF General-purpose flag 2 GF General-purpose flag PD Set this bit to to go into POWER DOWN mode IDL Set this bit to to go into IDLE mode Timer Control TF TR TF TR IE IT IE IT Mnemonic: TCON Address: 88h - - Revision A2

BIT NAME FUNCTION 7 TF 6 TR 5 TF 4 TR 3 IE 2 IT IE IT Timer Mode Control Timer overflow flag: This bit is set when Timer overflows It is cleared automatically when the program does a timer interrupt service routine It can also be set or cleared by software : Turn on Timer : Turn off Timer Timer overflow flag: This bit is set when Timer overflows It is cleared automatically when the program does a timer interrupt service routine It can also be set or cleared by software : Turn on Timer : Turn off Timer Interrupt Edge Detect: This bit is set by the hardware when a falling-edge / lowlevel is detected on INT If INT is edge-triggered, this bit is cleared by the hardware when the interrupt service routine begins Otherwise, it follows the pin Interrupt type control : Interrupt is triggered by a falling-edge on INT : Interrupt is triggered by a low-level on INT Interrupt Edge Detect: This bit is set by the hardware when a falling-edge / lowlevel is detected on INT If INT is edge-triggered, this bit is cleared by the hardware when the interrupt service routine begins Otherwise, it follows the pin Interrupt type control : Interrupt is triggered by a falling-edge on INT : Interrupt is triggered by a low-level on INT GATE C/ T M M GATE C/ T M M Mnemonic: TMOD Address: 89h BIT NAME FUNCTION 7 GATE 6 C/ T Gating control: When this bit is set, Timer/Counter is enabled only while the INT pin is high and the TR control bit is set When cleared, the INT pin has no effect, and Timer is enabled whenever TR is set Timer or Counter Select: When cleared, Timer is incremented by the internal clock When set, Timer counts falling edges on the T pin 5 M Timer Mode Select bits: See below 4 M Timer Mode Select bits: See below - - Revision A2

Continued BIT NAME FUNCTION 3 GATE 2 C/ T Gating control: When this bit is set, Timer/Counter is enabled only while the INT pin is high and the TR control bit is set When cleared, the INT pin has no effect, and Timer is enabled whenever TR is set Timer or Counter Select: When cleared, Timer is incremented by the internal clock When set, Timer counts falling edges on the T pin M Timer Mode Select bits: See below M Timer Mode Select bits: See below M, M: Mode Select bits: M M Mode Mode : 848 timer, TLx serves as 5-bit pre-scale Mode : 6-bit timer/counter, no pre-scale Mode 2: 8-bit timer/counter with auto-reload from THx Mode 3: (Timer ) TL is an 8-bit timer/counter controlled by the standard Timer- control bits TH is an 8-bit timer only controlled by Timer- control bits (Timer ) Timer/Counter is stopped Timer LSB TL7 TL6 TL5 TL4 TL3 TL2 TL TL Mnemonic: TL Address: 8Ah TL7-: Timer Low byte Timer LSB TL7 TL6 TL5 TL4 TL3 TL2 TL TL Mnemonic: TL Address: 8Bh TL7-: Timer Low byte Timer MSB TH7 TH6 TH5 TH4 TH3 TH2 TH TH Mnemonic: TH Address: 8Ch TH7-: Timer High byte - 2 - Revision A2

Timer MSB TH7 TH6 TH5 TH4 TH3 TH2 TH TH Mnemonic: TH Address: 8Dh TH7-: Timer High byte Auxiliary Register - - - - - - EXTRAM ALEOFF Mnemonic: AUXR Address: 8Eh BIT NAME FUNCTION 7~2 - Reserve EXTRAM = Enable AUX-RAM = Disable AUX-RAM ALEOFF : ALE expression is enabled : ALE expression is disabled Port P7 P6 P5 P4 P3 P2 P P Mnemonic: P Address: 9h P7-: General-purpose input/output port Port-read instructions read the port pins, while read-modifywrite instructions read the port latch Port 4 Low Address Comparator P4AL7 P4AL6 P4AL5 P4AL4 P4AL3 P4AL2 P4AL P4AL Mnemonic: P4AL Address: 94h Port 4 High Address Comparator P4AH7 P4AH6 P4AH5 P4AH4 P4AH3 P4AH2 P4AH P4AH Mnemonic: P4AH Address: 95h - 3 - Revision A2

Serial Port Control SM/FE SM SM2 REN TB8 RB8 TI RI Mnemonic: SCON Address: 98h BIT NAME FUNCTION 7 SM/FE Serial port, Mode (SM) bit or Framing-Error (FE) Flag: The SMOD bit in PCON SFR determines whether this bit acts as SM or as FE SM is described with SMI below When used as FE, this bit indicates whether the stop bit is invalid (FE=) or valid (FE=) This bit must be manually cleared by software Serial port, Mode (SM) bit: Mode: SM SM Description Length Baud rate 6 SM 5 SM2 4 REN 3 TB8 2 RB8 TI RI Synchronous 8 6(6T mode)/2(2t mode) T clk Asynchronous Variable 2 Asynchronous 32/6(6T mode) or 64/32(2T mode) T clk 3 Asynchronous Variable Multi-processor communication (Modes 2 and 3) Set this bit to enable the multi-processor communication feature With this feature, RI is not activated if the ninth data bit received (RB8) is (Mode ) Set this bit to to keep RI de-activated if a valid stop bit is not received (Mode ) SM2 controls the serial port clock If clear, the serial port runs at /2 the oscillator This is compatible with the standard 852 Receive enable: = Serial reception is enabled = Serial reception is disabled (Modes 2 and 3) This is the ninth bit to be transmitted This bit is set and cleared by software as desired (Modes 2 and 3) This is the ninth data bit that was received (Mode ) If SM2 is, RB8 is the stop bit that was received (Mode ) No function Transmit interrupt flag: This flag is set by the hardware at the end of the eighth bit in mode or at the beginning of the stop bit in modes 3 during serial transmission This bit must be cleared by software Receive interrupt flag: This flag is set by the hardware at the end of the eighth bit in mode or halfway through the stop bit in modes 3 during serial reception However, SM2 restricts this bit This bit can be cleared only by software - 4 - Revision A2

Serial Data Buffer SBUF7 SBUF6 SBUF5 SBUF4 SBUF3 SBUF2 SBUF SBUF Mnemonic: SBUF Address: 99h BIT NAME FUNCTION 7~ SBUF Serial port data is read from or written to this location It actually consists of two separate, internal 8-bit registers, the receive register and the transmit buffer Any read access reads data from the receive register, while write access writes to the transmit buffer Port 2 P27 P26 P25 P24 P23 P22 P2 P2 Mnemonic: P2 Address: Ah Ram High Byte Address XRAMAH XRAMAH Mnemonic: XRAMAH Address: Ah The AUX-RAM high byte address Auxiliary Register - - - - GF2 - DPS Mnemonic: AUXR Address: A2h BIT NAME FUNCTION 7~4 - Reserved 3 GF2 General purpose, user defined flag 2 The bit cannot be written and is always read as - Reserved DPS = switch to DPTR = switch to DPTR - 5 - Revision A2

Watchdog Timer Reset Register WDTRST7 WDTRST6 WDTRST5 WDTRST4 WDTRST3 WDTRST2 WDTRST WDTRST Mnemonic: WDTRST Address: A6h Interrupt Enable EA EC ET2 ES ET EX ET EX Mnemonic: IE Address: A8h BIT NAME FUNCTION 7 EA Global interrupt enable Enable/disable all interrupts except for PFI 6 EC Enable PCA interrupt 5 ET2 Enable Timer 2 interrupt 4 ES Enable Serial port interrupt 3 ET Enable Timer interrupt 2 EX Enable external interrupt INT ET Enable Timer interrupt EX Enable external interrupt INT SLAVE ADDRESS Mnemonic: SADDR Address: A9h BIT NAME FUNCTION 7~ SADDR The SADDR should be programmed to the given or broadcast address for serial port to which the slave processor is designated Port 42 Low Address Comparator P42AL7 P42AL6 P42AL5 P42AL4 P42AL3 P42AL2 P42AL P42AL Mnemonic: P42AL Address: Ach - 6 - Revision A2

Port 42 High Address Comparator P42AH7 P42AH6 P42AH5 P42AH4 P42AH3 P42AH2 P42AH P42AH Mnemonic: P42AH Address: ADh Port 4 CS Inverse P43INV P42INV P4INV P4INV Mnemonic: P4CSIN Address: AEh BIT NAME FUNCTION The active polarity of P4x which functions chip-select signal 7~4 P4xINV : Active high : Active low 3~ - Reserved and must be set zero Port 3 P37 P326 P35 P324 P33 P32 P3 P3 Mnemonic: P3 Address: Bh Port 43 Low Address Comparator P43AL7 P43AL6 P43AL5 P43AL4 P43AL3 P43AL2 P43AL P43AL Mnemonic: P43AL Address: B4h Port 43 High Address Comparator P43AH7 P43AH6 P43AH5 P43AH4 P43AH3 P43AH2 P43AH P43AH Mnemonic: P43AH Address: B5h Interrupt Priority High - PPCH PT2H PSH PTH PXH PTH PXH Mnemonic: IPH Address: B8h BIT NAME FUNCTION 7 - This bit is not implemented and is always read high 6 PPCH : Set the priority of the PCA interrupt to the highest level - 7 - Revision A2

5 PT2H : Set the priority of the Timer 2 interrupt to the highest level 4 PSH : Set the priority of the Serial Port interrupt to the highest level 3 PTH : Set the priority of the Timer interrupt to the highest level 2 PXH : Set the priority of external interrupt INT to the highest level PTH : Set the priority of the Timer interrupt to the highest level PXH : Set the priority of external interrupt INT to the highest level Interrupt Priority - PPC PT2 PS PT PX PT PX Mnemonic: IP Address: B8h BIT NAME FUNCTION 7 - This bit is not implemented and is always read high 6 PPC : Set the priority of the PCA interrupt one level higher 5 PT2 : Set the priority of the Timer 2 interrupt one level higher 4 PS : Set the priority of the Serial Port interrupt one level higher 3 PT : Set the priority of the Timer interrupt one level higher 2 PX : Set the priority of external interrupt INT one level higher PT : Set the priority of the Timer interrupt one level higher PX : Set the priority of external interrupt INT one level higher Slave Address Mask Enable Mnemonic: SADEN Address: B9h BIT NAME FUNCTION 7~ SADEN This register enables the Automatic Address Recognition feature of the serial port When a bit in SADEN is set to, the same bit in SADDR is compared to the incoming serial data When a bit in SADEN is set to, the same bit in SADDR is a "don't care" value in the comparison The serial port interrupt occurs only if all the SADDR bits where SADEN is set to match the incoming serial data On-Chip Programming Control SWRST/ REBOOT - - - - FBOOTSL FPROGEN Mnemonic: CHPCON Address: BFh - 8 - Revision A2

BIT NAME FUNCTION 7 W: SWRESET R: REBOOT When FBOOTSL and FPROGEN are set to, set this bit to to force the microcontroller to reset to the initial condition, just like power-on reset This action re-boots the microcontroller and starts normal operation Read this bit to determine whether or not a hardware reboot is in progress 6 2 - Reserved FBOOTSL Program Location Selection This bit should be set before entering ISP mode : The Loader Program is in the 64-KB AP Flash EPROM The 4-KB LD Flash EPROM is the destination for re-programming : The Loader Program is in the 4-KB memory bank The 64-KB AP Flash EPROM is the destination for re-programming FPROGEN FLASH EPROM Programming Enable : Enable in-system programming mode In this mode, erase, program and read operations are achieved during device enters idle state : Disable in-system programming mode The on-chip flash memory is read-only CHPCON has an unrestricted read access, however, the write access is protected by timed-access protection See the section of timed-access protection for more information External Interrupt Control PX3 EX3 IE3 IT3 PX2 EX2 IE2 IT2 Mnemonic: XICON Address: Ch BIT NAME FUNCTION 7 PX3 : Set the priority of external interrupt INT3 one level higher 6 EX3 : Enable external interrupt INT3 5 IE3 4 IT3 Interrupt INT3 flag This bit is set and cleared automatically by the hardware when the interrupt is detected and processed : INT3 is falling-edge triggered : INT3 is low-level triggered 3 PX2 : Set the priority of external interrupt INT2 one level higher 2 EX2 : Enable external interrupt INT2 IE2 IT2 Interrupt INT2 flag This bit is set and cleared automatically by the hardware when the interrupt is detected and processed : INT2 is falling-edge triggered : INT2 is low-level triggered - 9 - Revision A2

External Interrupt High Control PXH3 - - - PXH2 - - - Mnemonic: XICONH Address: Ch BIT NAME FUNCTION 7 PXH3 : Set the priority of external interrupt INT3 to the highest level 6-4 - Reserved 3 PXH2 : Set the priority of external interrupt INT2 to the highest level 2 - - Reserved Port 4 Control Register A P4FUN P4FUN P4CMP P4CMP P4FUN P4FUN P4CMP P4CMP Mnemonic: P4CONA Address: C2h BIT NAME FUNCTION 7, 6 5, 4 3, 2, P4FUN P4FUN P4CMP P4CMP P4FUN P4FUN P4CMP P4CMP P4 function control bits, similar to P43FUN and P43FUN below P4 address-comparator length control bits, similar to P43CMP and P43CMP below P4 function control bits, similar to P43FUN and P43FUN below P4 address-comparator length control bits, similar to P43CMP and P43CMP below Port 4 Control Register B P43FUN P43FUN P43CMP P43CMP P42FUN P42FUN P42CMP P42CMP Mnemonic: P4CONB Address: C3h - 2 - Revision A2

BIT NAME FUNCTION 7, 6 5, 4 3, 2, P43FUN P43FUN P43CMP P43CMP P42FUN P42FUN P42CMP P42CMP : Mode P43 is a general purpose I/O port, like Port : Mode P43 is a read-strobe signal for chip-select purposes The address range depends on SFR P43AH, P43AL, P43CMP and P43CMP : Mode 2 P43 is a write-strobe signal for chip-select purposes The address range depends on SFR P43AH, P43AL, P43CMP and P43CMP : Mode 3 P43 is a read/write-strobe signal for chip-select purposes The address range depends on SFR P43AH, P43AL, P43CMP, and P43CMP Chip-select signal address comparison: : Compare the full 6-bit address with P43AH and P43AL : Compare the 5 MSB of the 6-bit address with P43AH and P43AL : Compare the 4 MSB of the 6-bit address with P43AH and P43AL : Compare the 8 MSB of the 6-bit address with P43AH P42 function control bits, similar to P43FUN and P43FUN above P42 address-comparator length control bits, similar to P43CMP and P43CMP above F/W Flash Low Address Mnemonic: SFRAL Address: C4h F/W flash low byte address F/W Flash High Address Mnemonic: SFRAH Address: C5h F/W flash high byte address F/W Flash Data Mnemonic: SFRFD Address: C6h F/W flash data - 2 - Revision A2

F/W Flash Control WFWIN OEN CEN CTRL3 CTRL2 CTRL CTRL Mnemonic: SFRCN Address: C7h BIT NAME FUNCTION 7 - Reserved 6 WFWIN On-chip Flash EPROM bank select for in-system programming This bit should be defined by the loader program in ISP mode : 64-KB Flash EPROM is the destination for re-programming : 4-KB Flash EPROM is the destination for re-programming 5 OEN Flash EPROM output enable 4 CEN Flash EPROM chip enable 3 - CTRL[3:] Flash control signals Timer 2 Control TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2 Mnemonic: T2CON Address: C8h BIT NAME FUNCTION 7 TF2 6 EXF2 5 RCLK 4 TCLK Timer 2 overflow flag: If RCLK and TCLK are, this bit is set when Timer 2 overflows or when the count is equal to the value in the capture register in downcount mode This bit can also be set by software, and it can only be cleared by software Timer 2 External Flag: When Timer 2 is in either capture or auto-reload mode and DCEN is, a negative transition on the T2EX pin (P) and EXEN2= sets this flag This flag can also be set by software Once set, this flag generates a Timer-2 interrupt, if enabled, and it must be cleared by software Receive Clock Flag: Set this bit to force Timer 2 into baud-rate generator mode when receiving data on the serial port in modes or 3 = Timer 2 overflow is the time base = Timer overflow is the time base Transmit clock Flag: Set this bit to force Timer 2 into baud-rate generator mode when transmitting data on the serial port in modes or 3 = Timer 2 overflow is the time base = Timer overflow is the time base - 22 - Revision A2

Continued BIT NAME FUNCTION 3 EXEN2 2 TR2 C/T2 CP/RL2 Timer 2 External Enable: If Timer 2 is not in baud-rate generator mode (see RCLK and TCLK above), set this bit to allow a negative transition on the T2EX pin to capture/reload Timer 2 counter Timer 2 Run Control: = Enable Timer 2 = Disable Timer 2, which preserves the current value in TH2 and TL2 Counter/Timer select: = Timer 2 operates as a timer at a speed controlled by T2M (CKCON5) = Timer 2 counts negative edges on the T2EX pin Capture/Reload Select: If EXEN2 is set to, this bit determines whether the capture or auto-reload function is activated = auto-reload when timer 2 overflows or a falling edge is detected on T2EX = capture each falling edge is detected on T2EX If either RCLK or TCLK is set, this bit has no function, as Timer 2 runs in autoreload mode Timer 2 Mode - - - - - - T2OE DCEN Mnemonic: T2MOD Address: C9h BIT NAME FUNCTION 7~2 - Reserved T2OE Timer 2 Output Enable This bit enables/disables the Timer 2 clock-out function DCEN Down Count Enable: Setting DCEN to allows T2EX pin to control the direction that Timer 2 counts in 6-bit auto-reload mode Timer 2 Capture Low RCAP2L7 RCAP2L6 RCAP2L5 RCAP2L4 RCAP2L3 RCAP2L2 RCAP2L RCAP2L Mnemonic: RCAP2L Address: CAh RCAP2L Timer 2 Capture LSB: In capture mode, RCAP2L is used to capture the TL2 value In autoreload mode, RCAP2L is used as the LSB of the 6-bit reload value - 23 - Revision A2

Timer 2 Capture High RCAP2H7 RCAP2H6 RCAP2H5 RCAP2H4 RCAP2H3 RCAP2H2 RCAP2H RCAP2H Mnemonic: RCAP2H Address: CBh RCAP2H Timer 2 Capture HSB: In capture mode, RCAP2H is used to capture the TH2 value In autoreload mode, RCAP2H is used as the MSB of the 6-bit reload value Timer 2 Register Low TL27 TL26 TLH25 TL24 TL23 TL22 TL2 TL2 TL2 Timer 2 LSB Mnemonic: TL2 Address: CCh Timer 2 Register High TH27 TH26 TH25 TH24 TH23 TH22 TH2 TH2 TL2 Timer 2 MSB Mnemonic: TH2 Address: CDh Program Status Word CY AC F RS RS OV F P Mnemonic: PSW Address: Dh BIT NAME FUNCTION 7 CY 6 AC Carry flag: Set when an arithmetic operation results in a carry being generated from the ALU It is also used as the accumulator for bit operations Auxiliary carry: Set when the previous operation resulted in a carry from the high order nibble 5 F General purpose, user-defined flag 4 RS Register bank select bits: See below 3 RS Register bank select bits: See below 2 OV Overflow flag: Set when a carry was generated from the seventh bit but not from the eighth bit as a result of the previous operation, or vice-versa F General purpose, user-defined flag P Parity flag: Set and cleared by the hardware to indicate an odd or even number, respectively, of 's in the accumulator - 24 - Revision A2

RS-: Register bank select bits: RS RS REGISTER BANK ADDRESS -7h 8-Fh 2-7h 3 8-Fh PCA Counter Control Register CF CR - CCF4 CCF3 CCF2 CCF CCF Mnemonic: CCON Address: D8h PCA Counter Mode Register CIDL WDTE - - - CPS CPS ECF Mnemonic: CMOD Address: D9h PCA Module Register - ECOM CAPP CAPN MAT TOG PWM ECCF Mnemonic: CCAPM Address: DAh PCA Module Register - ECOM CAPP CAPN MAT TOG PWM ECCF Mnemonic: CCAPM Address: DBh PCA Module 2 Register - ECOM2 CAPP2 CAPN2 MAT2 TOG2 PWM2 ECCF2 Mnemonic: CCAPM2 Address: DCh PCA Module 3 Register - ECOM3 CAPP3 CAPN3 MAT3 TOG3 PWM3 ECCF3 Mnemonic: CCAPM3 Address: DDh - 25 - Revision A2

PCA Module 4 Register - ECOM4 CAPP4 CAPN4 MAT4 TOG4 PWM4 ECCF4 Mnemonic: CCAPM4 Address: DEh Clock Control Register - - T2M TM TM - - MD Mnemonic: CKCON Address: DFh BIT NAME FUNCTION 7 - Reserved 6 - Reserved 5 T2M 4 TM 3 TM 2 - Reserved - Reserved MD Timer 2 clock select: = Divide-by-6 clock = Divide-by-2 clock This bit has no effect if option bit 3 is set to to select 2 clocks / machine cycle Timer clock select: = Divide-by-6 clock = Divide-by-2 clock This bit has no effect if option bit 3 is set to to select 2 clocks / machine cycle Timer clock select: = Divide-by-6 clock = Divide-by-2 clock This bit has no effect if option bit 3 is set to to select 2 clocks / machine cycle Stretch MOVX select bits: This bit is used to select the stretch value for the MOVX instruction, which enables the microcontroller to access slower memory devices or peripherals transparently and without the need for external circuits The RD or WR strobe and all internal timings are stretched by the selected interval The default value is cycle For faster access, set the value to CKCON has an unrestricted read access, however, the write access is protected by timed-access protection See the section of timed-access protection for more information - 26 - Revision A2

Accumulator ACC7 ACC6 ACC5 ACC4 ACC3 ACC2 ACC ACC Mnemonic: ACC Address: Eh ACC7-: The A (or ACC) register is the standard 852 accumulator Port 4 - - - - P43/INT2 P42/INT3 P4 P4 Mnemonic: ACC Address: E8h P43-: Port 4 is a bi-directional I/O port with internal pull-ups BIT NAME FUNCTION 7 4 - Reserved 3 P43 Port 4 Data bit which outputs to pin P43 in mode, or external interrupt INT2 2 P42 Port 4 Data bit which outputs to pin P42 in mode, or external interrupt INT3 P4 Port 4 Data bit which outputs to pin P4 in mode P4 Port 4 Data bit which outputs to pin P4 in mode PCA Counter Low Register CL7 CL6 CL6 CL4 CL3 CL2 CL CL Mnemonic: CL Address: E9h PCA Module Compare/Capture Low Register CCAPL7 CCAPL6 CCAPL5 CCAPL4 CCAPL3 CCAPL2 CCAPL CCAPL Mnemonic: CCAPL Address: EAh PCA Module Compare/Capture Low Register CCAPL7 CCAPL6 CCAPL5 CCAPL4 CCAPL3 CCAPL2 CCAPL CCAPL Mnemonic: CCAPL Address: EBh - 27 - Revision A2

PCA Module 2 Compare/Capture Low Register CCAP2L7 CCAP2L6 CCAP2L5 CCAP2L4 CCAP2L3 CCAP2L2 CCAP2L CCAP2L Mnemonic: CCAP2L Address: ECh PCA Module 3 Compare/Capture Low Register CCAP3L7 CCAP3L6 CCAP3L5 CCAP3L4 CCAP3L3 CCAP3L2 CCAP3L CCAP3L Mnemonic: CCAP3L Address: EDh PCA Module 4 Compare/Capture Low Register CCAP4L7 CCAP4L6 CCAP4L5 CCAP4L4 CCAP4L3 CCAP4L2 CCAP4L CCAP4L Mnemonic: CCAP4L Address: EEh B Register B7 B6 B5 B4 B3 B2 B B Mnemonic: B Address: Fh B7-: The B register is the standard 852 register that serves as a second accumulator Chip Enable Register Mnemonic: CHPENR Address: F6h PCA Counter High Register CH7 CH6 CH6 CH4 CH3 CH2 CH CH Mnemonic: CH Address: F9h PCA Module Compare/Capture High Register CCAPH7 CCAPH6 CCAPH5 CCAPH4 CCAPH3 CCAPH2 CCAPH CCAPH Mnemonic: CCAPH Address: FAh - 28 - Revision A2

PCA Module Compare/Capture High Register CCAPH7 CCAPH6 CCAPH5 CCAPH4 CCAPH3 CCAPH2 CCAPH CCAPH Mnemonic: CCAPH Address: FBh PCA Module 2 Compare/Capture High Register CCAP2H7 CCAP2H6 CCAP2H5 CCAP2H4 CCAP2H3 CCAP2H2 CCAP2H CCAP2H Mnemonic: CCAP2H Address: FCh PCA Module 3 Compare/Capture High Register CCAP3H7 CCAP3H6 CCAP3H5 CCAP3H4 CCAP3H3 CCAP3H2 CCAP3H CCAP3H Mnemonic: CCAP3H Address: FDh PCA Module 4 Compare/Capture High Register CCAP4H7 CCAP4H6 CCAP4H5 CCAP4H4 CCAP4H3 CCAP4H2 CCAP4H CCAP4H Mnemonic: CCAP4H Address: FEh - 29 - Revision A2

7 PORT 4 AND BASE ADDRESS REGISTERS Port 4, address E8H, is a 4-bit, multi-purpose, programmable I/O port Each bit can be configured individually, and registers P4CONA and P4CONB contain the control bits that select the mode of each pin Each pin has four operating modes Mode : Bi-directional I/O port, like port P42 and P43 serve as external interrupts INT3 and INT2, if enabled Mode : Read-strobe signals synchronized with the RD signal at specified addresses These signals can be used as chip-select signals for external peripherals Mode 2: Write-strobe signals synchronized with the WR signal at specified addresses These signals can be used as chip-select signals for external peripherals Mode 3: Read/write-strobe signals synchronized with the RD or WR signal at specified addresses These signals can be used as chip-select signals for external peripherals In modes 3, the address range for chip-select signals depends on the contents of registers P4xAH and P4xAL, which contain the high-order byte and low-order byte, respectively, of the 6-bit address comparator for P4x This is illustrated in the following schematic READ WRITE P4 REGISTER P4x P4xCSINV DATA I/O RD_CS MUX 4-> WR_CS RD/WR_CS PIN P4x ADDRESS BUS EQUAL P4xFUN P4xFUN REGISTER P4xAL P4xAH REGISTER P4xCMP P4xCMP Bit Length Selectable comparator P4x INPUT DATA BUS Figure 7- For example, the following program sets up P4 as a write-strobe signal for I/O port addresses 234H 237H with positive polarity, while P4 P43 are used as general I/O ports - 3 - Revision A2

MOV P4AH, #2H MOV P4AL, #34H ; Base I/O address 234H for P4 MOV P4CONA, #B MOV P4CONB, #H MOV P2ECON, #H ; P4 is a write-strobe signal; address lines A and A are masked ; P4 P43 are general I/O ports ; Set P4SINV to to invert the P4 write-strobe to positive polarity Then, any instruction MOVX @DPTR, A (where DPTR is in 234H 237H) generates a positivepolarity, write-strobe signal on pin P4, while the instruction MOV P4, #XX puts bits 3 of data #XX on pins P43 P4-3 - Revision A2

8 INTERRUPTS This section provides more information about external interrupts INT2 and INT3 and provides an overview of interrupt priority levels and polling sequences 8 External Interrupts 2 and 3 The W78ERD2 offers two additional external interrupts, INT2 and INT3, similar to external interrupts INT and INT in the standard 8C52 These interrupts are configured by the XICON (External Interrupt Control) register, which is not a standard register in the 8C52 Its address is CH XICON is bit-addressable; for example, "SETB C2H" sets the EX2 bit of XICON 82 Interrupt Priority Each interrupt has one of four priority levels in the W78ERD2, as shown below Four-level interrupt priority IPHX PRIORITY BITS IPX INTERRUPT PRIORITY LEVEL Level (lowest priority) Level Level 2 Level 3 (highest priority) Interrupts with the same priority level are polled in the sequence indicated below Nine-source interrupt information INTERRUPT SOURCE POLLING SEQUENCE WITHIN PRIORITY LEVEL ENABLE REQUIRED SETTINGS INTERRUPT TYPE EDGE/LEVEL VECTOR ADDRESS External Interrupt (highest) IE TCON 3H Timer/Counter IE - BH External Interrupt 2 IE2 TCON2 3H Timer/Counter 3 IE3 - BH Programmable Counter Array 4 IE6-33H Serial Port 5 IE4-23H Timer/Counter 2 6 IE5-2BH External Interrupt 2 7 XICON2 XICON 3BH External Interrupt 3 8 (lowest) XICON6 XICON3 43H - 32 - Revision A2

9 PROGRAMMABLE TIMERS/COUNTERS The W78ERD2 has three 6-bit programmable timer/counters Time-Base Selection The W78ERD2 offers two speeds for the timer The timers can count at /2 of the clock, the same speed they have in the standard 85 family Alternatively, the timers can count at /6 of the clock, called turbo mode The speed is controlled by bits TM, TM and T2M bits in CKCON The default value is zero, which selects /2 of the clock These 3 bits, TM, TM and T2M, have no effect if option bit 3 is set to to select 2 clocks / machine cycle 9 Timer and Timer Timers and each have a 6-bit timer/counter which consists of two eight-bit registers: Timer consists of TH (8 MSB) and TL (8 LSB), and Timer consists of TH and TL These timers/counters can be configured to operate either as timers, machine cycle counters or counters based on external inputs The "Timer" or "Counter" function itself is selected by the corresponding " C/ T " bit in the TMOD register: bit 2 for Timer and bit 6 for Timer In addition, each timer/counter can operate in one of four possible modes, which are selected by bits M and M in TMOD The rest of this section explains the time-base for the timers and then introduces each mode Mode In mode, the timer/counter is a 3-bit counter whose eight MSB are in THx and five LSB are the five lower bits in TLx The upper three bits in TLx are ignored Because THx and TLx are read separately, the timer/counter acts like an eight-bit counter with a five-bit, divide-by-32 pre-scale Counting is enabled only when TRx is set and either GATE = or INTx = What the timer/counter counts depends on C/ T When C/ T is set to, the timer/counter counts the negative edges of the clock according to the time-base selected by bits TxM in CKCON When C/ T is set to, it counts falling edges on T (P34, for Timer ) or T (P35, for Timer ) When the 3-bit counter reaches FFFh, the next count rolls over the timer/counter to h, and the timer overflow flag TFx (in TCON) is set If enabled, an interrupt occurs - 33 - Revision A2

osc TM = CKCON3 (TM = CKCON4) /6 C/T = TMOD2 (C/T = TMOD6) M,M = TMOD,TMOD (M,M = TMOD5,TMOD4) /2 4 7 7 T = P34 (T = P35) TL TH (TL) (TH) TR = TCON4 (TR = TCON6) Timer functions are shown in brackets GATE = TMOD3 (GATE = TMOD7) INT = P32 (INT = P33) TFx TF (TF) Interrupt Figure 9- Timer/Counter Mode & Mode Mode Mode is similar to mode, except that the timer/counter is 6-bit counter, not a 3-bit counter All the bits in THx and TLx are used Roll-over occurs when the timer moves from FFFFh to h Mode 2 Mode 2 is similar to mode, except that TLx acts like an eight-bit counter and THx holds the autoreload value for TLx When the TLx register overflows from FFh to h, the timer overflow flag TFx bit (in TCON) is set, TLx is reloaded with the contents of THx, and the counting process continues The reload operation does not affect the THx register osc T = P34 (T = P35) TR = TCON4 (TR = TCON6) TM = CKCON3 (TM = CKCON4) /6 /2 C/T = TMOD2 (C/T = TMOD6) Timer functions are shown in brackets TL (TL) 7 TFx TF (TF) Interrupt GATE = TMOD3 (GATE = TMOD7) INT = P32 (INT = P33) TH (TH) 7 Figure 9-2 Timer/Counter Mode 2-34 - Revision A2

Mode 3 Mode 3 is used when an extra eight-bit timer is needed, and it has different effects on Timer and Timer Timer separates TL and TH into two separate eight-bit count registers TL uses the Timer control bits C/ T, GATE, TR, INT and TF and can count clock cycles (clock / 2 or clock / 6) or falling edges on pin T Meanwhile, TH takes over TR and TF from Timer and can count clock cycles (clock / 2 or clock / 6) Mode 3 simply freezes Timer, which provides a way to turn it on and off When Timer is in mode 3, Timer can still be used in modes, and 2, but its flexibility is limited Timer can still be used as a timer / counter (or a baud-rate generator for the serial port) and retains the use of GATE and INT pin, but it no longer has control over the overflow flag TF and enable bit TR osc T = P34 /6 /2 TM = CKCON3 C/T = TMOD2 TL 7 TF Interrupt TR = TCON4 GATE = TMOD3 INT = P32 TH TR = TCON6 7 TF Interrupt Figure 9-3 Timer/Counter Mode 3 92 Timer/Counter 2 Timer 2 is a 6-bit up/down counter equipped with a capture/reload capability It is configured by the T2MOD register and controlled by the T2CON register As with Timers and, Timer 2 can count clock cycles (fosc / 2 or fosc / 6) or the external T2 pin, as selected by C/ T2, and there are four operating modes, each discussed below Capture Mode Capture mode is enabled by setting the CP/ RL2 bit in the T2CON register In capture mode, Timer 2 serves as a 6-bit up-counter When the counter rolls over from FFFFh to h, the TF2 bit is set, and, if enabled, an interrupt is generated If the EXEN2 bit is set, then a negative transition on the T2EX pin captures the value in TL2 and TH2 registers in the RCAP2L and RCAP2H registers This action also causes the EXF2 bit in T2CON to be set, which may also generate an interrupt - 35 - Revision A2

RCLK+TCLK=, CP/ RL2 =T2CON= osc T2 = P /6 /2 T2M = CKCON5 C/T2 = T2CON TL2 TH2 T2CON7 TF2 TR2 = T2CON2 T2EX = P RCAP2L RCAP2H Timer 2 Interrupt EXEN2 = T2CON3 EXF2 T2CON6 Auto-reload Mode, Counting up Figure 9-4 6-Bit Capture Mode This mode is enabled by clearing the CP/ RL2 bit in T2CON and the DCEN bit in T2MOD In this mode, Timer 2 is a 6-bit up-counter When the counter rolls over from FFFFh to h, the contents of RCAP2L and RCAP2H are automatically reloaded into TL2 and TH2, and the timer overflow bit TF2 is set If the EXEN2 bit is set, then a negative transition of T2EX pin also causes a reload, which also sets the EXF2 bit in T2CON RCLK+TCLK=, CP/ RL2 =T2CON=, DCEN= osc T2 = P /6 /2 T2M = CKCON5 C/T2 = T2CON TL2 TH2 T2CON7 TF2 TR2 = T2CON2 T2EX = P RCAP2L RCAP2 H Timer 2 Interrupt EXEN2 = T2CON3 EXF2 T2CON6 Auto-reload Mode, Counting Up/Down Figure 9-5 6-Bit Auto-reload Mode, Counting Up This mode is enabled when the CP/ RL2 bit in T2CON is clear and the DCEN bit in T2MOD is set In this mode, Timer 2 is an up/down-counter whose direction is controlled by the T2EX pin ( = up, = down) When Timer 2 overflows while counting up, the counter is reloaded by RCAP2L and RCAP2H When Timer 2 is counting down, the counter is reloaded with FFFFh when Timer 2 is equal to RCAP2L and RCAP2H In either case, the timer overflow bit TF2 is set, and the EXF2 bit is toggled, though EXF2 can not generate an interrupt in this mode - 36 - Revision A2

RCLK+TCLK=, CP/ RL2 =T2CON=, DCEN= Down Counting Reload Value FFh FFh osc T2 = P /6 /2 T2M = CKCON5 C/T = T2CON TL2 TH2 T2CON7 TF2 Timer 2 Interrupt TR2 = T2CON2 T2EX = P RCAP2L RCAP2H Up Counting Reload Value Figure 9-6 6-Bit Auto-reload Up/Down Counter EXF2 T2CON6 Baud Rate Generator Mode Baud-rate generator mode is enabled by setting either the RCLK or TCLK bits in T2CON register In baud-rate generator mode, Timer 2 is a 6-bit up-counter that automatically reloads when it overflows, but this overflow does not set the timer overflow bit TF2 If EXEN2 is set, then a negative transition on the T2EX pin sets EXF2 bit in T2CON and, if enabled, generates an interrupt request RCLK+TCLK= osc T2 = P C/T = T2CON TL2 TH2 Timer 2 overflow TR2 = T2CON2 T2EX = P RCAP2L RCAP2H EXEN2 = T2CON3 EXF2 T2CON6 Timer 2 Interrupt Figure 9-7 Baud Rate Generator Mode - 37 - Revision A2

ENHANCED FULL DUPLEX SERIAL PORT The W78ERD2 serial port is a full-duplex port, and the W78ERD2 provides additional features such as frame-error detection and automatic address recognition The serial port runs in one of four operating modes Serial Ports Modes SM SM MODE TYPE BAUD CLOCK FRAME SIZE START BIT STOP BIT 9TH BIT FUNCTION Synch 2 TCLKS 8 bits No No None Asynch Timer or 2 bits None 2 Asynch 32 or 64 TCLKS bits, 3 Asynch Timer or 2 bits, In synchronous mode (mode ), the W78ERD2 generates the clock and operates in a half-duplex mode In asynchronous modes (modes 3), full-duplex operation is available so that the serial port can simultaneously transmit and receive data In any mode, register SBUF functions as both the transmit register and the receive buffer Any write to SBUF writes to the transmit register, while any read from SBUF reads from the receive buffer The rest of this section discusses each operating mode and then discusses frame-error detection and automatic address recognition MODE Mode is a half-duplex, synchronous mode RxD transmits and receives serial data, and TxD transmits the shift clock The TxD clock is provided by the W78ERD2 Eight bits are transmitted or received per frame, LSB first The baud rate is fixed at /2 of the oscillator frequency The functional block diagram is shown below RI REN osc 2 RXD P3 Alternate Iutput function Write to SBUF TX START TX CLOCK SERIAL CONTROLLE RX CLOCK RX START Internal Data Bus TX SHIFT TI RI SHIFT CLOCK LOAD SBUF RX SHIFT CLOCK SIN PARIN LOAD CLOCK Transmit Shift Register PAROUT SOUT Receive Shift Register SBUF RXD P3 Alternate Output Function Serial Port Interrupt TXD P3 Alternate Output function Read SBUF SBUF Internal Data Bus Figure - Serial Port Mode - 38 - Revision A2

As mentioned before, data enters and leaves the serial port on RxD TxD line provides the shift clock, which shifts data into and out of the W78ERD2 and the device at the other end of the line Any instruction that writes to SBUF starts the transmission The shift clock is activated, and the data is shifted out on the RxD pin until all eight bits are transmitted If SM2 is set to, the data appears on RxD one clock period before the falling edge on TxD, and the TxD clock then remains low for two clock periods before going high again If SM2 is set to, the data appears on RxD three clock periods before the falling edge on TxD, and the TxD clock then remains low for six clock periods before going high again This ensures that the receiving device can clock RxD data on the rising edge of TxD or when the TxD clock is low Finally, the TI flag is set high in C once the last bit has been transmitted The serial port receives data when REN is and RI is zero The TxD clock is activated, and the serial port latches data on the rising edge of the shift clock As a result, the external device should present data on the falling edge of TxD This process continues until all eight bits have been received Then, after the last rising edge on TxD, the RI flag is set high in C, which stops reception until RI is cleared by the software 2 MODE Mode is a full duplex, asynchronous mode Serial communication frames are made up of ten bits transmitted on TXD and received on RXD The ten bits consist of a start bit (), eight data bits (LSB first), and a stop bit () When the W78ERD2 receives data, the stop bit goes into RB8 in SCON The baud rate is either /6 or /32 of the Timer overflow, which can be set to a variety of reload values (The /6 or /32 factor is determined by the SMOD bit in PCON SFR) The functional diagram is shown below Timer Overflow 2 SMOD = Timer 2 Overflow Write to SBUF Internal Data Bus Transmit Shift Register STOP PARIN START LOAD CLOCK SOUT TXD TCLK 6 TX START TX CLOCK TX SHIFT TI RCLK 6 SERIAL CONTROLLER RI Serial Port Interrupt SAMPLE -TO- DETECTOR RX CLOCK RX START LOAD SBUF RX SHIFT Read SBUF RXD BIT DETECTOR CLOCK PAROUT SIN D8 Receive Shift Register SBUF RB8 Internal Data Bus Figure -2 Serial Port Mode - 39 - Revision A2