T89C51CC01_03 ATMEL | Alldatasheet

Document overview

  • Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
  • PDF pages: 160

Technical content

Features

 80C51 Core Architecture  256 Bytes of On-chip RAM  1K Bytes of On-chip XRAM  32K Bytes of On-chip Flash Memory – Data Retention: 10 Years at 85°C Erase/Write Cycle: 100K  2K Bytes of On-chip Flash for Bootloader  2K Bytes of On-chip EEPROM Erase/Write Cycle: 100K  14-sources 4-level Interrupts  Three 16-bit Timers/Counters  Full Duplex UART Compatible 80C51  Maximum Crystal Frequency 40 MHz, in X2 Mode, 20 MHz (CPU Core, 20 MHz)  Five Ports: 32 + 2 Digital I/O Lines  Five-channel 16-bit PCA with: – PWM (8-bit) – High-speed Output – Timer and Edge Capture  Double Data Pointer  21-bit Watchdog Timer (7 Programmable Bits)  A 10-bit Resolution Analog to Digital Converter (ADC) with 8 Multiplexed Inputs  Full CAN Controller: – Fully Compliant with CAN Rev2.0A and 2.0B – Optimized Structure for Communication Management (Via SFR) – 15 Independent Message Objects: Each Message Object Programmable on Transmission or Reception Individual Tag and Mask Filters up to 29-bit Identifier/Channel 8-byte Cyclic Data Register (FIFO)/Message Object 16-bit Status and Control Register/Message Object 16-bit Time-Stamping Register/Message Object CAN Specification 2.0 Part A or 2.0 Part B Programmable for Each Message Object Access to Message Object Control and Data Registers Via SFR Programmable Reception Buffer Length Up To 15 Message Objects Priority Management of Reception of Hits on Several Message Objects at the Same Time (Basic CAN Feature) Priority Management for Transmission Message Object Overrun Interrupt – Supports: Time Triggered Communication Autobaud and Listening Mode Programmable Automatic Reply Mode – 1-Mbit/s Maximum Transfer Rate at 8 MHz (1) Crystal Frequency in X2 Mode – Readable Error Counters – Programmable Link to On-chip Timer for Time Stamping and Network Synchronization – Independent Baud Rate Prescaler – Data, Remote, Error and Overload Frame Handling  On-chip Emulation Logic (Enhanced Hook System)  Power Saving Modes: – Idle Mode – Power-down Mode  Power Supply: 3V to 5.5V  Temperature Range: Industrial (-40° to +85°C)  Packages: VQFP44, PLCC44, CA-BGA64 1. At BRP = 1 sampling point will be fixed. Enhanced 8-bit Microcontroller with CAN Controller and Flash Memory T89C51CC01

2 T89C51CC01

4129G–CAN–05/03 Description The T89C51CC01 is the first member of the CANary TM family of 8-bit microcontrollers dedicated to CAN network applications. In X2 mode a maximum external clock rate of 20 MHz reaches a 300 ns cycle time. Besides the full CAN controller T89C51CC01 provides 32K Bytes of Flash memory including In-System-Programming (ISP), 2K Bytes Boot Flash Memory, 2K Bytes EEPROM and 1.2-Kbyte RAM. Special attention is paid to the reduction of the electro-magnetic emission of T89C51CC01. Block Diagram Notes: 1. 8 analog Inputs/8 Digital I/O 2. 2-Bit I/O Port Timer 0 INT RAM 256x8 RxD TxD WR RD EA PSEN ALE XTAL2 XTAL1 UART CPU Timer 1 INT1 CtrlINT0 C51 CORE Port 0 Port 1 Port 2 Port 3 Parallel I/O Ports and Ext. Bus P1(1) XRAM 1kx8 IB-bus PCA RESET Watch Dog PCA ECI Vss Vcc Timer 2 T2EX Port 4 P4(2) 10 bit ADC Flash 32kx Boot loader 2kx8 EE PROM 2kx8 CAN CONTROLLER TxDC RxDC VAREF VAVCC VAGND

4129G–CAN–05/03 Pin Configuration PLCC44 P1.3/AN3/CEX0 P1.2/AN2/ECI P1.1/AN1/T2EX P1.0/AN 0/T2 VAREF VAGND RESET VSS VCC XTAL1 XTAL2 P3.7/RD P4.0/ TxDC P4.1/RxDC P2.7/A15 P2.6/A14 P2.5/A13 P2.4/A12 P2.3/A11 P2.2/A10 P2.1/A9 P3.6/WR ALE PSEN P0.7/AD7 P0.6/AD6 P0.5/AD5 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.1/AD1 P0.0/AD0 P2.0/A8 P1.4/AN4/CEX1 P1.5/AN5/CEX2 P1.6/AN6/CEX3 P1.7/AN7/CEX4 EA P3.0/RxD P3.1/TxD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 43 42 41 40 3944 38 37 36 35 34 12 13 17 161514 20 1918 21 22 VQFP44 P1.4/AN4/CEX1 P1.5/AN5/CEX2 P1.6/AN6/CEX3 P1.7/AN7/CEX4 EA P3.0/RxD P3.1/TxD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 ALE PSEN P0.7/AD7 P0.6/AD6 P0.5/AD5 P0.2 /AD2 P0.3 /AD3 P0.4 /AD4 P0.1 /AD1 P0.0 /AD0 P2.0/A8 P1.3/AN3/CEX0 P1.2/AN2/ECI P1.1/AN1/T2EX P1.0/AN 0/T2 VAREF VAGND RESET VSS VCC XTAL1 XTAL2 P3.7/RD P4.0/TxDC P4.1/RxDC P2.7/A15 P2.6/A14 P2.5/A13 P2.4/A12 P2.3/A11 P2.2/A10 P2.1/A9 P3.6/WR

4 T89C51CC01

4129G–CAN–05/03 CA-BGA64 Top View P1.2/AN2P1.4/AN4 P1.0/AN0 P1.3/AN3P1.5/AN5 P1.1/AN1 NCP1.6/AN6 NCP1.7/AN7 EA NC NC NC RESET NC P0.6 P0.5 P0.7PSENNCNC VDD VSSVAGND VAREF VDD VSS XTAL1 NC ALE XTAL2 P3.0 P3.2 P3.4 P3.5 P3.1 P3.3 NC NC P4.0 P2.7P3.7P3.6 P2.6 P4.1 NC NC NC NC P2.4 P2.5 P2.3 P2.1 P2.0 P2.2 NC P0.0 NC P0.1 P0.3 NC P0.2 P0.4 21 3 45 67 8 C B A D E F G H

Table 1. Pin Description and Data Memory. In this application it uses strong internal pull-ups when emitting 1 ’s. Port 0 also outputs the code Bytes during program validation. External pull-ups are required during program verification. inputs via the ADCCF register (in this case the internal pull-ups are disconnected). External clock input for Timer/counter2. Trigger input for Timer/counter2. PCA module 0 Entry of input/PWM output. PCA module 1 Entry of input/PWM output. PCA module 2 Entry of input/PWM output. PCA module 3 Entry of input/PWM output. PCA module 4 Entry ot input/PWM output. Port 1 receives the low-order address byte during EPROM programming and program verification. It can drive CMOS inputs without external pull-ups. Memory that use 8 bit addresses (MOVX @Ri), Port 2 transmits the contents of the P2 special function register. It also receives high-order addresses and control signals during program validation. It can drive CMOS inputs without external pull-ups.

6 T89C51CC01

source of current (IIL, see section "Electrical Characteristic") because of the internal pull-ups. External Data Memory read strobe; Enables the external data memory. It can drive CMOS inputs without external pull-ups. current (IIL, on the datasheet) because of the internal pull-up transistor. Receiver input of CAN controller. It can drive CMOS inputs without external pull-ups. Table 1. Pin Description (Continued)

independently programmed as input or output. I/O or for its alternate input output function. ister (x = 1,3 or 4). To use a pin for general-purpose input, set the bit in the Px register. This turns off the output FET drive. resistor to VSS permits power-on reset using only an external capacitor to VCC. executed from an internal Flash (EA = 1), ALE generation can be disabled by the software. memory. The PSEN is not activated for internal fetches. less then 8000H. When held at the low level,T89C51CC01 fetches all instructions from the external program memory . Input of the inverting oscillator amplifier and input of the internal clock generator circuits. above a frequency of 16 MHz, a duty cycle of 50% should be maintained. Output from the inverting oscillator amplifier.

8 T89C51CC01

Figure 1. Port 1, Port 3 and Port 4 Structure Note: The internal pull-up can be disabled on P1 when analog function is selected. shows the structure of Port 2. An external source can pull a Port 2 pin low. turn off the output driver FET. Figure 2. Port 0 Structure

  1. Port 0 internal strong pull-ups assist the logic-one output for memory bus cycles only.

Except for these bus cycles, the pull-up FET is off, Port 0 outputs are open-drain.

Figure 3. Port 2 Structure

  1. Port 2 internal strong pull-ups FET (P1 in FiGURE) assist the logic-one output for

switches the output-driver input from the latch output to the internal address/data line. Table 2. Read-Modify-Write Instructions

10 T89C51CC01

It is not obvious the last three instructions in this list are Read-Modify-Write instructions. than the pins returns the correct logic-one value. to input conditions by a logical one written to the latch. vention. Current strengths are 1/10 that of pFET #3. Figure 4. Internal Pull-Up Configurations Note: Port 2 p1 assists the logic-one output for memory bus cycles.

Table 3. C51 Core SFRs Table 4. I/O Port SFRs Table 5. Timers SFRs

1 Modes GATE1 C/T1# M11 M01 GATE0 C/T0# M10 M00

12 T89C51CC01

Table 5. Timers SFRs (Continued) Table 6. Serial I/O Port SFRs Table 7. PCA SFRs

Table 7. PCA SFRs (Continued) Table 8. Interrupt SFRs Table 9. ADC SFRs Table 10. CAN SFRs

14 T89C51CC01

Table 10. CAN SFRs (Continued)

Table 11. Other SFRs

16 T89C51CC01

Note: 1. These registers are bit –addressable. whose address ends in 0 and 8. The bit addresses, in this area, are 0x80 through to 0xFF. Table 12. SFR Mapping

4129G–CAN–05/03 Clock The T89C51CC01 core needs only 6 clock periods per machine cycle. This feature, called ”X2”, provides the following advantages:  Divides frequency crystals by 2 (cheaper crystals) while keeping the same CPU power.  Saves power consumption while keeping the same CPU power (oscillator power saving).  Saves power consumption by dividing dynamic operating frequency by 2 in operating and idle modes.  Increases CPU power by 2 while keeping the same crystal frequency. In order to keep the original C51 compatibility, a divider-by-2 is inserted between the XTAL1 signal and the main clock input of the core (phase generator). This divider may be disabled by the software. An extra feature is available to start after Reset in the X2 mode. This feature can be enabled by a bit X2B in the Hardware Security Byte. This bit is described in the section "In-System-Programming". Description The X2 bit in the CKCON register (see Table 13) allows switching from 12 clock cycles per instruction to 6 clock cycles and vice versa. At reset, the standard speed is activated (STD mode). Setting this bit activates the X2 feature (X2 mode) for the CPU Clock only (see Figure 5.). The Timers 0, 1 and 2, Uart, PCA, Watchdog or CAN switch in X2 mode only if the cor- responding bit is cleared in the CKCON register. The clock for the whole circuit and peripheral is first divided by two before being used by the CPU core and peripherals. This allows any cyclic ratio to be accepted on the XTAL1 input. In X2 mode, as this divider is bypassed, the signals on XTAL1 must have a cyclic ratio between 40 to 60%. Figure 5. shows the clock generation block diagram. The X2 bit is validated on the XTAL1÷2 rising edge to avoid glitches when switching from the X2 to the STD mode. Figure 6 shows the mode switching waveforms.

18 T89C51CC01

Figure 5. Clock CPU Generation Diagram

Figure 6. Mode Switching Waveforms

20 T89C51CC01

4129G–CAN–05/03 Register Table 13. CKCON Register CKCON (S:8Fh) Clock Control Register Note: 1. This control bit is validated when the CPU clock bit X2 is set; when X2 is low, this bit has no effect. Reset Value = 0000 0000b 76543210 CANX2 WDX2 PCAX2 SIX2 T2X2 T1X2 T0X2 X2 Bit Number Bit Mnemonic Description 7C A N X 2 CAN clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 6W D X 2 Watchdog clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 5P C A X 2 Programmable Counter Array clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 4S I X 2 Enhanced UART clock (MODE 0 and 2) (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 3T 2 X 2 Timer 2 clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 2T 1 X 2 Timer 1 clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 1T 0 X 2 Timer 0 clock (1) Clear to select 6 clock periods per peripheral clock cycle. Set to select 12 clock periods per peripheral clock cycle. 0X 2 CPU clock Clear to select 12 clock periods per machine cycle (STD mode) for CPU and all the peripherals. Set to select 6 clock periods per machine cycle (X2 mode) and to enable the individual peripherals "X2"bits.

cally divided by 2 using the X2 Mode detailed in Section “Clock”. internal reset source such as a watchdog, PCA, timer, etc.  The level on xtal1 input must be outside the specification (VIH, VIL).  Oscillator startup time (oscrst). To determine the capacitor the highest value of these two parameters has to be chosen. The reset circuitry is shown in Figure 7. Figure 7. Reset Circuitry two values of oscillator start-up time and two pull-down resistor values. Table 14. Minimum Reset Capacitor for a 15k Pull-down Resistor discharged, leading to a bad reset sequence.

22 T89C51CC01

periods is mode independent (X2 or X1). tor must be added as shown Figure 8. Figure 8. Reset Circuitry for WDT reset out usage this bit allows mapping of the bootloader in the code area, a reset failure can be critical. (write or erase) may corrupt the Flash on-chip memory. supply failure, power supply switched off). status of the Port pins during Idle mode is detailed in Table 14. instruction that sets IDL bit is the last instruction executed. Note: If IDL bit and PD bit are set simultaneously, the T89C51CC01 enters Power-down mode. Then it does not go in Idle mode when exiting Power-down mode.

  1. Generate an enabled interrupt.

4129G–CAN–05/03 of the interrupt service routine, program execution resumes with the instruction immediately following the instruction that activated Idle mode. The general-purpose flags (GF1 and GF0 in PCON register) may be used to indicate whether an interrupt occurred during normal operation or during Idle mode. When Idle mode is exited by an interrupt, the interrupt service routine may examine GF1 and GF0. 2. Generate a reset. – A logic high on the RST pin clears IDL bit in PCON register directly and asynchronously. This restores the clock to the CPU. Program execution momentarily resumes with the instruction immediately following the instruction that activated the Idle mode and may continue for a number of clock cycles before the internal reset algorithm takes control. Reset initializes the T89C51CC01 and vectors the CPU to address C:0000h. Note: 1. During the time that execution resumes, the internal RAM cannot be accessed; how- ever, it is possible for the Port pins to be accessed. To avoid unexpected outputs at the Port pins, the instruction immediately following the instruction that activated Idle mode should not write to a Port pin or to the external RAM. 2. If Idle mode is invoked by ADC Idle, the ADC conversion completion will exit Idle. Power-down Mode The Power-down mode places the T89C51CC01 in a very low power state. Power-down mode stops the oscillator and freezes all clocks at known states. The CPU status prior to entering Power-down mode is preserved, i.e., the program counter, program status word register retain their data for the duration of Power-down mode. In addition, the SFRs and RAM contents are preserved. The status of the Port pins during Power-down mode is detailed in Table 14. Entering Power-down Mode To enter Power-down mode, set PD bit in PCON register. The T89C51CC01 enters the Power-down mode upon execution of the instruction that sets PD bit. The instruction that sets PD bit is the last instruction executed. Exiting Power-down Mode If VDD was reduced during the Power-down mode, do not exit Power-down mode until VDD is restored to the normal operating level. There are two ways to exit the Power-down mode: 1. Generate an enabled external interrupt. – The T89C51CC01 provides capability to exit from Power-down using INT0#, INT1#. Hardware clears PD bit in PCON register which starts the oscillator and restores the clocks to the CPU and peripherals. Using INTx# input, execution resumes when the input is released (see Figure 9) while using KINx input, execution resumes after counting 1024 clock ensuring the oscillator is restarted properly (see Figure 8). Execution resumes with the interrupt service routine. Upon completion of the interrupt service routine, program execution resumes with the instruction immediately following the instruction that activated Power-down mode. Note: 1. The external interrupt used to exit Power-down mode must be configured as level sensitive (INT0# and INT1#) and must be assigned the highest priority. In addition, the duration of the interrupt must be long enough to allow the oscillator to stabilize. The execution will only resume when the interrupt is deasserted. 2. Exit from power-down by external interrupt does not affect the SFRs nor the internal RAM content.

24 T89C51CC01

Figure 9. Power-down Exit Waveform Using INT1:0# Power-down mode should not write to a Port pin or to the external RAM.

  1. Exit from power-down by reset redefines all the SFRs, but does not affect the internal

4129G–CAN–05/03 Registers Table 15. PCON Register PCON (S:87h) – Power configuration Register Reset Value = 00X1 0000b 76543210 SMOD1 SMOD0 - POF GF1 GF0 PD IDL Bit Number Bit Mnemonic Description 7S M O D 1 Serial port Mode bit 1 Set to select double baud rate in mode 1, 2 or 3 6S M O D 0 Serial port Mode bit 0 Clear to select SM0 bit in SCON register. Set to select FE bit in SCON register. 5- Reserved The value read from this bit is indeterminate. Do not set this bit. 4P O F Power-Off Flag Clear to recognize next reset type. Set by hardware when Vcc rises from 0 to its nominal voltage. Can also be set by software. 3G F 1 General-purpose flag 1 One use is to indicate whether an interrupt occurred during normal operation or during Idle mode. 2G F 0 General-purpose flag 0 One use is to indicate whether an interrupt occurred during normal operation or during Idle mode. 1P D Power-down Mode bit Cleared by hardware when an interrupt or reset occurs. Set to activate the Power-down mode. If IDL and PD are both set, PD takes precedence. 0I D L Idle Mode bit Cleared by hardware when an interrupt or reset occurs. Set to activate the Idle mode. If IDL and PD are both set, PD takes precedence.

26 T89C51CC01

  1. The internal space mapped in three separate segments:

 the lower 128 Bytes RAM segment.  the upper 128 Bytes RAM segment.  the expanded 1024 Bytes RAM segment (XRAM). SFRs, (addresses 80h to FFh) accessible by direct addressing mode. Figure 11 shows the internal and external data memory spaces organization. Figure 10. Internal Memory - RAM Figure 11. Internal and External Data Memory Organization XRAM-XRAM

128 Bytes

ing, and can be used for context switching in interrupt service routines. Table 16. Register Bank Selection addresses in this area are 00h to 7Fh. Figure 12. Lower 128 Bytes Internal RAM Organization EXTRAM = 1, the XRAM is selected. must then be initialized properly.

4 Banks of

8 Registers

28 T89C51CC01

the bus control signals (RD, WR, and ALE). describes the external memory interface signals. Figure 13. External Data Memory Interface Structure Table 17. External Data Memory Interface Signals Figure 14), and write data (see Figure 15) in the external data memory. signals from 3 to 15 CPU clock periods. refer to the Section “AC Characteristics”.

30 T89C51CC01

and reducing code size in case of intensive usage of external memory accesses. Figure 16. Dual Data Pointer Implementation using one data pointer as a “source” pointer and the other one as a “destination” pointer. enhanced algorithm libraries.

Table 19. AUXR Register Carry out from bit 1 of ALU operands. Carry out from bit 1 of addition operands. Refer to Table 16 for bits description. Overflow set by arithmetic operations. Set when ACC contains an odd number of 1 ’s. Cleared when ACC contains an even number of 1 ’s. The value read from these bits are indeterminate. Do not set this bit. the RD/ and the WR/ pulse length is increased according to the value of M0. The value read from this bit is indeterminate. Do not set this bit.

32 T89C51CC01

Table 20. AUXR1 Register 0 - Internal XRAM access using MOVX @ Ri/@ DPTR. 1 - External data memory access. 1 - ALE is active only during a MOVX or MOVC instruction. The value read from these bits is indeterminate. Do not set these bits. Clear this bit for disable boot Flash. The value read from this bit is indeterminate. Do not set this bit. 1- Reserved for Data Pointer Extension. Set to select second dual data pointer: DPTR1. Clear to select first dual data pointer: DPTR0.

4129G–CAN–05/03 EEPROM Data Memory The 2-Kbyte on-chip EEPROM memory block is located at addresses 0000h to 07FFh of the XRAM/XRAM memory space and is selected by setting control bits in the EECON register. A read in the EEPROM memory is done with a MOVX instruction. A physical write in the EEPROM memory is done in two steps: write data in the column latches and transfer of all data latches into an EEPROM memory row (programming). The number of data written on the page may vary from 1 up to 128 Bytes (the page size). When programming, only the data written in the column latch is programmed and a ninth bit is used to obtain this feature. This provides the capability to program the whole memory by Bytes, by page or by a number of Bytes in a page. Indeed, each ninth bit is set when the writing the corresponding byte in a row and all these ninth bits are reset after the writing of the complete EEPROM row. Write Data in the Column Latches Data is written by byte to the column latches as for an external RAM memory. Out of the 11 address bits of the data pointer, the 4 MSBs are used for page selection (row) and 7 are used for byte selection. Between two EEPROM programming sessions, all the addresses in the column latches must stay on the same page, meaning that the 4 MSB must no be changed. The following procedure is used to write to the column latches:  Save and disable interrupt.  Set bit EEE of EECON register  Load DPTR with the address to write  Store A register with the data to be written  Execute a MOVX @DPTR, A  If needed loop the three last instructions until the end of a 128 Bytes page  Restore interrupt. Note: The last page address used when loading the column latch is the one used to select the page programming address. Programming The EEPROM programming consists of the following actions:  writing one or more Bytes of one page in the column latches. Normally, all Bytes must belong to the same page; if not, the last page address will be latched and the others discarded.  launching programming by writing the control sequence (50h followed by A0h) to the EECON register.  EEBUSY flag in EECON is then set by hardware to indicate that programming is in progress and that the EEPROM segment is not available for reading.  The end of programming is indicated by a hardware clear of the EEBUSY flag. Note: The sequence 5xh and Axh must be executed without instructions between then other- wise the programming is aborted. Read Data The following procedure is used to read the data stored in the EEPROM memory:  Save and disable interrupt  Set bit EEE of EECON register  Load DPTR with the address to read  Execute a MOVX A, @DPTR  Restore interrupt

34 T89C51CC01

4129G–CAN–05/03 ;* NAME: api_rd_eeprom_byte ;* DPTR contain address to read. ;* Acc contain the reading value ;* NOTE: before execute this function, be sure the EEPROM is not BUSY api_rd_eeprom_byte: ; Save and clear EA MOV EECON, #02h; map EEPROM in XRAM space MOVX A, @DPTR MOV EECON, #00h; unmap EEPROM ; Restore EA ret ;* NAME: api_ld_eeprom_cl ;* DPTR contain address to load ;* Acc contain value to load ;* NOTE: in this example we load only 1 byte, but it is possible upto ;* 128 Bytes. ;* before execute this function, be sure the EEPROM is not BUSY api_ld_eeprom_cl: ; Save and clear EA MOV EECON, #02h ; map EEPROM in XRAM space MOVX @DPTR, A MOVEECON, #00h; unmap EEPROM ; Restore EA ret ;* NAME: api_wr_eeprom ;* NOTE: before execute this function, be sure the EEPROM is not BUSY api_wr_eeprom: ; Save and clear EA MOV EECON, #050h MOV EECON, #0A0h ; Restore EA ret

4129G–CAN–05/03 Registers Table 21. EECON Register EECON (S:0D2h) EEPROM Control Register Reset Value = XXXX XX00b Not bit addressable 76543210 EEPL3 EEPL2 EEPL1 EEPL0 - - EEE EEBUSY Bit Number Bit Mnemonic Description 7-4 EEPL3-0 Programming Launch command bits Write 5Xh followed by AXh to EEPL to launch the programming. 3- Reserved The value read from this bit is indeterminate. Do not set this bit. 2- Reserved The value read from this bit is indeterminate. Do not set this bit. 1E E E Enable EEPROM Space bit Set to map the EEPROM space during MOVX instructions (Write in the column latches) Clear to map the XRAM space during MOVX. 0E E B U S Y Programming Busy flag Set by hardware when programming is in progress. Cleared by hardware when programming is done. Can not be set or cleared by software.

36 T89C51CC01

available using specific programming tool. Figure 17. Program/Code Memory Organization stant from this location does not affect Ports 0 and 2.

  1. Default factory programmed parts come with maximum hardware protection. Execu-

17.22 External Code Memory Access

the bus control signals (PSEN#, and ALE). describes the external memory interface signals. Figure 18. External Code Memory Interface Structure Figure 19) in the external program/code memory. mation on X2 mode see section “Clock “. form and do not provide precise timing information. For bus cycling parameters refer to the ‘AC-DC parameters’ section. Table 23. External Code Memory Interface Signals

38 T89C51CC01

Figure 19. External Code Fetch Waveforms 2K Bytes for boot loader and Application Programming Interfaces (API). mode is detailed in the "In-System-Programming" section. a set of API described in the "In-System-Programming" section. Figure 20. Flash Memory Architecture

4129G–CAN–05/03 FM0 Memory Architecture The Flash memory is made up of 4 blocks (see Figure 20):  The memory array (user space) 32K Bytes  The Extra Row  The Hardware security bits  The column latch registers User Space This space is composed of a 32K Bytes Flash memory organized in 256 pages of 128 Bytes. It contains the user’s application code. Extra Row (XRow) This row is a part of FM0 and has a size of 128 Bytes. The extra row may contain infor- mation for boot loader usage. Hardware Security Byte The Hardware security Byte space is a part of FM0 and has a size of 1 byte. The 4 MSB can be read/written by software, the 4 LSB can only be read by software and written by hardware in parallel mode. Column Latches The column latches, also part of FM0, have a size of full page (128 Bytes). The column latches are the entrance buffers of the three previous memory locations (user array, XROW and Hardware security byte). Cross Flash Memory Access

Description

The FM0 memory can be program only from FM1. Programming FM0 from FM0 or from external memory is impossible. The FM1 memory can be program only by parallel programming. The Table 24 show all software Flash access allowed. Table 24. Cross Flash Memory Access

40 T89C51CC01

page while bits 14 to 7 are used to select the programming address of the page. Setting FPS bit takes precedence on the EXTRAM bit in AUXR register. dance with Table 25. A MOVC instruction is then used for reading these spaces. Table 25. FM0 Blocks Select Bits spaces to program according to FMOD1:0 bits.

11 R e s e r v e d

Table 26. Programming Spaces otherwise the programming is aborted.

  1. Interrupts that may occur during programming time must be disabled to avoid any

spurious exit of the programming mode. Status of the Flash Memory The bit FBUSY in FCON register is used to indicate the status of programming. FBUSY is set when programming is in progress. Selecting FM1 The bit ENBOOT in AUXR1 register is used to map FM1 from F800h to FFFFh.  Save then disable interrupt and map the column latch space by setting FPS bit.  Load the DPTR with the address to load.  Load Accumulator register with the data to load.  Execute the MOVX @DPTR, A instruction.  If needed loop the three last instructions until the page is completely loaded.

5 X 0 0 No action

5 X 0 1 No action

5 X 1 0 No action

5 X 1 1 No action

42 T89C51CC01

Figure 21. Column Latches Loading Procedure  Load up to one page of data in the column latches from address 0000h to 7FFFh.  Save then disable the interrupts. FCON register (only from FM1). The end of the programming indicated by the FBUSY flag cleared.  Load data in the column latches from address FF80h to FFFFh.  Save then disable the interrupts. the programming indicated by the FBUSY flag cleared. The end of the programming indicated by the FBUSY flag cleared.

Figure 22. Flash and Extra Row Programming Procedure  Save and disable the interrupts.  Load DPTR at address 0000h.  Load Accumulator register with the data to load.  Execute the MOVX @DPTR, A instruction. the programming indicated by the FBUSY flag cleared. The end of the programming indicated by the FBusy flag cleared.

44 T89C51CC01

Figure 23. Hardware Programming Procedure the address of the code byte to read. Note: FCON is supposed to be reset when not needed.  Map the Extra Row space by writing 02h in FCON register.  Clear FCON to unmap the Extra Row.  Map the Hardware Security space by writing 04h in FCON register.  Clear FCON to unmap the Hardware Security Byte.

Figure 24. Reading Procedure Note: 1. aa = 10 for the Hardware Security Byte. chip code and data located in FM0 and FM1. Table 27. Program Lock bit Preventing Flash Corruption See the “Power Management” section. external program memory returns non coded data. on reset, and further parallel programming of the Flash is disabled.

46 T89C51CC01

4129G–CAN–05/03 Registers FCON RegisterFCON (S:D1h) Flash Control Register Reset Value = 0000 0000b 76543210 FPL3 FPL2 FPL1 FPL0 FPS FMOD1 FMOD0 FBUSY Bit Number Bit Mnemonic Description 7-4 FPL3:0 Programming Launch Command Bits Write 5Xh followed by AXh to launch the programming according to FMOD1:0 (see Table 26) 3F P S Flash Map Program Space Set to map the column latch space in the data memory space. Clear to re-map the data memory space. 2-1 FMOD1:0 Flash Mode See Table 25 or Table 26. 0F B U S Y Flash Busy Set by hardware when programming is in progress. Clear by hardware when programming is done. Can not be changed by software.

can be ordered with CAN bootloader or UART bootloader). Note: 1. The user can also program his own bootloader in FM1. This allow the customer to have a full use of the 32-Kbyte user memory. bootloader located in FM0 at [SBV]00h.  A further method exists in activating the Atmel boot loader by hardware activation. See Section “Hardware Security Byte”.  The FM0 can be programmed also by the parallel mode using a programmer. Figure 25. Flash Memory Mapping

48 T89C51CC01

4129G–CAN–05/03 Boot Process Software Boot Process Example Many algorithms can be used for the software boot process. Below are descriptions of the different flags and Bytes. Boot Loader Jump Bit (BLJB): - This bit indicates if on RESET the user wants to jump to this application at address @0000h on FM0 or execute the boot loader at address @F800h on FM1. - BLJB = 0 (i.e. bootloader FM1 executed after a reset) is the default Atmel factory pro- gramming. - To read or modify this bit, the APIs are used. Boot Vector Address (SBV): - This byte contains the MSB of the user boot loader address in FM0. - The default value of SBV is FFh (no user boot loader in FM0). - To read or modify this byte, the APIs are used. Extra Byte (EB) and Boot Status Byte (BSB): - These Bytes are reserved for customer use. - To read or modify these Bytes, the APIs are used. Hardware Boot Process At the falling edge of RESET, the bit ENBOOT in AUXR1 register is initialized with the value of Boot Loader Jump Bit (BLJB). Further at the falling edge of RESET if the following conditions (called Hardware condi- tion) are detected. The FCON register is initialized with the value 00h and the PC is initialized with F800h (FM1 lower byte = Bootloader entry point). Harware Conditions:  PSEN low (1)  EA high,  ALE high (or not connected). The Hardware condition forces the bootloader to be executed, whatever BLJB value is. Then BLBJ will be checked. If no hardware condition is detected, the FCON register is initialized with the value F0h. Then BLJB value will be checked. Conditions are:  If bit BLJB = 1: User application in FM0 will be started at @0000h (standard reset).  If bit BLJB = 0: Boot loader will be started at @F800h in FM1. Note: 1. As PSEN is an output port in normal operating mode (running user applications or bootloader applications) after reset it is recommended to release PSEN after the fall- ing edge of Reset is signaled. The hardware conditions are sampled at reset signal Falling Edge, thus they can be released at any time when reset input is low.

Figure 26. Hardware Boot Process Algorithm is initialized with BLJB inverted.

50 T89C51CC01

4129G–CAN–05/03 Hardware Security Byte Table 29. Hardware Security Byte Default value after erasing chip: FFh Notes: 1. Only the 4 MSB bits can be accessed by software. 2. The 4 LSB bits can only be accessed by parallel mode. 76543210 X2B BLJB - - - LB2 LB1 LB0 Bit Number Bit Mnemonic Description 7X 2 B X2 Bit Set this bit to start in standard mode. Clear this bit to start in X2 mode. 6B L J B Boot Loader JumpBit - 1: To start the user’s application on next RESET (@0000h) located in FM0, - 0: To start the boot loader(@F800h) located in FM1. 5-3 - Reserved The value read from these bits are indeterminate. 2-0 LB2:0 Lock Bits

52 T89C51CC01

Figure 29. UART Timing in Mode 1 Figure 30. UART Timing in Modes 2 and 3 nication feature is enabled (SM2 bit in SCON register is set). the CPU is not interrupted by command frames addressed to other devices. be enabled in mode 0 (i.e. setting SM2 bit in SCON register in mode 0 has no effect).

4129G–CAN–05/03 Given Address Each device has an individual address that is specified in the SADDR register; the SADEN register is a mask byte that contains don ’t-care bits (defined by zeros) to form the device’s given address. The don ’t-care bits provide the flexibility to address one or more slaves at a time. The following example illustrates how a given address is formed. To address a device by its individual address, the SADEN mask byte must be 1111 1111b. For example: SADDR0101 0110b SADEN1111 1100b Given0101 01XXb Here is an example of how to use given addresses to address different slaves: Slave A:SADDR1111 0001b SADEN1111 1010b Given1111 0X0Xb Slave B:SADDR1111 0011b SADEN1111 1001b Given1111 0XX1b Slave C:SADDR1111 0010b SADEN1111 1101b Given1111 00X1b The SADEN byte is selected so that each slave may be addressed separately. For slave A, bit 0 (the LSB) is a don ’t-care bit; for slaves B and C, bit 0 is a 1. To com- municate with slave A only, the master must send an address where bit 0 is clear (e.g. 1111 0000b). For slave A, bit 1 is a 0; for slaves B and C, bit 1 is a don’t care bit. To communicate with slaves A and B, but not slave C, the master must send an address with bits 0 and 1 both set (e.g. 1111 0011b). To communicate with slaves A, B and C, the master must send an address with bit 0 set, bit 1 clear, and bit 2 clear (e.g. 1111 0001b). Broadcast Address A broadcast address is formed from the logical OR of the SADDR and SADEN registers with zeros defined as don’t-care bits, e.g.: SADDR 0101 0110b SADEN 1111 1100b SADDR OR SADEN1111 111Xb The use of don’t-care bits provides flexibility in defining the broadcast address, however in most applications, a broadcast address is FFh. The following is an example of using broadcast addresses: Slave A:SADDR1111 0001b SADEN1111 1010b Given1111 1X11b, Slave B:SADDR1111 0011b SADEN1111 1001b Given1111 1X11B, Slave C:SADDR=1111 0010b SADEN1111 1101b Given1111 1111b

54 T89C51CC01

and B, but not slave C, the master can send and address FBh. Clear to reset the error state, not cleared by a valid stop bit. Set by hardware when an invalid stop bit is detected. Refer to SM1 for serial port mode selection. Clear to disable multiprocessor communication feature. Set to enable multiprocessor communication feature in mode 2 and 3. Clear to disable serial reception. Set to enable serial reception. Clear to transmit a logic 0 in the 9th bit. Set to transmit a logic 1 in the 9th bit. Cleared by hardware if 9th bit received is a logic 0. Set by hardware if 9th bit received is a logic 1. Clear to acknowledge interrupt. stop bit in the other modes. Clear to acknowledge interrupt. Figure 30. in the other modes.

Table 31. SADEN Register Table 32. SADDR Register Table 33. SBUF Register

56 T89C51CC01

Table 34. PCON Register Set to select double baud rate in mode 1, 2 or 3. Clear to select SM0 bit in SCON register. Set to select FE bit in SCON register. The value read from this bit is indeterminate. Do not set this bit. Clear to recognize next reset type. Cleared by user for general-purpose usage. Set by user for general-purpose usage. Cleared by user for general-purpose usage. Set by user for general-purpose usage. Cleared by hardware when reset occurs. Set to enter power-down mode. Clear by hardware when interrupt or reset occurs.

4129G–CAN–05/03 Timers/Counters The T89C51CC01 implements two general-purpose, 16-bit Timers/Counters. Such are identified as Timer 0 and Timer 1, and can be independently configured to operate in a variety of modes as a Timer or an event Counter. When operating as a Timer, the Timer/Counter runs for a programmed length of time, then issues an interrupt request. When operating as a Counter, the Timer/Counter counts negative transitions on an external pin. After a preset number of counts, the Counter issues an interrupt request. The various operating modes of each Timer/Counter are described in the following sections. Timer/Counter Operations A basic operation is Timer registers THx and TLx (x = 0, 1) connected in cascade to form a 16-bit Timer. Setting the run control bit (TRx) in TCON register (see Figure 35) turns the Timer on by allowing the selected input to increment TLx. When TLx overflows it increments THx; when THx overflows it sets the Timer overflow flag (TFx) in TCON register. Setting the TRx does not clear the THx and TLx Timer registers. Timer regis- ters can be accessed to obtain the current count or to enter preset values. They can be read at any time but TRx bit must be cleared to preset their values, otherwise the behav- ior of the Timer/Counter is unpredictable. The C/Tx# control bit selects Timer operation or Counter operation by selecting the divided-down peripheral clock or external pin Tx as the source for the counted signal. TRx bit must be cleared when changing the mode of operation, otherwise the behavior of the Timer/Counter is unpredictable. For Timer operation (C/Tx# = 0), the Timer register counts the divided-down peripheral clock. The Timer register is incremented once every peripheral cycle (6 peripheral clock periods). The Timer clock rate is F PER/6, i.e. FOSC/12 in standard mode or F OSC/6 in X2 mode. For Counter operation (C/Tx# = 1), the Timer register counts the negative transitions on the Tx external input pin. The external input is sampled every peripheral cycles. When the sample is high in one cycle and low in the next one, the Counter is incremented. Since it takes 2 cycles (12 peripheral clock periods) to recognize a negative transition, the maximum count rate is F PER/12, i.e. F OSC/24 in standard mode or F OSC/12 in X2 mode. There are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full peripheral cycle. Timer 0 Timer 0 functions as either a Timer or event Counter in four modes of operation. Figure 31 to Figure 34 show the logical configuration of each mode. Timer 0 is controlled by the four lower bits of TMOD register (see Figure 36) and bits 0, 1, 4 and 5 of TCON register (see Figure 35). TMOD register selects the method of Timer gating (GATE0), Timer or Counter operation (T/C0#) and mode of operation (M10 and M00). TCON register provides Timer 0 control functions: overflow flag (TF0), run control bit (TR0), interrupt flag (IE0) and interrupt type control bit (IT0). For normal Timer operation (GATE0 = 0), setting TR0 allows TL0 to be incremented by the selected input. Setting GATE0 and TR0 allows external pin INT0# to control Timer operation. Timer 0 overflow (count rolls over from all 1s to all 0s) sets TF0 flag generating an inter- rupt request. It is important to stop Timer/Counter before changing mode.

58 T89C51CC01

ignored. Prescaler overflow increments TH0 register. Figure 31. Timer/Counter x (x = 0 or 1) in Mode 0 cascade (see Figure 32). The selected input increments TL0 register. Figure 32. Timer/Counter x (x = 0 or 1) in Mode 1

60 T89C51CC01

4129G–CAN–05/03 Timer 1 Timer 1 is identical to Timer 0 excepted for Mode 3 which is a hold-count mode. The fol- lowing comments help to understand the differences:  Timer 1 functions as either a Timer or event Counter in three modes of operation. Figure 31 to Figure 33 show the logical configuration for modes 0, 1, and 2. Timer 1’s mode 3 is a hold-count mode.  Timer 1 is controlled by the four high-order bits of TMOD register (see Figure 36) and bits 2, 3, 6 and 7 of TCON register (see Figure 35). TMOD register selects the method of Timer gating (GATE1), Timer or Counter operation (C/T1#) and mode of operation (M11 and M01). TCON register provides Timer 1 control functions: overflow flag (TF1), run control bit (TR1), interrupt flag (IE1) and interrupt type control bit (IT1).  Timer 1 can serve as the Baud Rate Generator for the Serial Port. Mode 2 is best suited for this purpose.  For normal Timer operation (GATE1 = 0), setting TR1 allows TL1 to be incremented by the selected input. Setting GATE1 and TR1 allows external pin INT1# to control Timer operation.  Timer 1 overflow (count rolls over from all 1s to all 0s) sets the TF1 flag generating an interrupt request.  When Timer 0 is in mode 3, it uses Timer 1’s overflow flag (TF1) and run control bit (TR1). For this situation, use Timer 1 only for applications that do not require an interrupt (such as a Baud Rate Generator for the Serial Port) and switch Timer 1 in and out of mode 3 to turn it off and on.  It is important to stop Timer/Counter before changing mode. Mode 0 (13-bit Timer) Mode 0 configures Timer 1 as a 13-bit Timer, which is set up as an 8-bit Timer (TH1 reg- ister) with a modulo-32 prescaler implemented with the lower 5 bits of the TL1 register (see Figure 31). The upper 3 bits of TL1 register are ignored. Prescaler overflow incre- ments TH1 register. Mode 1 (16-bit Timer) Mode 1 configures Timer 1 as a 16-bit Timer with TH1 and TL1 registers connected in cascade (see Figure 32). The selected input increments TL1 register. Mode 2 (8-bit Timer with Auto- Reload) Mode 2 configures Timer 1 as an 8-bit Timer (TL1 register) with automatic reload from TH1 register on overflow (see Figure 33). TL1 overflow sets TF1 flag in TCON register and reloads TL1 with the contents of TH1, which is preset by software. The reload leaves TH1 unchanged. Mode 3 (Halt) Placing Timer 1 in mode 3 causes it to halt and hold its count. This can be used to halt Timer 1 when TR1 run control bit is not available i.e. when Timer 0 is in mode 3. Interrupt Each Timer handles one interrupt source that is the timer overflow flag TF0 or TF1. This flag is set every time an overflow occurs. Flags are cleared when vectoring to the Timer interrupt routine. Interrupts are enabled by setting ETx bit in IEN0 register. This assumes interrupts are globally enabled by setting EA bit in IEN0 register.

Figure 35. Timer Interrupt System

62 T89C51CC01

4129G–CAN–05/03 Registers Table 35. TCON Register TCON (S:88h) Timer/Counter Control Register Reset Value = 0000 0000b 76543210 TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 Bit Number Bit Mnemonic Description 7T F 1 Timer 1 Overflow Flag Cleared by hardware when processor vectors to interrupt routine. Set by hardware on Timer/Counter overflow, when Timer 1 register overflows. 6T R 1 Timer 1 Run Control Bit Clear to turn off Timer/Counter 1. Set to turn on Timer/Counter 1. 5T F 0 Timer 0 Overflow Flag Cleared by hardware when processor vectors to interrupt routine. Set by hardware on Timer/Counter overflow, when Timer 0 register overflows. 4T R 0 Timer 0 Run Control Bit Clear to turn off Timer/Counter 0. Set to turn on Timer/Counter 0. 3I E 1 Interrupt 1 Edge Flag Cleared by hardware when interrupt is processed if edge-triggered (see IT1). Set by hardware when external interrupt is detected on INT1# pin. 2I T 1 Interrupt 1 Type Control Bit Clear to select low level active (level triggered) for external interrupt 1 (INT1#). Set to select falling edge active (edge triggered) for external interrupt 1. 1I E 0 Interrupt 0 Edge Flag Cleared by hardware when interrupt is processed if edge-triggered (see IT0). Set by hardware when external interrupt is detected on INT0# pin. 0I T 0 Interrupt 0 Type Control Bit Clear to select low level active (level triggered) for external interrupt 0 (INT0#). Set to select falling edge active (edge triggered) for external interrupt 0.

Table 36. TMOD Register Notes: 1. Reloaded from TH1 at overflow.

  1. Reloaded from TH0 at overflow.

Clear to enable Timer 1 whenever TR1 bit is set. Set to enable Timer 1 only while INT1# pin is high and TR1 bit is set. Clear for Timer operation: Timer 1 counts the divided-down system clock. Set for Counter operation: Timer 1 counts negative transitions on external pin T1. 0 0Mode 0: 8-bit Timer/Counter (TH1) with 5-bit prescaler (TL1). 0 1Mode 1: 16-bit Timer/Counter. Clear to enable Timer 0 whenever TR0 bit is set. Set to enable Timer/Counter 0 only while INT0# pin is high and TR0 bit is set. Clear for Timer operation: Timer 0 counts the divided-down system clock. Set for Counter operation: Timer 0 counts negative transitions on external pin T0. 0 0Mode 0: 8-bit Timer/Counter (TH0) with 5-bit prescaler (TL0). 0 1Mode 1: 16-bit Timer/Counter. TH0 is an 8-bit Timer using Timer 1’s TR0 and TF0 bits.

0 M00

64 T89C51CC01

Table 37. TH0 Register Table 38. TL0 Register Table 39. TH1 Register

Table 40. TL1 Register

66 T89C51CC01

Timer 2 The T89C51CC01 timer 2 is compatible with timer 2 in the 80C52. timer clock. Setting TR2 allows TL2 to be incremented by the selected input. Figure 36. In this mode the T2EX pin controls the counting direction. in RCAP2H and RCAP2L registers to be loaded into the timer registers TH2 and TL2. timer registers TH2 and TL2 equals the value stored in RCAP2H and RCAP2L registers. The underflow sets TF2 flag and reloads FFFFh into the timer registers. Figure 36. Auto-Reload Mode Up/Down Counter

61 Hz (F

 Set T2OE bit in T2MOD register.  Clear C/T2 bit in T2CON register. reload value or different depending on the application.  To start the timer, set TR2 run control bit in T2CON register. independent since both functions use the values in the RCAP2H and RCAP2L registers. Figure 37. Clock-Out Mode

68 T89C51CC01

4129G–CAN–05/03 Registers Table 41. T2CON Register T2CON (S:C8h) Timer 2 Control Register Reset Value = 0000 0000b Bit addressable 76543210 TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2# CP/RL2# Bit Number Bit Mnemonic Description 7T F 2 Timer 2 Overflow Flag TF2 is not set if RCLK=1 or TCLK = 1. Must be cleared by software. Set by hardware on timer 2 overflow. 6E X F 2 Timer 2 External Flag Set when a capture or a reload is caused by a negative transition on T2EX pin if EXEN2=1. Set to cause the CPU to vector to timer 2 interrupt routine when timer 2 interrupt is enabled. Must be cleared by software.

5 RCLK

Clear to use timer 1 overflow as receive clock for serial port in mode 1 or 3. Set to use timer 2 overflow as receive clock for serial port in mode 1 or 3. 4T C L K Transmit Clock bit Clear to use timer 1 overflow as transmit clock for serial port in mode 1 or 3. Set to use timer 2 overflow as transmit clock for serial port in mode 1 or 3. 3E X E N 2 Timer 2 External Enable bit Clear to ignore events on T2EX pin for timer 2 operation. Set to cause a capture or reload when a negative transition on T2EX pin is detected, if timer 2 is not used to clock the serial port. 2T R 2 Timer 2 Run Control bit Clear to turn off timer 2. Set to turn on timer 2. 1C / T 2 # Timer/Counter 2 Select bit Clear for timer operation (input from internal clock system: F OSC). Set for counter operation (input from T2 input pin).

0 CP/RL2#

Timer 2 Capture/Reload bit If RCLK=1 or TCLK=1, CP/RL2# is ignored and timer is forced to auto-reload on timer 2 overflow. Clear to auto-reload on timer 2 overflows or negative transitions on T2EX pin if EXEN2=1. Set to capture on negative transitions on T2EX pin if EXEN2=1.

Table 42. T2MOD Register Table 43. TH2 Register The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. Clear to program P1.0/T2 as clock input or I/O port. Set to program P1.0/T2 as clock output.

0 DCEN

Clear to disable timer 2 as up/down counter. Set to enable timer 2 as up/down counter.

70 T89C51CC01

Table 44. TL2 Register Table 45. RCAP2H Register Table 46. RCAP2L Register 7-0 High Byte of Timer 2 Reload/Capture. 7-0 Low Byte of Timer 2 Reload/Capture.

ter. When exiting reset, the WDT is -by default- disable. Note: When the Watchdog is enable it is impossible to change its period. Figure 38. Watchdog Timer

72 T89C51CC01

Table 47. Machine Cycle Count Table 48. Time-Out Computation

4129G–CAN–05/03 Watchdog Timer During Power-down Mode and Idle In Power-down mode the oscillator stops, which means the WDT also stops. While in Power-down mode, the user does not need to service the WDT. There are 2 methods of exiting Power-down mode: by a hardware reset or via a level activated external interrupt which is enabled prior to entering Power-down mode. When Power-down is exited with hardware reset, the Watchdog is disabled. Exiting Power-down with an interrupt is sig- nificantly different. The interrupt shall be held low long enough for the oscillator to stabilize. When the interrupt is brought high, the interrupt is serviced. To prevent the WDT from resetting the device while the interrupt pin is held low, the WDT is not started until the interrupt is pulled high. It is suggested that the WDT be reset during the inter- rupt service for the interrupt used to exit Power-down. To ensure that the WDT does not overflow within a few states of exiting powerdown, it is best to reset the WDT just before entering powerdown. In the Idle mode, the oscillator continues to run. To prevent the WDT from resetting T89C51CC01 while in Idle mode, the user should always set up a timer that will periodi- cally exit Idle, service the WDT, and re-enter Idle mode. Register Table 49. WDTPRG Register WDTPRG (S:A7h) Watchdog Timer Duration Programming Register Reset Value = XXXX X000b 76543210 Bit Number Bit Mnemonic Description 7- Reserved The value read from this bit is indeterminate. Do not set this bit. 6- Reserved The value read from this bit is indeterminate. Do not set this bit. 5- Reserved The value read from this bit is indeterminate. Do not set this bit. 4- Reserved The value read from this bit is indeterminate. Do not set this bit. 3- Reserved The value read from this bit is indeterminate. Do not set this bit. 2S 2 Watchdog Timer Duration selection bit 2 Work in conjunction with bit 1 and bit 0. 1S 1 Watchdog Timer Duration selection bit 1 Work in conjunction with bit 2 and bit 0. 0S 0 Watchdog Timer Duration selection bit 0 Work in conjunction with bit 1 and bit 2.

74 T89C51CC01

Table 50. WDTRST Register sequence without instruction between these two sequences.

4129G–CAN–05/03 CAN Controller The CAN Controller provides all the features required to implement the serial communi- cation protocol CAN as defined by BOSCH GmbH. The CAN specification as referred to by ISO/11898 (2.0A and 2.0B) for high speed and ISO/11519-2 for low speed. The CAN Controller is able to handle all types of frames (Data, Remote, Error and Overload) and achieves a bitrate of 1-Mbit/sec at 8 MHz 1 Crystal frequency in X2 mode. Note: 1. At BRP = 1 sampling point will be fixed. CAN Controller The CAN Controller accesses are made through SFR. Several operations are possible by SFR:  arithmetic and logic operations, transfers and program control (SFR is accessible by direct addressing).  15 independent message objects are implemented, a pagination system manages their accesses. Any message object can be programmed in a reception buffer block (even non-consec- utive buffers). For the reception of defined messages one or several receiver message objects can be masked without participating in the buffer feature. An IT is generated when the buffer is full. The frames following the buffer-full interrupt will not be taken into account until at least one of the buffer message objects is re-enabled in reception. Higher priority of a message object for reception or transmission is given to the lower message object number. The programmable 16-bit Timer (CANTIMER) is used to stamp each received and sent message in the CANSTMP register. This timer starts counting as soon as the CAN con- troller is enabled by the ENA bit in the CANGCON register. The Time Trigger Communication (TTC) protocol is supported by the T89C51CC01. Figure 39. CAN Controller Block Diagram

76 T89C51CC01

register (CANPAGE) as illustrate in Figure 40. Figure 40. CAN Controller Memory Organization

8 Bytes

each access. The range of this counter is 8. Note that the maibox is a pure RAM, dedicated to one message object, without overlap. lations or tests can be executed in the mailbox area which provide quicker access. – message object Status (CANSTCH). gives a fast overview of the message objects availability. The CAN messages can be handled by interrupt or polling modes.  Receive buffer message object. Table 51. Configuration for CONCH1:2 message object, it is necessary to re-write the configuration in CANCONCH register.

78 T89C51CC01

sage objects, and with no limitation in number of message objects used up to 15. Figure 41. Buffer mode The same acceptance filter must be defined for each message objects of the buffer. When there is no mask on the identifier or the IDE, all messages are accepted. A received frame will always be stored in the lowest free message object. the message object re-enabled in buffer reception in order to free the message object. message objects is re-enabled in reception. This flag must be cleared by the software in order to acknowledge the interrupt.

 Interrupt on overrun of CAN Timer. Figure 42. CAN Controller Interrupt Structure  Enable transmission interrupt, ENTX.

80 T89C51CC01

 Enable reception interrupt, ENRX.  Enable interrupt on error, ENERCH.  Enable interrupt on error, ENERG.  Enable interrupt on Buffer full, ENBUF.  Enable Overrun IT in the interrupt system register. CANGIT bits (OVRTIM, OVRBUF,...), must be cleared by the software application. Figure 43. Sample And Transmission Point

Figure 44. General Structure of a Bit Period Verify that the CAN baud rate you want is an integer division of FCAN clock.

82 T89C51CC01

when the CAN macro detects an error. transmission, an error passive unit will wait before initiating further transmission. A bus off unit is not allowed to have any influence on the bus. For fault confinement, two error counters (TEC and REC) are implemented. See CAN Specification for details on Fault confinement. Figure 45. Line Error Mode

ID+RTR+RB+IDE received are written over the ID TAG Registers. Figure 46. Acceptance filter block diagram To accept only ID = 318h in part A.

84 T89C51CC01

4129G–CAN–05/03 Data and Remote Frame Description of the different steps for:  Data Frame  Remote Frame, With Automatic Reply,  Remote Frame u uu uu 0 1 x 0 0 u uu uu ENCH RTR RPLV TXOK RXOK 0 1 x 0 0 c uc uu 0 0 x 1 0 u cc uu 0 0 x 0 1 DATA FRAME Node A Node B ENCH RTR RPLV TXOK RXOK message object in reception message object stay in reception message object in transmission message object stay in transmission u uu uu 1 1 x 0 0 c uu uc 0 1 x 1 0 u cc uu 0 0 x 0 1 REMOTE FRAME DATA FRAME u uu uu 1 1 1 0 0 u uu cc 0 1 0 0 0 c uc cu 0 0 0 1 0 ENCH RTR RPLV TXOK RXOK ENCH RTR RPLV TXOK RXOK (immediate) message object in reception message object in transmission message object stay in transmission message object in transmission message object in reception message object stay in by CAN controller by CAN controller reception u uu uu 1 1 x 0 0 u uu uu ENCH RTR RPLV TXOK RXOK 1 1 0 0 0 c uu uc 0 1 x 1 0 u cc uu 1 0 0 0 1 REMOTE FRAME ENCH RTR RPLV TXOK RXOK u uu uu 0 1 x 0 0 c uc uu 0 0 x 1 0 u cc uc 0 0 x 0 1 DATA FRAME (deferred) u : modified by useri c : modified by CANi message object in reception message object in transmission by user message object stay in transmission message object stay in reception message object in transmission message object in reception message object in reception by CAN controller by user

TTC bit in the CANGCON register. Note: In this mode, CAN only sends the frame once, even if an error occurs. the message object which received or sent the frame. – All messages can be stamps. – The stamping of a received frame occurs when the RxOk flag is set. – The stamping of a sent frame occurs when the TxOk flag is set. The CAN Timer works in a roll-over from FFFFh to 0000h which serves as a time base. in the interrupt enable register IEN1 is set. Figure 47. Block Diagram of CAN Timer

86 T89C51CC01

ing the received messages. It cannot send any message. The error flags are updated. The bit timing can be adjusted until no error occurs (good configuration find). In this mode, the error counters are frozen. To go back to the standard mode, the AUTOBAUD bit must be cleared. Figure 48. Autobaud Mode

4129G–CAN–05/03 // Enable the CAN macro CANGCON = 02h 2. Configure message object 3 in reception to receive only standard (11-bit identi- fier) message 100h // Select the message object 3 CANPAGE = 30h // Enable the interrupt on this message object CANIE2 = 08h // Clear the status and control register CANSTCH = 00h CANCONCH = 00h // Init the acceptance filter to accept only message 100h in standard mode CANIDT1 = 20h CANIDT2 = 00h CANIDT3 = 00h CANIDT4 = 00h CANIDM1 = FFh CANIDM2 = FFh CANIDM3 = FFh CANIDM4 = FFh // Enable channel in reception CANCONCH = 88h // enable reception Note: To enable the CAN interrupt in reception: EA = 1 ECAN = 1 CANGIE = 20h 3. Send a message on the message object 12 // Select the message object 12 CANPAGE = C0h // Enable the interrupt on this message object CANIE1 = 01h // Clear the Status register CANSTCH = 00h; // load the identifier to send (ex: 555h) CANIDT1 = AAh; CANIDT2 = A0h; // load data to send CANMSG = 00h CANMSG = 01h CANMSG = 02h CANMSG = 03h CANMSG = 04h CANMSG = 05h CANMSG = 06h CANMSG = 07h // configure the control register CANCONCH = 18h

88 T89C51CC01

4129G–CAN–05/03 4. Interrupt routine // Save the current CANPAGE // Find the first message object which generate an interrupt in CANSIT1 and CANSIT2 // Select the corresponding message object // Analyse the CANSTCH register to identify which kind of interrupt is generated // Manage the interrupt // Clear the status register CANSTCH = 00h; // if it is not a channel interrupt but a general interrupt // Manage the general interrupt and clear CANGIT register // restore the old CANPAGE

Table 52. CAN SFR’s With Reset Values

90 T89C51CC01

4129G–CAN–05/03 Registers Table 53. CANGCON Register CANGCON (S:ABh) CAN General Control Register Reset Value = 0000 0000b 7654 32 10 ABRQ OVRQ TTC SYNCTTC AUTOBAUD TEST ENA GRES Bit Number Bit Mnemonic Description 7A B R Q Abort Request Not an auto-resetable bit. A reset of the ENCH bit (message object control and DLC register) is done for each message object. The pending transmission communications are immediately aborted but the on-going communication will be terminated normally, setting the appropriate status flags, TXOK or RXOK. 6O V R Q Overload frame request (initiator) Auto-resetable bit. Set to send an overload frame after the next received message. Cleared by the hardware at the beginning of transmission of the overload frame.

5 TTC

Network in Timer Trigger Communication set to select node in TTC. clear to disable TTC features.

4 SYNCTTC

When this bit is set the TTC timer is caught on the last bit of the End Of Frame. When this bit is clear the TTC timer is caught on the Start Of Frame. This bit is only used in the TTC mode.

3 AUTOBAUD

set to active listening mode. Clear to disable listening mode 2T E S T Test mode. The test mode is intended for factory testing and not for customer use. 1E N A / S T B Enable/Standby CAN Controller When this bit is set, it enables the CAN controller and its input clock. When this bit is clear, the on-going communication is terminated normally and the CAN controller state of the machine is frozen (the ENCH bit of each message object does not change). In the standby mode, the transmitter constantly provides a recessive level; the receiver is not activated and the input clock is stopped in the CAN controller. During the disable mode, the registers and the mailbox remain accessible. Note that two clock periods are needed to start the CAN controller state of the machine. 0G R E S General Reset (software reset) Auto-resetable bit. This reset command is ‘ORed’ with the hardware reset in order to reset the controller. After a reset, the controller is disabled.

Table 54. CANGSTA Register Note: 1. These fields are Read Only. The values read from this bit is indeterminate. Do not set this bit. The values read from this bit is indeterminate. Do not set this bit. bit is also active during an InterFrame Spacing if a frame must be sent. This flag does not generate an interrupt.

3 RBSY

This flag does not generate an interrupt. bit gives the true state of a chosen mode. This flag does not generate an interrupt.

0 ERRP Error Passive Mode(1)

92 T89C51CC01

Table 55. CANGIT Register Note: 1. These fields are Read Only. It can be used in the case of the polling method. The values read from this bit is indeterminate. Do not set this bit. This status bit is set when the CAN timer switches 0xFFFF to 0x0000. If the bit ETIM in the IE1 register is set, an interrupt is generated. Clear this bit in order to reset the interrupt. This bit is set when the buffer is full. Detection of more than five consecutive bits with the same polarity. This flag can generate an interrupt. resetable by user. from the start of frame up to the data field. This flag can generate an interrupt. resetable by user. This flag can generate an interrupt. resetable by user. No detection of the dominant bit in the acknowledge slot. This flag can generate an interrupt. resetable by user.

Table 56. CANTEC Register Table 57. CANREC Register

94 T89C51CC01

Table 58. CANGIE Register Table 59. CANEN1 Register The values read from these bits are indeterminate. Do not set these bits.

5 ENRX

3 ENERCH

2 ENBUF

1 ENERG

The value read from this bit is indeterminate. Do not set this bit. The values read from this bit is indeterminate. Do not set this bit. 1 - message object is enabled.

Table 60. CANEN2 Register Table 61. CANSIT1 Register 1 - message object is enabled. The values read from this bit is indeterminate. Do not set this bit. 1 - IT turned on. Reset when interrupt condition is cleared by user.

96 T89C51CC01

Table 62. CANSIT2 Register Table 63. CANIE1 Register 1 - IT turned on. Reset when interrupt condition is cleared by user. The values read from this bit is indeterminate. Do not set this bit. IECH14:8 = 0b 0000 1100 -> Enable IT’s of message objects 11 and 10.

Table 64. CANIE2 Register Table 65. CANBT1 Register abled with the ENA bit of the CANGCON register set to 0. No default value after reset. IECH7:0 = 0b 0000 1100 -> Enable IT’s of message objects 3 and 2. The value read from this bit is indeterminate. Do not set this bit. determines the individual bit timing. The value read from this bit is indeterminate. Do not set this bit.

98 T89C51CC01

Table 66. CANBT2 Register abled with the ENA bit of the CANGCON register set to 0. No default value after reset. The value read from this bit is indeterminate. Do not set this bit. The synchronization jump width defines the maximum number of clock cycles. A bit period may be shortened or lengthened by a re-synchronization. The value read from this bit is indeterminate. Do not set this bit. bus line, the input comparator delay and the output driver delay. The value read from this bit is indeterminate. Do not set this bit.

Table 67. CANBT3 Register abled with the ENA bit of the CANGCON register set to 0. No default value after reset. The value read from this bit is indeterminate. Do not set this bit. be shortened by the re-synchronization jump width. be lengthened by the re-synchronization jump width. 0 - once, at the sample point. majority decision of the three values.

100 T89C51CC01

Table 68. CANPAGE Register Table 69. CANCONCH Register The available numbers are: 0 to 14 (see Figure 40). 0 - auto-increment of the index (default value). 1 - non-auto-increment of the index. Byte location of the data field for the defined message object (see Figure 40). 0 - CAN standard rev 2.0 A (ident = 11 bits). 1 - CAN standard rev 2.0 B (ident = 29 bits). Number of Bytes in the data field of the message. The range of DLC is from 0 up to 8. This value is updated when a frame is received (data or remote frame).

Table 70. CANSTCH Register No default value after reset. The communication enabled by transmission is completed. This flag can generate an interrupt. The communication enabled by reception is completed. message object (0 to 13) is updated first. This flag can generate an interrupt. The bit value monitored is different from the bit value sent. This flag can generate an interrupt. Detection of more than five consecutive bits with the same polarity. This flag can generate an interrupt. from the start of frame up to the data field. This flag can generate an interrupt. This flag can generate an interrupt. No detection of the dominant bit in the acknowledge slot. This flag can generate an interrupt.

102 T89C51CC01

Table 71. CANIDT1 Register for V2.0 part A No default value after reset. Table 72. CANIDT2 Register for V2.0 part A No default value after reset. Table 73. CANIDT3 Register for V2.0 part A No default value after reset. The values read from these bits are indeterminate. Do not set these bits. The values read from these bits are indeterminate. Do not set these bits.

Table 74. CANIDT4 Register for V2.0 part A No default value after reset. Table 75. CANIDT1 Register for V2.0 part B No default value after reset. Table 76. CANIDT2 Register for V2.0 part B No default value after reset. The values read from these bits are indeterminate. Do not set these bits. 2R T R T A G Remote Transmission Request Tag Value. The values read from this bit are indeterminate. Do not set these bit. 0R B 0 T A G Reserved Bit 0 Tag Value.

104 T89C51CC01

Table 77. CANIDT3 Register for V2.0 part B No default value after reset. Table 78. CANIDT4 Register for V2.0 part B No default value after reset. Table 79. CANIDM1 Register for V2.0 part A No default value after reset.

Table 80. CANIDM2 Register for V2.0 part A No default value after reset. Table 81. CANIDM3 Register for V2.0 part A No default value after reset. The values read from these bits are indeterminate. Do not set these bits. The values read from these bits are indeterminate.

106 T89C51CC01

Table 82. CANIDM4 Register for V2.0 part A Note: The ID Mask is only used for reception. No default value after reset. Table 83. CANIDM1 Register for V2.0 part B Note: The ID Mask is only used for reception. No default value after reset. The values read from these bits are indeterminate. Do not set these bits. The value read from this bit is indeterminate. Do not set this bit.

Table 84. CANIDM2 Register for V2.0 part B Note: The ID Mask is only used for reception. No default value after reset. Table 85. CANIDM3 Register for V2.0 part B Note: The ID Mask is only used for reception. No default value after reset.

108 T89C51CC01

Table 86. CANIDM4 Register for V2.0 part B Note: The ID Mask is only used for reception. No default value after reset. Table 87. CANMSG Register No default value after reset. The value read from this bit is indeterminate. Do not set this bit.

Table 88. CANTCON Register Table 89. CANTIMH Register Table 90. CANTIML Register

10 CANGTIM 9 CANGTIM 8

110 T89C51CC01

Table 91. CANSTMPH Register Table 92. CANSTMPL Register Table 93. CANTTCH Register

10 TIMSTMP 9 TIMSTMP 8

Table 94. CANTTCL Register

112 T89C51CC01

4129G–CAN–05/03 Programmable Counter Array (PCA) The PCA provides more timing capabilities with less CPU intervention than the standard timer/counters. Its advantages include reduced software overhead and improved accu- racy. The PCA consists of a dedicated timer/counter which serves as the time base for an array of five compare/capture modules. Its clock input can be programmed to count any of the following signals:  PCA clock frequency/6 (see “clock” section)  PCA clock frequency/2  Timer 0 overflow  External input on ECI (P1.2) Each compare/capture modules can be programmed in any one of the following modes:  rising and/or falling edge capture,  software timer,  high-speed output,  pulse width modulator. Module 4 can also be programmed as a Watchdog timer. see the "PCA Watchdog Timer" section. When the compare/capture modules are programmed in capture mode, software timer, or high speed output mode, an interrupt can be generated when the module executes its function. All five modules plus the PCA timer overflow share one interrupt vector. The PCA timer/counter and compare/capture modules share Port 1 for external I/Os. These pins are listed below. If the port is not used for the PCA, it can still be used for standard I/O. PCA Timer The PCA timer is a common time base for all five modules (see Figure 49). The timer count source is determined from the CPS1 and CPS0 bits in the CMOD SFR (see Table 8) and can be programmed to run at:  1/6 the PCA clock frequency.  1/2 the PCA clock frequency.  the Timer 0 overflow.  the input on the ECI pin (P1.2). PCA Component External I/O Pin 16-bit Counter P1.2/ECI 16-bit Module 0 P1.3/CEX0 16-bit Module 1 P1.4/CEX1 16-bit Module 2 P1.5/CEX2 16-bit Module 3 P1.6/CEX3 16-bit Module 4 P1.7/CEX4

Figure 49. PCA Timer/Counter The CMOD register includes three additional bits associated with the PCA.  The CIDL bit which allows the PCA to stop during idle mode.  The WDTE bit which enables or disables the Watchdog function on module 4. CCON register to be set when the PCA timer overflows.  The CR bit must be set to run the PCA. The PCA is shut off by clearing this bit. if the ECF bit in CMOD register is set. The CF bit can only be cleared by software.  8-bit Pulse Width Modulator. In addition module 4 can be used as a Watchdog Timer.

114 T89C51CC01

when a match or compare occurs in the associated module.  The PWM bit enables the pulse width modulation mode. CAPP bit enables the positive edge. If both bits are set both edges will be enabled.  The bit ECOM in CCAPM register when set enables the comparator function. Figure 50. PCA Interrupt System ECCFn bit in the CCAPMn SFR are set then an interrupt will be generated.

116 T89C51CC01

each time a match occurs between the PCA counter and the module’s capture registers. Figure 53. PCA High Speed Output Mode

Figure 54. PCA PWM Mode not cause the RST pin to be driven high. cations the first solution is the best option.

118 T89C51CC01

4129G–CAN–05/03 PCA Registers Table 95. CMOD Register CMOD (S:D9h) PCA Counter Mode Register Reset Value = 00XX X000b 76543210 CIDL WDTE - - - CPS1 CPS0 ECF Bit Number Bit Mnemonic Description 7C I D L PCA Counter Idle Control bit Clear to let the PCA run during Idle mode. Set to stop the PCA when Idle mode is invoked. 6W D T E Watchdog Timer Enable Clear to disable Watchdog Timer function on PCA Module 4, Set to enable it. 5- Reserved The value read from this bit is indeterminate. Do not set this bit. 4- Reserved The value read from this bit is indeterminate. Do not set this bit. 3- Reserved The value read from this bit is indeterminate. Do not set this bit. 2C P S 1 EWC Count Pulse Select bits CPS1 CPS0Clock source 0 0 Internal Clock, FPca/6 0 1 Internal Clock, FPca/2 1 0 Timer 0 overflow 1 1 External clock at ECI/P1.2 pin (Max. Rate = FPca/4) 1C P S 0 Reserved The value read from this bit is indeterminate. Do not set this bit. 0E C F Enable PCA Counter Overflow Interrupt bit Clear to disable CF bit in CCON register to generate an interrupt. Set to enable CF bit in CCON register to generate an interrupt.

Table 96. CCON Register interrupt request if the ECF bit in CMOD register is set. Must be cleared by software. Clear to turn the PCA Timer/Counter off. Set to turn the PCA Timer/Counter on. The value read from this bit is indeterminate. Do not set this bit.

4 CCF4

interrupt request if the ECCF 4 bit in CCAPM 4 register is set. Must be cleared by software.

3 CCF3

interrupt request if the ECCF 3 bit in CCAPM 3 register is set. Must be cleared by software.

2 CCF2

interrupt request if the ECCF 2 bit in CCAPM 2 register is set. Must be cleared by software.

1 CCF1

interrupt request if the ECCF 1 bit in CCAPM 1 register is set. Must be cleared by software.

0 CCF0

interrupt request if the ECCF 0 bit in CCAPM 0 register is set. Must be cleared by software.

120 T89C51CC01

Table 97. CCAPnH Registers Table 98. CCAPnL Registers

Table 99. CCAPMn Registers The Value read from this bit is indeterminate. Do not set this bit. Clear to disable the Compare function. Set to enable the Compare function. output, the Pulse Width Modulator (PWM) and the Watchdog Timer (WDT).

5 CAPPn

Clear to disable the Capture function triggered by a positive edge on CEXx pin. Clear to disable the Capture function triggered by a negative edge on CEXx pin. Set to enable the Capture function triggered by a negative edge on CEXx pin. CCFx bit in CCON register, flagging an interrupt.

2 TOGn

The toggle mode is configured by setting ECOMx, MATx and TOGx bits. Clear to disable CCFx bit in CCON register to generate an interrupt request. Set to enable CCFx bit in CCON register to generate an interrupt request.

122 T89C51CC01

Table 100. CH Register Table 101. CL Register

4129G–CAN–05/03 Analog-to-Digital Converter (ADC) This section describes the on-chip 10 bit analog-to-digital converter of the T89C51CC01. Eight ADC channels are available for sampling of the external sources AN0 to AN7. An analog multiplexer allows the single ADC converter to select one from the 8 ADC channels as ADC input voltage (ADCIN). ADCIN is converted by the 10-bit cascaded potentiometric ADC. Two modes of conversion are available: - Standard conversion (8 bits). - Precision conversion (10 bits). For the precision conversion, set bit PSIDLE in ADCON register and start conversion. The device is in a pseudo-idle mode, the CPU does not run but the peripherals are always running. This mode allows digital noise to be as low as possible, to ensure high precision conversion. For this mode it is necessary to work with end of conversion interrupt, which is the only way to wake the device up. If another interrupt occurs during the precision conversion, it will be served only after this conversion is completed. Features  8 channels with multiplexed inputs  10-bit cascaded potentiometric ADC  Conversion time 16 micro-seconds (typ.)  Zero Error (offset) ± 2 LSB max  Positive External Reference Voltage Range (VREF) 2.4 to 3.0Volt (typ.)  ADCIN Range 0 to 3Volt  Integral non-linearity typical 1 LSB, max. 2 LSB  Differential non-linearity typical 0.5 LSB, max. 1 LSB  Conversion Complete Flag or Conversion Complete Interrupt  Selectable ADC Clock ADC Port 1 I/O Functions Port 1 pins are general I/O that are shared with the ADC channels. The channel select bit in ADCF register define which ADC channel/port1 pin will be used as ADCIN. The remaining ADC channels/port1 pins can be used as general-purpose I/O or as the alter- nate function that is available. A conversion launched on a channel which are not selected on ADCF register will not have any effect.

124 T89C51CC01

Figure 55. ADC Description depicts the waveforms in idealized form and do not provide precise timing information. of the T89C51CC01 datasheet. Figure 56. Timing Diagram The user must ensure that 4 us minimum time between setting ADEN and the start of the first conversion.

A start of single A/D conversion is triggered by setting bit ADSST (ADCON.3). After completion of the A/D conversion, the ADSST bit is cleared by hardware. high. In this case one should wait Tsetup only before the first conversion. Table 102. Selected Analog input 3FFh if greater than VAREF and 000h if less than VAGND. Clock Selection The ADC clock is the same as CPU. to generate the ADC clock from the oscillator frequency.

000 A N 0

001 A N 1

010 A N 2

011 A N 3

100 A N 4

101 A N 5

110 A N 6

111 A N 7

126 T89C51CC01

Figure 57. A/D Converter clock in ADCON register. In this mode its power dissipation is reduced. EADC is set. For re-arming the interrupt the bit ADEOC must be cleared by software. Figure 58. ADC Interrupt Structure

  1. Start a standard conversion
  2. Start a precision conversion (need interrupt ADC)

4129G–CAN–05/03 // clear the field SCH[2:0] ADCON and = F8h // Select the channel ADCON | = channel // Start conversion in precision mode ADCON | = 48h Note: to enable the ADC interrupt: EA = 1

128 T89C51CC01

Table 104. ADCON Register Set to use P1.x as ADC input. Clear to use P1.x as standart I/O port.

6 PSIDLE

Clear to convert without idle mode. Clear for Standby mode (power dissipation 1 uW). Must be cleared by software.

3 ADSST

Set to start an A/D conversion.

Table 105. ADCLK Register Table 106. ADDH Register Table 107. ADDL Register The value read from these bits are indeterminate. Do not set these bits. The value read from these bits are indeterminate. Do not set these bits.

130 T89C51CC01

interrupt, a timer overrun interrupt and an ADC. These interrupts are shown below. Figure 59. Interrupt Control System

which must be cleared to disable all the interrupts at the same time. bit values and priority levels associated with each combination. Table 108. Priority Level Bit Values determined by the polling sequence, see Table 109. Table 109. Interrupt Priority Within level

132 T89C51CC01

4129G–CAN–05/03 Registers Table 110. IEN0 Register IEN0 (S:A8h) Interrupt Enable Register Reset Value = 0000 0000b bit addressable 76543210 EA EC ET2 ES ET1 EX1 ET0 EX0 Bit Number Bit Mnemonic Description 7E A Enable All Interrupt bit Clear to disable all interrupts. Set to enable all interrupts. If EA=1, each interrupt source is individually enabled or disabled by setting or clearing its interrupt enable bit. 6E C PCA Interrupt Enable Clear to disable the PCA interrupt. Set to enable the PCA interrupt. 5E T 2 Timer 2 Overflow Interrupt Enable bit Clear to disable Timer 2 overflow interrupt. Set to enable Timer 2 overflow interrupt. 4E S Serial Port Enable bit Clear to disable serial port interrupt. Set to enable serial port interrupt. 3E T 1 Timer 1 Overflow Interrupt Enable bit Clear to disable timer 1 overflow interrupt. Set to enable timer 1 overflow interrupt. 2E X 1 External Interrupt 1 Enable bit Clear to disable external interrupt 1. Set to enable external interrupt 1. 1E T 0 Timer 0 Overflow Interrupt Enable bit Clear to disable timer 0 overflow interrupt. Set to enable timer 0 overflow interrupt. 0E X 0 External Interrupt 0 Enable bit Clear to disable external interrupt 0. Set to enable external interrupt 0.

Table 111. IEN1 Register The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. Clear to disable the timer overrun interrupt. Set to enable the timer overrun interrupt.

1 EADC

Clear to disable the ADC interrupt. Set to enable the ADC interrupt. Clear to disable the CAN interrupt. Set to enable the CAN interrupt.

134 T89C51CC01

Table 112. IPL0 Register The value read from this bit is indeterminate. Do not set this bit.

6 PPC PCA Interrupt Priority bit

Refer to PT2H for priority level. Refer to PSH for priority level. Refer to PT1H for priority level. Refer to PX1H for priority level. Refer to PT0H for priority level. Refer to PX0H for priority level.

Table 113. IPL1 Register The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. Refer to PI2CH for priority level. Refer to PSPIH for priority level. Refer to PKBH for priority level.

136 T89C51CC01

Table 114. IPH0 Register The value read from this bit is indeterminate. Do not set this bit.

6 PPCH

4 PSH

Table 115. IPH1 Register The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit. The value read from this bit is indeterminate. Do not set this bit.

1 PADCH

138 T89C51CC01

4129G–CAN–05/03

Electrical Characteristics

DC Parameters for Standard Voltage TA = -40°C to +85°C; VSS = 0V; VCC = 3V to 5.5V; F = 0 to 40 MHz Ambiant Temperature Under Bias: Table 116. DC Parameters in Standard Voltage maximum rating conditions may affect device reliability.

if a crystal oscillator used (see Figure 60.).

  1. Idle I CC is measured with all output pins disconnected; XTAL1 driven with T CLCH,
  2. Power-down I CC is measured with all output pins disconnected; EA = VCC, PORT 0 =

and the POF flag must be set.

  1. Capacitance loading on Ports 0 and 2 may cause spurious noise pulses to be super-

Trigger use is not necessary.

  1. Typicals are based on a limited number of samples and are not guaranteed. The val-

ues listed are at room temperature.

  1. Under steady state (non-transient) conditions, I OL must be externally limited as fol-

not guaranteed to sink current greater than the listed test conditions.

  1. ICC_FLASH_WRITE operating current while a Flash block write is on going.
  2. Flash Retention is guaranteed with the same formula for V CC Min down to 0.

Figure 60. ICC Test Condition, Active Mode All other pins are disconnected.

140 T89C51CC01

Figure 61. ICC Test Condition, Idle Mode Figure 62. ICC Test Condition, Power-Down Mode Figure 63. Clock Signal Waveform for ICC Tests in Active and Idle Modes All other pins are disconnected. All other pins are disconnected.

Notes: 1. Typicals are based on a limited number of samples and are not guaranteed. AVLL = Time for Address Valid to ALE Low. TLLPL = Time for ALE Low to PSEN Low. Table 118, Table 121 and Table 124 give the description of each AC symbols. Table 119, Table 123 and Table 125 give for each range the AC parameter. value and use this value in the formula. LLIV and 20 MHz, Standard clock. Table 117. DC Parameters for AD Converter in Precision Conversion

142 T89C51CC01

Table 118. Symbol Description Table 119. AC Parameters for a Fix Clock (F = 40 MHz)

Table 120. AC Parameters for a Variable Clock

12 TCLCL

144 T89C51CC01

Table 121. Symbol Description Table 122. AC Parameters for a Variable Clock (F=40MHz)

Table 123. AC Parameters for a Variable Clock

146 T89C51CC01

Table 124. Symbol Description (F = 40 MHz)

Table 125. AC Parameters for a Fix Clock (F = 40 MHz) Table 126. AC Parameters for a Variable Clock Table 127. AC Parameters

148 T89C51CC01

4129G–CAN–05/03 External Clock Drive Waveforms AC Testing Input/Output Waveforms AC inputs during testing are driven at V CC - 0.5 for a logic “1” and 0.45V for a logic “0”. Timing measurement are made at VIH min for a logic “1” and VIL max for a logic “0”. Float Waveforms For timing purposes as port pin is no longer floating when a 100 mV change from load voltage occurs and begins to float when a 100 mV change from the loaded VOH/VOL level occurs. IOL/IOH ≥ ± 20 mA. VCC-0.5V 0.45V 0.7VCC 0.2VCC-0.1 TCHCL TCLCX TCLCL TCLCH TCHCX INPUT/OUTPUT 0.2 VCC + 0.9 0.2 VCC - 0.1 VCC -0.5V 0.45V FLOAT VOH - 0.1 V VOL + 0.1 V VLOAD VLOAD + 0.1 V VLOAD - 0.1 V

4129G–CAN–05/03 Clock Waveforms Valid in normal clock mode. In X2 mode XTAL2 must be changed to XTAL2/2. This diagram indicates when signals are clocked internally. The time it takes the signals to propagate to the pins, however, ranges from 25 to 125 ns. This propagation delay is dependent on variables such as temperature and pin loading. Propaga- tion also varies from output to output and component. Typically though (T A=25°C fully loaded) RD and WR propagation delays are approximately 50ns. The other signals are typically 85 ns. Propagation delays are incorporated in the AC specifications. DATA PCL OUT DATA PCL OUT DATA PCL OUT SAMPLED SAMPLED SAMPLED STATE4 STATE5 STATE6 STATE1 STATE2 STATE3 STATE4 STATE5 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 P1 P2 FLOAT FLOAT FLOAT THESE SIGNALS ARE NOT ACTIVATED DURING THE EXECUTION OF A MOVX INSTRUCTION INDICATES ADDRESS TRANSITIONS EXTERNAL PROGRAM MEMORY FETCH FLOAT DATA SAMPLED DPL OR Rt OUT INDICATES DPH OR P2 SFR TO PCH TRANSITION PCL OUT (IF PROGRAM MEMORY IS EXTERNAL) PCL OUT (EVEN IF PROGRAM MEMORY IS INTERNAL) PCL OUT (IF PROGRAM MEMORY IS EXTERNAL OLD DATANEW DATA P0 PINS SAMPLED P1, P2, P3 PINS SAMPLED P1, P2, P3 PINS SAMPLED P0 PINS SAMPLED RXD SAMPLED INTERNAL CLOCK XTAL2 ALE PSEN P2 (EXT) READ CYCLE WRITE CYCLE RD WR PORT OPERATION MOV PORT SRC MOV DEST P0 MOV DEST PORT (P1. P2. P3) (INCLUDES INTO. INT1. TO T1) SERIAL PORT SHIFT CLOCK TXD (MODE 0) DATA OUT DPL OR Rt OUT INDICATES DPH OR P2 SFR TO PCH TRANSITION RXD SAMPLED

150 T89C51CC01

Table 129. Memory AC Timing Figure 64. Flash Memory – ISP Waveforms Figure 65. Flash Memory – Internal Busy Waveforms Table 130. AC Parameters for A/D Conversion

4129G–CAN–05/03

Ordering Information

Table 131. Possible Order Entries can be done by an Atmel distributor.

152 T89C51CC01

4129G–CAN–05/03 Package Drawings CA-BGA

4129G–CAN–05/03 VQFP44

154 T89C51CC01

4129G–CAN–05/03 PLCC44

4129G–CAN–05/03 Datasheet Change Log for T89C51CC01 Changes from 4129F- 11/02 to 4129G-04/03 1. Changed the endurance of Flash to 100, 000 Write/Erase cycles. 2. Added note on Flash retention formula for V IH1, in Section "DC Parameters for Standard Voltage", page 138.

i Table of Contents

Printed on recycled paper. Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company ’s standard warranty which is detailed in Atmel ’s Terms and Conditions located on the Company ’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time wi thout notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel ’s products are not authorized for use as critical components in life support devices or systems. Atmel Corporation Atmel Operations

2325 Orchard Parkway

San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza

77 Mody Road Tsimshatsui

Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Memory San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers San Jose, CA 95131 Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602

44306 Nantes Cedex 3, France

13106 Rousset Cedex, France

1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535

74025 Heilbronn, Germany

1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906 Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123

38521 Saint-Egreve Cedex, France

literature@atmel.com Web Site http://www.atmel.com 4129G–CAN–05/03 /xM © Atmel Corporation 2003 . All rights reserved. Atmel ® and combinations thereof are the registered trademarksof Atmel Corporation or its subsidiaries. Other terms and product names may be the trade- marks of others.