C8051F12x 13x PDF
C8051F12x 13x PDF
C8051F12x 13x PDF
UART1
AMUX
SMBus
ADC SPI Bus Port 2
+ +
PCA Port 3
- - TEMP
SENSOR
Timer 0
VOLTAGE
COMPARATORS
Timer 1 Port 4
Timer 2
Port 5
12-Bit Timer 3
8-bit
AMUX
DAC Port 6
PGA 500ksps Timer 4
ADC 12-Bit Port 7
DAC
C8051F12x Only 64 pin 100 pin
NOTES:
2 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Table of Contents
1. System Overview.................................................................................................... 19
1.1. CIP-51™ Microcontroller Core.......................................................................... 27
1.1.1. Fully 8051 Compatible.............................................................................. 27
1.1.2. Improved Throughput ............................................................................... 27
1.1.3. Additional Features .................................................................................. 28
1.2. On-Chip Memory............................................................................................... 29
1.3. JTAG Debug and Boundary Scan..................................................................... 30
1.4. 16 x 16 MAC (Multiply and Accumulate) Engine............................................... 31
1.5. Programmable Digital I/O and Crossbar ........................................................... 32
1.6. Programmable Counter Array ........................................................................... 33
1.7. Serial Ports ....................................................................................................... 33
1.8. 12 or 10-Bit Analog to Digital Converter ........................................................... 34
1.9. 8-Bit Analog to Digital Converter....................................................................... 35
1.10.12-bit Digital to Analog Converters................................................................... 36
1.11.Analog Comparators......................................................................................... 37
2. Absolute Maximum Ratings .................................................................................. 38
3. Global DC Electrical Characteristics .................................................................... 39
4. Pinout and Package Definitions............................................................................ 41
5. ADC0 (12-Bit ADC, C8051F120/1/4/5 Only)........................................................... 55
5.1. Analog Multiplexer and PGA............................................................................. 55
5.2. ADC Modes of Operation.................................................................................. 57
5.2.1. Starting a Conversion............................................................................... 57
5.2.2. Tracking Modes........................................................................................ 58
5.2.3. Settling Time Requirements ..................................................................... 59
5.3. ADC0 Programmable Window Detector ........................................................... 66
6. ADC0 (10-Bit ADC, C8051F122/3/6/7 and C8051F13x Only)................................ 73
6.1. Analog Multiplexer and PGA............................................................................. 73
6.2. ADC Modes of Operation.................................................................................. 75
6.2.1. Starting a Conversion............................................................................... 75
6.2.2. Tracking Modes........................................................................................ 76
6.2.3. Settling Time Requirements ..................................................................... 77
6.3. ADC0 Programmable Window Detector ........................................................... 84
7. ADC2 (8-Bit ADC, C8051F12x Only)...................................................................... 91
7.1. Analog Multiplexer and PGA............................................................................. 91
7.2. ADC2 Modes of Operation................................................................................ 92
7.2.1. Starting a Conversion............................................................................... 92
7.2.2. Tracking Modes........................................................................................ 92
7.2.3. Settling Time Requirements ..................................................................... 94
7.3. ADC2 Programmable Window Detector ......................................................... 100
7.3.1. Window Detector In Single-Ended Mode ............................................... 100
7.3.2. Window Detector In Differential Mode.................................................... 101
Rev. 1.4 3
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
4 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 5
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
6 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 7
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
8 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
List of Figures
1. System Overview
Figure 1.1. C8051F120/124 Block Diagram ............................................................. 21
Figure 1.2. C8051F121/125 Block Diagram ............................................................. 22
Figure 1.3. C8051F122/126 Block Diagram ............................................................. 23
Figure 1.4. C8051F123/127 Block Diagram ............................................................. 24
Figure 1.5. C8051F130/132 Block Diagram ............................................................. 25
Figure 1.6. C8051F131/133 Block Diagram ............................................................. 26
Figure 1.7. On-Board Clock and Reset .................................................................... 28
Figure 1.8. On-Chip Memory Map............................................................................ 29
Figure 1.9. Development/In-System Debug Diagram............................................... 30
Figure 1.10. MAC0 Block Diagram ........................................................................... 31
Figure 1.11. Digital Crossbar Diagram ..................................................................... 32
Figure 1.12. PCA Block Diagram.............................................................................. 33
Figure 1.13. 12-Bit ADC Block Diagram ................................................................... 34
Figure 1.14. 8-Bit ADC Diagram............................................................................... 35
Figure 1.15. DAC System Block Diagram ................................................................ 36
Figure 1.16. Comparator Block Diagram .................................................................. 37
2. Absolute Maximum Ratings
3. Global DC Electrical Characteristics
4. Pinout and Package Definitions
Figure 4.1. C8051F120/2/4/6 Pinout Diagram (TQFP-100) ..................................... 49
Figure 4.2. C8051F130/2 Pinout Diagram (TQFP-100) ........................................... 50
Figure 4.3. TQFP-100 Package Drawing ................................................................. 51
Figure 4.4. C8051F121/3/5/7 Pinout Diagram (TQFP-64) ....................................... 52
Figure 4.5. C8051F131/3 Pinout Diagram (TQFP-64) ............................................. 53
Figure 4.6. TQFP-64 Package Drawing ................................................................... 54
5. ADC0 (12-Bit ADC, C8051F120/1/4/5 Only)
Figure 5.1. 12-Bit ADC0 Functional Block Diagram ................................................. 55
Figure 5.2. Typical Temperature Sensor Transfer Function..................................... 56
Figure 5.3. ADC0 Track and Conversion Example Timing....................................... 58
Figure 5.4. ADC0 Equivalent Input Circuits.............................................................. 59
Figure 5.5. ADC0 Data Word Example .................................................................... 65
Figure 5.6. 12-Bit ADC0 Window Interrupt Example:
Right Justified Single-Ended Data ......................................................... 68
Figure 5.7. 12-Bit ADC0 Window Interrupt Example:
Right Justified Differential Data ............................................................. 69
Figure 5.8. 12-Bit ADC0 Window Interrupt Example:
Left Justified Single-Ended Data ........................................................... 70
Figure 5.9. 12-Bit ADC0 Window Interrupt Example:
Left Justified Differential Data................................................................ 71
Rev. 1.4 9
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
10 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 11
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Figure 20.4. 4-Wire Single Master and Slave Mode Connection Diagram ............. 276
Figure 20.5. Master Mode Data/Clock Timing ........................................................ 278
Figure 20.6. Slave Mode Data/Clock Timing (CKPHA = 0) .................................... 279
Figure 20.7. Slave Mode Data/Clock Timing (CKPHA = 1) .................................... 279
Figure 20.8. SPI Master Timing (CKPHA = 0)........................................................ 283
Figure 20.9. SPI Master Timing (CKPHA = 1)........................................................ 283
Figure 20.10. SPI Slave Timing (CKPHA = 0)........................................................ 284
Figure 20.11. SPI Slave Timing (CKPHA = 1)........................................................ 284
21. UART0
Figure 21.1. UART0 Block Diagram ....................................................................... 287
Figure 21.2. UART0 Mode 0 Timing Diagram ........................................................ 288
Figure 21.3. UART0 Mode 0 Interconnect.............................................................. 288
Figure 21.4. UART0 Mode 1 Timing Diagram ....................................................... 289
Figure 21.5. UART0 Modes 2 and 3 Timing Diagram ............................................ 291
Figure 21.6. UART0 Modes 1, 2, and 3 Interconnect Diagram .............................. 292
Figure 21.7. UART Multi-Processor Mode Interconnect Diagram .......................... 294
22. UART1
Figure 22.1. UART1 Block Diagram ....................................................................... 299
Figure 22.2. UART1 Baud Rate Logic .................................................................... 300
Figure 22.3. UART Interconnect Diagram .............................................................. 301
Figure 22.4. 8-Bit UART Timing Diagram.............................................................. 301
Figure 22.5. 9-Bit UART Timing Diagram............................................................... 302
Figure 22.6. UART Multi-Processor Mode Interconnect Diagram .......................... 303
23. Timers
Figure 23.1. T0 Mode 0 Block Diagram.................................................................. 310
Figure 23.2. T0 Mode 2 Block Diagram.................................................................. 311
Figure 23.3. T0 Mode 3 Block Diagram.................................................................. 312
Figure 23.4. T2, 3, and 4 Capture Mode Block Diagram ........................................ 318
Figure 23.5. Tn Auto-reload (T2,3,4) and Toggle Mode (T2,4) Block Diagram ..... 319
24. Programmable Counter Array
Figure 24.1. PCA Block Diagram............................................................................ 325
Figure 24.2. PCA Counter/Timer Block Diagram.................................................... 326
Figure 24.3. PCA Interrupt Block Diagram ............................................................. 328
Figure 24.4. PCA Capture Mode Diagram.............................................................. 329
Figure 24.5. PCA Software Timer Mode Diagram .................................................. 330
Figure 24.6. PCA High Speed Output Mode Diagram............................................ 331
Figure 24.7. PCA Frequency Output Mode ............................................................ 332
Figure 24.8. PCA 8-Bit PWM Mode Diagram ......................................................... 333
Figure 24.9. PCA 16-Bit PWM Mode...................................................................... 334
25. JTAG (IEEE 1149.1)
12 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
List Of Tables
1. System Overview
Table 1.1. Product Selection Guide ......................................................................... 20
2. Absolute Maximum Ratings
Table 2.1. Absolute Maximum Ratings .................................................................... 38
3. Global DC Electrical Characteristics
Table 3.1. Global DC Electrical Characteristics
(C8051F120/1/2/3 and C8051F130/1/2/3) ............................................. 39
Table 3.2. Global DC Electrical Characteristics (C8051F124/5/6/7) ....................... 40
4. Pinout and Package Definitions
Table 4.1. Pin Definitions ......................................................................................... 41
5. ADC0 (12-Bit ADC, C8051F120/1/4/5 Only)
Table 5.1. 12-Bit ADC0 Electrical Characteristics (C8051F120/1/4/5) .................... 72
6. ADC0 (10-Bit ADC, C8051F122/3/6/7 and C8051F13x Only)
Table 6.1. 10-Bit ADC0 Electrical Characteristics
(C8051F122/3/6/7 and C8051F13x) ...................................................... 90
7. ADC2 (8-Bit ADC, C8051F12x Only)
Table 7.1. ADC2 Electrical Characteristics ............................................................ 103
8. DACs, 12-Bit Voltage Mode (C8051F12x Only)
Table 8.1. DAC Electrical Characteristics .............................................................. 111
9. Voltage Reference
Table 9.1. Voltage Reference Electrical Characteristics ....................................... 118
10. Comparators
Table 10.1. Comparator Electrical Characteristics ................................................ 126
11. CIP-51 Microcontroller
Table 11.1. CIP-51 Instruction Set Summary ........................................................ 129
Table 11.2. Special Function Register (SFR) Memory Map .................................. 144
Table 11.3. Special Function Registers ................................................................. 146
Table 11.4. Interrupt Summary .............................................................................. 155
12. Multiply And Accumulate (MAC0)
Table 12.1. MAC0 Rounding (MAC0SAT = 0) ....................................................... 168
13. Reset Sources
Table 13.1. Reset Electrical Characteristics .......................................................... 183
14. Oscillators
Table 14.1. Oscillator Electrical Characteristics .................................................... 185
Table 14.2. PLL Frequency Characteristics .......................................................... 195
Table 14.3. PLL Lock Timing Characteristics ........................................................ 196
15. Flash Memory
Table 15.1. Flash Electrical Characteristics .......................................................... 200
16. Branch Target Cache
17. External Data Memory Interface and On-Chip XRAM
Table 17.1. AC Parameters for External Memory Interface ................................... 233
Rev. 1.4 13
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
14 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
List of Registers
SFR Definition 5.1. AMX0CF: AMUX0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 60
SFR Definition 5.2. AMX0SL: AMUX0 Channel Select . . . . . . . . . . . . . . . . . . . . . . . . 61
SFR Definition 5.3. ADC0CF: ADC0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
SFR Definition 5.4. ADC0CN: ADC0 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
SFR Definition 5.5. ADC0H: ADC0 Data Word MSB . . . . . . . . . . . . . . . . . . . . . . . . . . 64
SFR Definition 5.6. ADC0L: ADC0 Data Word LSB . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
SFR Definition 5.7. ADC0GTH: ADC0 Greater-Than Data High Byte . . . . . . . . . . . . . 66
SFR Definition 5.8. ADC0GTL: ADC0 Greater-Than Data Low Byte . . . . . . . . . . . . . . 66
SFR Definition 5.9. ADC0LTH: ADC0 Less-Than Data High Byte . . . . . . . . . . . . . . . . 67
SFR Definition 5.10. ADC0LTL: ADC0 Less-Than Data Low Byte . . . . . . . . . . . . . . . 67
SFR Definition 6.1. AMX0CF: AMUX0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 78
SFR Definition 6.2. AMX0SL: AMUX0 Channel Select . . . . . . . . . . . . . . . . . . . . . . . . . 79
SFR Definition 6.3. ADC0CF: ADC0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
SFR Definition 6.4. ADC0CN: ADC0 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
SFR Definition 6.5. ADC0H: ADC0 Data Word MSB . . . . . . . . . . . . . . . . . . . . . . . . . . 82
SFR Definition 6.6. ADC0L: ADC0 Data Word LSB . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
SFR Definition 6.7. ADC0GTH: ADC0 Greater-Than Data High Byte . . . . . . . . . . . . . 84
SFR Definition 6.8. ADC0GTL: ADC0 Greater-Than Data Low Byte . . . . . . . . . . . . . . 84
SFR Definition 6.9. ADC0LTH: ADC0 Less-Than Data High Byte . . . . . . . . . . . . . . . . 85
SFR Definition 6.10. ADC0LTL: ADC0 Less-Than Data Low Byte . . . . . . . . . . . . . . . 85
SFR Definition 7.1. AMX2CF: AMUX2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 95
SFR Definition 7.2. AMX2SL: AMUX2 Channel Select . . . . . . . . . . . . . . . . . . . . . . . . 96
SFR Definition 7.3. ADC2CF: ADC2 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
SFR Definition 7.4. ADC2CN: ADC2 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
SFR Definition 7.5. ADC2: ADC2 Data Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
SFR Definition 7.6. ADC2GT: ADC2 Greater-Than Data Byte . . . . . . . . . . . . . . . . . . 102
SFR Definition 7.7. ADC2LT: ADC2 Less-Than Data Byte . . . . . . . . . . . . . . . . . . . . 102
SFR Definition 8.1. DAC0H: DAC0 High Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
SFR Definition 8.2. DAC0L: DAC0 Low Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
SFR Definition 8.3. DAC0CN: DAC0 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
SFR Definition 8.4. DAC1H: DAC1 High Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
SFR Definition 8.5. DAC1L: DAC1 Low Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
SFR Definition 8.6. DAC1CN: DAC1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
SFR Definition 9.1. REF0CN: Reference Control (C8051F120/2/4/6) . . . . . . . . . . . . 114
SFR Definition 9.2. REF0CN: Reference Control (C8051F121/3/5/7) . . . . . . . . . . . . 116
SFR Definition 9.3. REF0CN: Reference Control (C8051F130/1/2/3) . . . . . . . . . . . . 117
SFR Definition 10.1. CPT0CN: Comparator0 Control . . . . . . . . . . . . . . . . . . . . . . . . . 122
SFR Definition 10.2. CPT0MD: Comparator0 Mode Selection . . . . . . . . . . . . . . . . . 123
SFR Definition 10.3. CPT1CN: Comparator1 Control . . . . . . . . . . . . . . . . . . . . . . . . . 124
SFR Definition 10.4. CPT1MD: Comparator1 Mode Selection . . . . . . . . . . . . . . . . . 125
SFR Definition 11.1. PSBANK: Program Space Bank Select . . . . . . . . . . . . . . . . . . 134
SFR Definition 11.2. SFRPGCN: SFR Page Control . . . . . . . . . . . . . . . . . . . . . . . . . 142
SFR Definition 11.3. SFRPAGE: SFR Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Rev. 1.4 15
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
16 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 17
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
18 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
1. System Overview
The C8051F12x and C8051F13x device families are fully integrated mixed-signal System-on-a-Chip
MCUs with 64 digital I/O pins (100-pin TQFP) or 32 digital I/O pins (64-pin TQFP).
Highlighted features are listed below. Refer to Table 1.1 for specific product feature selection.
With on-chip VDD monitor, Watchdog Timer, and clock oscillator, the C8051F12x and C8051F13x devices
are truly stand-alone System-on-a-Chip solutions. All analog and digital peripherals are enabled/disabled
and configured by user firmware. The Flash memory can be reprogrammed even in-circuit, providing non-
volatile data storage, and also allowing field upgrades of the 8051 firmware.
On-board JTAG debug circuitry allows non-intrusive (uses no on-chip resources), full speed, in-circuit
debugging using the production MCU installed in the final application. This debug system supports inspec-
tion and modification of memory and registers, setting breakpoints, watchpoints, single stepping, run and
halt commands. All analog and digital peripherals are fully functional while debugging using JTAG.
Each MCU is specified for operation over the industrial temperature range (–45 to +85 °C). The Port I/O,
RST, and JTAG pins are tolerant for input signals up to 5 V. The devices are available in 100-pin TQFP or
64-pin TQFP packaging. Table 1.1 lists the specific device features and package offerings for each part
number. Figure 1.1 through Figure 1.6 show functional block diagrams for each device.
Rev. 1.4 19
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
2-cycle 16 by 16 MAC
Analog Comparators
Temperature Sensor
Voltage Reference
Digital Port I/O’s
Timers (16-bit)
Flash Memory
DAC Outputs
MIPS (Peak)
SMBus/I2C
Package
UARTS
RAM
20 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+
AV+ Analog Power SMBus C
AGND
AGND 8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8 kB
XRAM Timer 3/
B
A
Drv P2.7
MONEN
VDD
Monitor
WDT 1 RTC
P0, P1,
R
P3 P3.0
P2, P3 Drv
External Data P3.7
XTAL1 External Oscillator Latches
XTAL2 Circuit Memory Bus
PLL
Circuitry
System
Clock
C Crossbar
Config.
Calibrated Internal
Oscillator
o 128 kB
FLASH A
VREF2
ADC 8:1
VREF VREF r 500 ksps
(8-Bit)
Prog
Gain
M
U
X
VREFD
DAC1
DAC1
(12-Bit)
e 64x4 byte
C P4 Latch
P4.0
Rev. 1.4 21
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+ SMBus C
Analog Power
AGND
8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8 kB
XRAM Timer 3/
B
A
Drv P2.7
RTC
MONEN
VDD
Monitor
WDT 1 P0, P1,
R
P3 P3.0
Calibrated Internal
Oscillator
o 128 kB
FLASH
ADC
500 ksps
Prog
A
M 8:1
Gain
U
VREF VREF r (8-Bit)
AV+
X
DAC1
DAC1
(12-Bit)
e 64x4 byte
C
VREFA
P4 Latch
cache Bus Control P4
T DRV
DAC0 L
DAC0
(12-Bit)
VREFA
P5 Latch P5
AIN0.0 A
AIN0.1 Address Bus
DRV
d
AIN0.2 A ADC d P6 Latch P6
AIN0.3 M Prog
AIN0.4 U Gain 100 ksps r DRV
AIN0.5
AIN0.6
X (12-Bit)
AIN0.7
TEMP
D P7 Latch P7
Data Bus
SENSOR a DRV
CP0+
CP0 t
CP0-
a
CP1+
CP1
CP1-
22 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+
AV+ Analog Power SMBus C
AGND
AGND
8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8 kB
XRAM Timer 3/
B
A
Drv P2.7
RTC
MONEN
VDD
Monitor
WDT 1 P0, P1,
R
P3 P3.0
Calibrated Internal
Oscillator
o 128 kB
FLASH A
VREF2
ADC 8:1
VREF
VREFD
VREF r 500 ksps
(8-Bit)
Prog
Gain
M
U
X
DAC1
DAC1
(12-Bit)
e 64x4 byte
C P4 Latch
P4.0
Rev. 1.4 23
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+ SMBus C
Analog Power
AGND
8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8 kb
XRAM Timer 3/
B
A
Drv P2.7
RTC
MONEN
VDD
Monitor
WDT 1 P0, P1,
R
P3 P3.0
Calibrated Internal
Oscillator
o 128 kb
FLASH
ADC
500 ksps
Prog
A
M 8:1
Gain
U
VREF VREF r (8-Bit)
AV+
X
DAC1
DAC1
(12-Bit)
e 64x4 byte
C
VREFA
P4 Latch
cache Bus Control P4
T DRV
DAC0 L
DAC0
(12-Bit)
VREFA
P5 Latch P5
AIN0.0 A
AIN0.1 Address Bus
DRV
d
AIN0.2 A ADC d P6 Latch P6
AIN0.3 M Prog
AIN0.4 U Gain 100 ksps r DRV
AIN0.5
AIN0.6
X (10-Bit)
AIN0.7
TEMP
D P7 Latch P7
Data Bus
SENSOR a DRV
CP0+
CP0 t
CP0-
a
CP1+
CP1
CP1-
24 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+
AV+ Analog Power SMBus C
AGND
AGND
8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8kbyte
XRAM Timer 3/
B
A
Drv P2.7
RTC
MONEN
VDD
Monitor
WDT 1 P0, P1,
R
P3 P3.0
Calibrated Internal
Oscillator
o FLASH
128kbyte
VREF VREF r (‘F130)
64kbyte
e (‘F132)
Bus Control C P4 Latch
P4.0
P4 P4.4
T DRV P4.5/ALE
L P4.6/RD
64x4 byte P4.7/WR
VREF0 cache P5 Latch P5 P5.0/A8
AIN0.0 A
AIN0.1 Address Bus
DRV P5.7/A15
d
AIN0.2 A ADC d P6 Latch P6 P6.0/A0
AIN0.3 M Prog
AIN0.4 U Gain 100ksps r DRV P6.7/A7
AIN0.5
AIN0.6
X (10-Bit)
AIN0.7
TEMP
D P7 Latch P7 P7.0/D0
Data Bus
SENSOR a DRV
CP0+ P7.7/D7
CP0 t
CP0-
a
CP1+
CP1
CP1-
Rev. 1.4 25
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD
VDD
Port I/O
VDD Config.
Digital Power
DGND
DGND UART0 P0.0
P0
DGND
SFR Bus UART1 Drv P0.7
AV+ SMBus C
Analog Power
AGND
8 256 byte
SPI Bus
R
O
P1
Drv
P1.0/AIN2.0
P1.7/AIN2.7
TCK PCA
TMS
TDI
JTAG
Logic
Boundary Scan
Debug HW
0 RAM
Timers 0,
S
S P2.0
TDO P2
1, 2, 4
RST Reset 5 8kbyte
XRAM Timer 3/
B
A
Drv P2.7
RTC
MONEN
VDD
Monitor
WDT 1 P0, P1,
R
P3 P3.0
Calibrated Internal
Oscillator
o FLASH
128kbyte
VREF VREF r (‘F131)
64kbyte
e (‘F133)
Bus Control C P4 Latch P4
T DRV
L
64x4 byte
VREF0
cache P5 Latch P5
AIN0.0 A
AIN0.1 Address Bus
DRV
d
AIN0.2 A ADC d P6 Latch P6
AIN0.3 M Prog
AIN0.4 U Gain 100ksps r DRV
AIN0.5
AIN0.6
X (10-Bit)
AIN0.7
TEMP
D P7 Latch P7
Data Bus
SENSOR a DRV
CP0+
CP0 t
CP0-
a
CP1+
CP1
CP1-
26 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The CIP-51 has a total of 109 instructions. The table below shows the total number of instructions that
require each execution time.
With the CIP-51's maximum system clock at 100 MHz, the C8051F120/1/2/3 and C8051F130/1/2/3 have a
peak throughput of 100 MIPS (the C8051F124/5/6/7 have a peak throughput of 50 MIPS).
Rev. 1.4 27
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The extended interrupt handler provides 20 interrupt sources into the CIP-51 (as opposed to 7 for the stan-
dard 8051), allowing the numerous analog and digital peripherals to interrupt the controller. An interrupt
driven system requires less intervention by the MCU, giving it more effective throughput. The extra inter-
rupt sources are very useful when building multi-tasking, real-time systems.
There are up to seven reset sources for the MCU: an on-board VDD monitor, a Watchdog Timer, a missing
clock detector, a voltage level detection from Comparator0, a forced software reset, the CNVSTR0 input
pin, and the RST pin. The RST pin is bi-directional, accommodating an external reset, or allowing the inter-
nally generated POR to be output on the RST pin. Each reset source except for the VDD monitor and Reset
Input pin may be disabled by the user in software; the VDD monitor is enabled/disabled via the MONEN
pin. The Watchdog Timer may be permanently enabled in software after a power-on reset during MCU ini-
tialization.
The MCU has an internal, stand alone clock generator which is used by default as the system clock after
any reset. If desired, the clock source may be switched on the fly to the external oscillator, which can use a
crystal, ceramic resonator, capacitor, RC, or external clock source to generate the system clock. This can
be extremely useful in low power applications, allowing the MCU to run from a slow (power saving) exter-
nal crystal source, while periodically switching to the 24.5 MHz internal oscillator as needed. Additionally,
an on-chip PLL is provided to achieve higher system clock speeds for increased throughput.
VDD
CNVSTR
(Port I/O) Crossbar Supply
(CNVSTR Monitor
reset Supply
enable) +
-
Reset RST
Timeout (wired-OR)
Comparator0
CP0+
+
-
CP0- (CP0
reset
enable)
Reset
Missing WDT Funnel
Clock
Detector
(one-
shot)
EN EN PRE
Internal
Enable
Enable
Strobe
Clock
MCD
WDT
WDT
Generator
28 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The devices include an on-chip 8k byte RAM block and an external memory interface (EMIF) for accessing
off-chip data memory. The on-chip 8k byte block can be addressed over the entire 64k external data mem-
ory address range (overlapping 8k boundaries). External data memory address space can be mapped to
on-chip memory only, off-chip memory only, or a combination of the two (addresses up to 8k directed to on-
chip, above 8k directed to EMIF). The EMIF is also configurable for multiplexed or non-multiplexed
address/data lines.
On the C8051F12x and C8051F130/1, the MCU’s program memory consists of 128 k bytes of banked
Flash memory. The 1024 bytes from addresses 0x1FC00 to 0x1FFFF are reserved. On the C8051F132/3,
the MCU’s program memory consists of 64 k bytes of Flash memory. This memory may be reprogrammed
in-system in 1024 byte sectors, and requires no special off-chip programming voltage.
On all devices, there are also two 128 byte sectors at addresses 0x20000 to 0x200FF, which may be used
by software for data storage. See Figure 1.8 for the MCU system memory map.
0x00000
EXTERNAL DATA ADDRESS SPACE
C8051F132/3
0x200FF 0xFFFF
Scrachpad Memory
0x20000 (DATA only)
FLASH
(In-System 0x2000
Programmable in 1024 0x1FFF
Byte Sectors) XRAM - 8192 Bytes
(accessable using MOVX
0x0000 instruction)
0x00000
Rev. 1.4 29
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Silicon Labs' debugging system supports inspection and modification of memory and registers, break-
points, watchpoints, a stack monitor, and single stepping. No additional target RAM, program memory, tim-
ers, or communications channels are required. All the digital and analog peripherals are functional and
work correctly while debugging. All the peripherals (except for the ADC and SMBus) are stalled when the
MCU is halted, during single stepping, or at a breakpoint in order to keep them synchronized.
The C8051F120DK development kit provides all the hardware and software necessary to develop applica-
tion code and perform in-circuit debugging with the C8051F12x or C8051F13x MCUs.
The kit includes a Windows (95 or later) development environment, a serial adapter for connecting to the
JTAG port, and a target application board with a C8051F120 MCU installed. All of the necessary commu-
nication cables and a wall-mount power supply are also supplied with the development kit. Silicon Labs’
debug environment is a vastly superior configuration for developing and debugging embedded applications
compared to standard MCU emulators, which use on-board "ICE Chips" and target cables and require the
MCU in the application board to be socketed. Silicon Labs' debug environment both increases ease of use
and preserves the performance of the precision, on-chip analog peripherals.
TARGET PCB
C8051
F12x/13x
30 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
MAC0MS
MAC0FM
16 x 16 Multiply
1 0
0
40 bit Add
MAC0 Accumulator
MAC0OVR MAC0ACC3 MAC0ACC2 MAC0ACC1 MAC0ACC0
MAC0SO
MAC0FM
MAC0SC
MAC0SD
MAC0CA
MAC0N
MAC0Z
MAC0RNDH MAC0RNDL
MAC0CF MAC0STA
Figure 1.10. MAC0 Block Diagram
Rev. 1.4 31
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Each Port I/O pin can be configured as either a push-pull or open-drain output. Also, the "weak pullups"
which are normally fixed on an 8051 can be globally disabled, providing additional power saving capabili-
ties for low-power applications.
Perhaps the most unique enhancement is the Digital Crossbar. This is a large digital switching network that
allows mapping of internal digital system resources to Port I/O pins on P0, P1, P2, and P3. (See
Figure 1.11) Unlike microcontrollers with standard multiplexed digital I/O, all combinations of functions are
supported.
The on-chip counter/timers, serial buses, HW interrupts, ADC Start of Conversion inputs, comparator out-
puts, and other digital signals in the controller can be configured to appear on the Port I/O pins specified in
the Crossbar Control registers. This allows the user to select the exact mix of general purpose Port I/O and
digital resources needed for the particular application.
2 External
SMBus Priority Pins
2 Decoder
UART1 P0.0
P0 Highest
(Internal Digital Signals)
8
7 I/O Priority
PCA Cells P0.7
Comptr. 2
Outputs Digital
P1 P1.0
Crossbar 8
I/O
T0, T1, Cells P1.7
T2, T2EX, 8
T4,T4EX
/INT0,
/INT1 P2 P2.0
8
I/O
Cells P2.7
Lowest /SYSCLK divided by 1,2,4, or 8
Priority CNVSTR0/2 2
P3 P3.0
8 8
I/O Lowest
Cells P3.7 Priority
P0
(P0.0-P0.7)
P1
(P1.0-P1.7) To External
Port Memory
Latches 8 Interface
To ADC2 Input
(EMIF)
P2 (‘F12x Only)
(P2.0-P2.7)
P3
(P3.0-P3.7)
32 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Each capture/compare module can be configured to operate in one of six modes: Edge-Triggered Capture,
Software Timer, High Speed Output, Frequency Output, 8-Bit Pulse Width Modulator, or 16-Bit Pulse Width
Modulator. The PCA Capture/Compare Module I/O and External Clock Input are routed to the MCU Port I/
O via the Digital Crossbar.
SYSCLK/12
SYSCLK/4
Timer 0 Overflow PCA
CLOCK 16-Bit Counter/Timer
ECI
MUX
SYSCLK
External Clock/8
CEX1
CEX2
CEX3
CEX4
CEX5
ECI
Crossbar
Port I/O
Rev. 1.4 33
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The ADC is under full control of the CIP-51 microcontroller via its associated Special Function Registers.
One input channel is tied to an internal temperature sensor, while the other eight channels are available
externally. Each pair of the eight external input channels can be configured as either two single-ended
inputs or a single differential input. The system controller can also put the ADC into shutdown mode to
save power.
A programmable gain amplifier follows the analog multiplexer. The gain can be set in software from 0.5 to
16 in powers of 2. The gain stage can be especially useful when different ADC input channels have widely
varied input voltage signals, or when it is necessary to "zoom in" on a signal with a large DC offset (in dif-
ferential mode, a DAC could be used to provide the DC offset).
Conversions can be started in four ways; a software command, an overflow of Timer 2, an overflow of
Timer 3, or an external signal input. This flexibility allows the start of conversion to be triggered by software
events, external HW signals, or a periodic timer overflow signal. Conversion completions are indicated by a
status bit and an interrupt (if enabled). The resulting 10 or 12-bit data word is latched into two SFRs upon
completion of a conversion. The data can be right or left justified in these registers under software control.
Window Compare registers for the ADC data can be configured to interrupt the controller when ADC data
is within or outside of a specified range. The ADC can monitor a key voltage continuously in background
mode, but not interrupt the controller unless the converted data is within the specified window.
Analog Multiplexer
Window
Configuration, Control, and Data Window Compare
Compare
Registers Logic
Interrupt
AIN0.0 +
AIN0.1 -
Programmable Gain
AIN0.2 + Amplifier
AIN0.3 - 9-to-1
AMUX
AV+ 12-Bit
AIN0.4 +
(SE or + SAR 12 ADC Data
AIN0.5 - DIFF) X - Registers
34 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
A programmable gain amplifier follows the analog multiplexer. The gain stage can be especially useful
when different ADC input channels have widely varied input voltage signals, or when it is necessary to
"zoom in" on a signal with a large DC offset (in differential mode, a DAC could be used to provide the DC
offset). The PGA gain can be set in software to 0.5, 1, 2, or 4.
A flexible conversion scheduling system allows ADC2 conversions to be initiated by software commands,
timer overflows, or an external input signal. ADC2 conversions may also be synchronized with ADC0 soft-
ware-commanded conversions. Conversion completions are indicated by a status bit and an interrupt (if
enabled), and the resulting 8-bit data word is latched into an SFR upon completion.
Analog Multiplexer
Window Window
Configuration, Control, and Data Registers Compare Compare
Logic Interrupt
AIN2.0
AIN2.1
Programmable Gain
AIN2.2 Amplifier
AIN2.3
8-to-1
AV+ 8-Bit
AIN2.4 8 ADC Data
AMUX + SAR
AIN2.5 X -
Register
Write to AD2BUSY
External VREF Timer 3 Overflow
Pin VREF Start Conversion
CNVSTR2 Input
AV+ Timer 2 Overflow
Write to AD0BUSY
(synchronized with
ADC0)
Rev. 1.4 35
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The DACs are voltage output mode and include a flexible output scheduling mechanism. This scheduling
mechanism allows DAC output updates to be forced by a software write or scheduled on a Timer 2, 3, or 4
overflow. The DAC voltage reference is supplied from the dedicated VREFD input pin on the 100-pin TQFP
devices or via the internal Voltage reference on the 64-pin TQFP devices. The DACs are especially useful
as references for the comparators or offsets for the differential inputs of the ADCs.
DAC0H
Timer 3
Timer 4
Timer 2
DAC0EN
DAC0CN
DAC0MD1
DAC0MD0
DAC0DF2 REF
DAC0DF1 AV+
DAC0DF0
DAC0H
Latch
8 8
Dig. MUX
12
DAC0
DAC0
DAC0L
Latch
8 8
AGND
DAC1H
Timer 3
Timer 4
Timer 2
DAC1EN
DAC1CN
DAC1MD1
DAC1MD0
DAC1DF2 REF
DAC1DF1
DAC1DF0 AV+
DAC1H
Latch
8 8
Dig. MUX
12
DAC1
DAC1
DAC1L
Latch
8 8
AGND
36 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
CPn Output
(Port I/O) CROSSBAR
2 Comparators
SFR's
CPn+ CIP-51
+
and
CPn (Data
Interrupt
CPn- - and
Handler
Control)
Rev. 1.4 37
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
38 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 39
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Analog Supply Current with Internal REF, ADC, DAC, Com- — 0.2 — µA
analog sub-systems inactive parators all disabled, oscillator
disabled
Notes:
1. Analog Supply AV+ must be greater than 1 V for VDD monitor to operate.
2. SYSCLK is the internal device clock. For operational speeds in excess of 30 MHz, SYSCLK must be derived
from the phase-locked loop (PLL).
3. SYSCLK must be at least 32 kHz to enable debugging.
40 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
VDD 37, 24, 37, 24, Digital Supply Voltage. Must be tied to +2.7 to
64, 90 41, 57 64, 90 41, 57 +3.6 V.
DGND 38, 25, 38, 25, Digital Ground. Must be tied to Ground.
63, 89 40, 56 63, 89 40, 56
TDO 4 61 4 61 D Out JTAG Test Data Output with internal pullup. Data
is shifted out on TDO on the falling edge of TCK.
TDO output is a tri-state driver.
XTAL1 26 17 26 17 A In Crystal Input. This pin is the return for the inter-
nal oscillator circuit for a crystal or ceramic reso-
nator. For a precision internal clock, connect a
crystal or ceramic resonator from XTAL1 to
XTAL2. If overdriven by an external CMOS
clock, this becomes the system clock.
Rev. 1.4 41
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
42 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
P0.0 62 55 62 55 D I/O Port 0.0. See Port Input/Output section for com-
plete description.
P0.1 61 54 61 54 D I/O Port 0.1. See Port Input/Output section for com-
plete description.
P0.2 60 53 60 53 D I/O Port 0.2. See Port Input/Output section for com-
plete description.
P0.3 59 52 59 52 D I/O Port 0.3. See Port Input/Output section for com-
plete description.
P0.4 58 51 58 51 D I/O Port 0.4. See Port Input/Output section for com-
plete description.
Rev. 1.4 43
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
A9m/A1/P2.1 45 36 45 36 D I/O Port 2.1. See Port Input/Output section for com-
plete description.
A10m/A2/P2.2 44 35 44 35 D I/O Port 2.2. See Port Input/Output section for com-
plete description.
A11m/A3/P2.3 43 34 43 34 D I/O Port 2.3. See Port Input/Output section for com-
plete description.
A12m/A4/P2.4 42 33 42 33 D I/O Port 2.4. See Port Input/Output section for com-
plete description.
A13m/A5/P2.5 41 32 41 32 D I/O Port 2.5. See Port Input/Output section for com-
plete description.
A14m/A6/P2.6 40 31 40 31 D I/O Port 2.6. See Port Input/Output section for com-
plete description.
A15m/A7/P2.7 39 30 39 30 D I/O Port 2.7. See Port Input/Output section for com-
plete description.
44 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD1/D1/P3.1 53 46 53 46 D I/O Port 3.1. See Port Input/Output section for com-
plete description.
AD2/D2/P3.2 52 45 52 45 D I/O Port 3.2. See Port Input/Output section for com-
plete description.
AD3/D3/P3.3 51 44 51 44 D I/O Port 3.3. See Port Input/Output section for com-
plete description.
AD4/D4/P3.4 50 43 50 43 D I/O Port 3.4. See Port Input/Output section for com-
plete description.
AD5/D5/P3.5 49 42 49 42 D I/O Port 3.5. See Port Input/Output section for com-
plete description.
AD6/D6/P3.6 48 39 48 39 D I/O Port 3.6. See Port Input/Output section for com-
plete description.
AD7/D7/P3.7 47 38 47 38 D I/O Port 3.7. See Port Input/Output section for com-
plete description.
P4.0 98 98 D I/O Port 4.0. See Port Input/Output section for com-
plete description.
P4.1 97 97 D I/O Port 4.1. See Port Input/Output section for com-
plete description.
P4.2 96 96 D I/O Port 4.2. See Port Input/Output section for com-
plete description.
P4.3 95 95 D I/O Port 4.3. See Port Input/Output section for com-
plete description.
P4.4 94 94 D I/O Port 4.4. See Port Input/Output section for com-
plete description.
Rev. 1.4 45
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
A9/P5.1 87 87 D I/O Port 5.1. See Port Input/Output section for com-
plete description.
A10/P5.2 86 86 D I/O Port 5.2. See Port Input/Output section for com-
plete description.
A11/P5.3 85 85 D I/O Port 5.3. See Port Input/Output section for com-
plete description.
A12/P5.4 84 84 D I/O Port 5.4. See Port Input/Output section for com-
plete description.
A13/P5.5 83 83 D I/O Port 5.5. See Port Input/Output section for com-
plete description.
A14/P5.6 82 82 D I/O Port 5.6. See Port Input/Output section for com-
plete description.
A15/P5.7 81 81 D I/O Port 5.7. See Port Input/Output section for com-
plete description.
46 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
A9m/A1/P6.1 79 79 D I/O Port 6.1. See Port Input/Output section for com-
plete description.
A10m/A2/P6.2 78 78 D I/O Port 6.2. See Port Input/Output section for com-
plete description.
A11m/A3/P6.3 77 77 D I/O Port 6.3. See Port Input/Output section for com-
plete description.
A12m/A4/P6.4 76 76 D I/O Port 6.4. See Port Input/Output section for com-
plete description.
A13m/A5/P6.5 75 75 D I/O Port 6.5. See Port Input/Output section for com-
plete description.
A14m/A6/P6.6 74 74 D I/O Port 6.6. See Port Input/Output section for com-
plete description.
A15m/A7/P6.7 73 73 D I/O Port 6.7. See Port Input/Output section for com-
plete description.
AD1/D1/P7.1 71 71 D I/O Port 7.1. See Port Input/Output section for com-
plete description.
AD2/D2/P7.2 70 70 D I/O Port 7.2. See Port Input/Output section for com-
plete description.
AD3/D3/P7.3 69 69 D I/O Port 7.3. See Port Input/Output section for com-
plete description.
AD4/D4/P7.4 68 68 D I/O Port 7.4. See Port Input/Output section for com-
plete description.
Rev. 1.4 47
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD5/D5/P7.5 67 67 D I/O Port 7.5. See Port Input/Output section for com-
plete description.
AD6/D6/P7.6 66 66 D I/O Port 7.6. See Port Input/Output section for com-
plete description.
AD7/D7/P7.7 65 65 D I/O Port 7.7. See Port Input/Output section for com-
plete description.
48 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
A10m/A2/P6.2
A11m/A3/P6.3
A12m/A4/P6.4
A8m/A0/P6.0
A9m/A1/P6.1
/WR/P4.7
ALE/P4.5
A10/P5.2
A11/P5.3
A12/P5.4
A13/P5.5
A14/P5.6
A15/P5.7
/RD/P4.6
A8/P5.0
A9/P5.1
DGND
100 DAC0
DAC1
VDD
P4.0
P4.1
P4.2
P4.3
P4.4
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
TMS 1 75 A13m/A5/P6.5
TCK 2 74 A14m/A6/P6.6
TDI 3 73 A15m/A7/P6.7
TDO 4 72 AD0/D0/P7.0
/RST 5 71 AD1/D1/P7.1
CP1- 6 70 AD2/D2/P7.2
CP1+ 7 69 AD3/D3/P7.3
CP0- 8 68 AD4/D4/P7.4
CP0+ 9 67 AD5/D5/P7.5
AGND 10 66 AD6/D6/P7.6
AV+ 11 C8051F120 65 AD7/D7/P7.7
VREF
AGND
12
13
C8051F122 64
63
VDD
DGND
AV+ 14 C8051F124 62 P0.0
VREFD 15 61 P0.1
VREF0 16
C8051F126 60 P0.2
VREF2 17 59 P0.3
AIN0.0 18 58 P0.4
AIN0.1 19 57 ALE/P0.5
AIN0.2 20 56 /RD/P0.6
AIN0.3 21 55 /WR/P0.7
AIN0.4 22 54 AD0/D0/P3.0
AIN0.5 23 53 AD1/D1/P3.1
AIN0.6 24 52 AD2/D2/P3.2
AIN0.7 25 51 AD3/D3/P3.3
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
XTAL1
XTAL2
MONEN
DGND
AIN2.7/A15/P1.7
AIN2.6/A14/P1.6
AIN2.5/A13/P1.5
AIN2.4/A12/P1.4
AIN2.3/A11/P1.3
AIN2.2/A10/P1.2
AIN2.1/A9/P1.1
AIN2.0/A8/P1.0
VDD
A15m/A7/P2.7
A14m/A6/P2.6
A13m/A5/P2.5
A12m/A4/P2.4
A11m/A3/P2.3
A10m/A2/P2.2
A9m/A1/P2.1
A8m/A0/P2.0
AD7/D7/P3.7
AD6/D6/P3.6
AD5/D5/P3.5
AD4/D4/P3.4
Rev. 1.4 49
50
TDO
AGND
AGND
TMS
NC
NC
AV+
AV+
CP0+
CP1+
TCK
VREF
/RST
AIN0.7
AIN0.6
AIN0.5
AIN0.4
AIN0.3
AIN0.2
AIN0.1
AIN0.0
VREF0
CP0-
CP1-
TDI
9
8
7
6
5
4
3
2
1
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
XTAL1 26 100 NC
XTAL2 27 99 NC
MONEN 28 98 P4.0
AIN2.7/A15/P1.7 29 97 P4.1
AIN2.6/A14/P1.6 30 96 P4.2
AIN2.5/A13/P1.5 31 95 P4.3
AIN2.4/A12/P1.4 32 94 P4.4
AIN2.3/A11/P1.3 33 93 ALE/P4.5
AIN2.2/A10/P1.2 34 92 /RD/P4.6
AIN2.1/A9/P1.1 35 91 /WR/P4.7
AIN2.0/A8/P1.0 36 90 VDD
VDD 37 89 DGND
DGND 38 88 A8/P5.0
A15m/A7/P2.7 39 87 A9/P5.1
A14m/A6/P2.6 40 86 A10/P5.2
Rev. 1.4
A13m/A5/P2.5 41 85 A11/P5.3
C8051F132
A12m/A4/P2.4 42
C8051F130 84 A12/P5.4
A11m/A3/P2.3 43 83 A13/P5.5
A10m/A2/P2.2 44 82 A14/P5.6
A9m/A1/P2.1 45 81 A15/P5.7
A8m/A0/P2.0 46 80 A8m/A0/P6.0
AD7/D7/P3.7 47 79 A9m/A1/P6.1
AD6/D6/P3.6 48 78 A10m/A2/P6.2
AD5/D5/P3.5 49 77 A11m/A3/P6.3
AD4/D4/P3.4 50 76 A12m/A4/P6.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
P0.4
P0.3
P0.2
P0.1
P0.0
VDD
DGND
/RD/P0.6
ALE/P0.5
/WR/P0.7
AD3/D3/P3.3
AD2/D2/P3.2
AD1/D1/P3.1
AD0/D0/P3.0
AD7/D7/P7.7
AD6/D6/P7.6
AD5/D5/P7.5
AD4/D4/P7.4
AD3/D3/P7.3
AD2/D2/P7.2
AD1/D1/P7.1
AD0/D0/P7.0
A15m/A7/P6.7
A14m/A6/P6.6
A13m/A5/P6.5
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
D
MIN NOM MAX
D1 (mm) (mm) (mm)
A - - 1.20
A1 0.05 - 0.15
D - 16.00 -
E1 E D1 - 14.00 -
e - 0.50 -
E - 16.00 -
E1 - 14.00 -
100
L 0.45 0.60 0.75
PIN 1
DESIGNATOR
1
A2 e
b A1
L
Rev. 1.4 51
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ALE/P0.5
/RD/P0.6
DGND
DAC0
DAC1
/RST
VDD
TDO
TMS
P0.0
P0.1
P0.2
P0.3
P0.4
TCK
TDI
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
CP1- 1 48 /WR/P0.7
CP1+ 2 47 AD0/D0/P3.0
CP0- 3 46 AD1/D1/P3.1
CP0+ 4 45 AD2/D2/P3.2
AGND 5 44 AD3/D3/P3.3
AV+ 6 43 AD4/D4/P3.4
VREF 7 C8051F121 42 AD5/D5/P3.5
VREFA 8 C8051F123 41 VDD
AIN0.0 9
C8051F125 40 DGND
AIN0.1 10 39 AD6/D6/P3.6
AIN0.2 11
C8051F127 38 AD7/D7/P3.7
AIN0.3 12 37 A8m/A0/P2.0
AIN0.4 13 36 A9m/A1/P2.1
AIN0.5 14 35 A10m/A2/P2.2
AIN0.6 15 34 A11m/A3/P2.3
AIN0.7 16 33 A12m/A4/P2.4
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
XTAL1
XTAL2
A15m/A7/P2.7
A14m/A6/P2.6
A13m/A5/P2.5
MONEN
VDD
DGND
AIN2.1/A9/P1.1
AIN2.0/A8/P1.0
AIN2.7/A15/P1.7
AIN2.6/A14/P1.6
AIN2.5/A13/P1.5
AIN2.4/A12/P1.4
AIN2.3/A11/P1.3
AIN2.2/A10/P1.2
52 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ALE/P0.5
/RD/P0.6
DGND
/RST
VDD
TDO
TMS
P0.0
P0.1
P0.2
P0.3
P0.4
TCK
TDI
NC
NC
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
CP1- 1 48 /WR/P0.7
CP1+ 2 47 AD0/D0/P3.0
CP0- 3 46 AD1/D1/P3.1
CP0+ 4 45 AD2/D2/P3.2
AGND 5 44 AD3/D3/P3.3
AV+ 6 43 AD4/D4/P3.4
VREF 7 42 AD5/D5/P3.5
VREF0 8 C8051F131 41 VDD
AIN0.0 9
C8051F133 40 DGND
AIN0.1 10 39 AD6/D6/P3.6
AIN0.2 11 38 AD7/D7/P3.7
AIN0.3 12 37 A8m/A0/P2.0
AIN0.4 13 36 A9m/A1/P2.1
AIN0.5 14 35 A10m/A2/P2.2
AIN0.6 15 34 A11m/A3/P2.3
AIN0.7 16 33 A12m/A4/P2.4
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
XTAL1
XTAL2
AIN2.7/A15/P1.7
AIN2.6/A14/P1.6
AIN2.5/A13/P1.5
AIN2.4/A12/P1.4
AIN2.3/A11/P1.3
AIN2.2/A10/P1.2
AIN2.1/A9/P1.1
AIN2.0/A8/P1.0
A15m/A7/P2.7
A14m/A6/P2.6
A13m/A5/P2.5
MONEN
VDD
DGND
Rev. 1.4 53
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
D
D1
MIN NOM MAX
(mm) (mm) (mm)
A - - 1.20
A1 0.05 - 0.15
D - 12.00 -
64 D1 - 10.00 -
PIN 1 e - 0.50 -
DESIGNATOR
1 E - 12.00 -
A2 e
E1 - 10.00 -
A
L 0.45 0.60 0.75
b A1
L
54 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AIN0.0 + AV+ 12
SYSCLK
REF
AIN0.1 - AD0EN
AIN0.2 +
ADC0H
AV+
AIN0.3 -9-to-1
AMUX 12-Bit
AIN0.4 +
(SE or + SAR 12
AIN0.5 - DIFF) X -
AIN0.6 +
AGND
ADC
ADC0L
AIN0.7 -
TEMP
AD0CM
AD0BUSY
AD0WINT
AD0LJST
11 Timer 2 Overflow
AIN67IC
AIN45IC
AIN23IC
AIN01IC
AD0CM1
AD0CM0
AD0SC4
AD0SC3
AD0SC2
AD0SC1
AD0SC0
AD0INT
AD0TM
AD0EN
AD0CM
Rev. 1.4 55
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The Temperature Sensor transfer function is shown in Figure 5.2. The output voltage (VTEMP) is the PGA
input when the Temperature Sensor is selected by bits AMX0AD3-0 in register AMX0SL; this voltage will
be amplified by the PGA according to the user-programmed PGA settings. Typical values for the Slope and
Offset parameters can be found in Table 5.1.
Slope (V / deg C)
Voltage
Offset (V at 0 Celsius)
-50 0 50 100
Temperature (Celsius)
Figure 5.2. Typical Temperature Sensor Transfer Function
56 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The AD0BUSY bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete.
The falling edge of AD0BUSY triggers an interrupt (when enabled) and sets the AD0INT interrupt flag
(ADC0CN.5). Converted data is available in the ADC0 data word MSB and LSB registers, ADC0H, ADC0L.
Converted data can be either left or right justified in the ADC0H:ADC0L register pair (see example in
Figure 5.5) depending on the programmed state of the AD0LJST bit in the ADC0CN register.
When initiating conversions by writing a ‘1’ to AD0BUSY, the AD0INT bit should be polled to determine
when a conversion has completed (ADC0 interrupts may also be used). The recommended polling proce-
dure is shown below.
When CNVSTR0 is used as a conversion start source, it must be enabled in the crossbar, and the corre-
sponding pin must be set to open-drain, high-impedance mode (see Section “18. Port Input/Output” on
page 235 for more details on Port I/O configuration).
Rev. 1.4 57
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
SAR Clocks
Low Power
ADC0TM=1 Track Convert Low Power Mode
or Convert
SAR Clocks
Low Power
ADC0TM=1 Track Convert Low Power Mode
or Convert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
SAR Clocks
Track or
ADC0TM=0 Convert Track
Convert
58 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
n
t = ln ------- × R TOTAL C SAMPLE
2
SA
Equation 5.1. ADC0 Settling Time Requirements
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the ADC0 MUX resistance and any external source resistance.
n is the ADC resolution in bits (12).
AIN0.x AIN0.x
RMUX = 5k RMUX = 5k
CSAMPLE = 10pF CSAMPLE = 10pF
CSAMPLE = 10pF
AIN0.y
RMUX = 5k
MUX Select
Rev. 1.4 59
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBA
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - AIN67IC AIN45IC AIN23IC AIN01IC 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Note: The ADC0 Data Word is in 2’s complement format for channels configured as differential.
60 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBB
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - AMX0AD3 AMX0AD2 AMX0AD1 AMX0AD0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
AMX0AD3–0
0000 0001 0010 0011 0100 0101 0110 0111 1xxx
TEMP
0000 AIN0.0 AIN0.1 AIN0.2 AIN0.3 AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.0) TEMP
0001 –(AIN0.1)
AIN0.2 AIN0.3 AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.2) TEMP
0010 AIN0.0 AIN0.1
–(AIN0.3)
AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.0) +(AIN0.2) TEMP
0011 –(AIN0.1) –(AIN0.3)
AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.4) TEMP
0100 AIN0.0 AIN0.1 AIN0.2 AIN0.3
–(AIN0.5)
AIN0.6 AIN0.7
SENSOR
+(AIN0.0) +(AIN0.4) TEMP
0101 –(AIN0.1)
AIN0.2 AIN0.3
–(AIN0.5)
AIN0.6 AIN0.7
SENSOR
+(AIN0.2) +(AIN0.4) TEMP
0110
AMX0CF Bits 3–0
Rev. 1.4 61
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBC
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD0SC4 AD0SC3 AD0SC2 AD0SC1 AD0SC0 AMP0GN2 AMP0GN1 AMP0GN0 11111000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SYSCLK
AD0SC = -------------------------------- – 1 ( AD0SC > 00000b )
2 × C LK SAR0
When the AD0SC bits are equal to 00000b, the SAR Conversion clock is equal to SYSCLK
to facilitate faster ADC conversions at slower SYSCLK speeds.
62 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xE8 (bit addressable)
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD0EN AD0TM AD0INT AD0BUSY AD0CM1 AD0CM0 AD0WINT AD0LJST 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Rev. 1.4 63
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBF
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 0
SFR Address: 0xBE
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
64 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
12-bit ADC0 Data Word appears in the ADC0 Data Word Registers as follows:
ADC0H[3:0]:ADC0L[7:0], if AD0LJST = 0
(ADC0H[7:4] will be sign-extension of ADC0H.3 for a differential reading, otherwise
=
0000b).
ADC0H[7:0]:ADC0L[7:4], if AD0LJST = 1
(ADC0L[3:0] = 0000b).
Example: ADC0 Data Word Conversion Map, AIN0.0 Input in Single-Ended Mode
(AMX0CF = 0x00, AMX0SL = 0x00)
Example: ADC0 Data Word Conversion Map, AIN0.0-AIN0.1 Differential Input Pair
(AMX0CF = 0x01, AMX0SL = 0x00)
For AD0LJST = 0:
Gain
Code = Vin × --------------- × 2 n ; ‘n’ = 12 for Single-Ended; ‘n’=11 for Differential.
VREF
Rev. 1.4 65
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xC5
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 0
SFR Address: 0xC4
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
66 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xC7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Rev. 1.4 67
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD0WINT
AD0WINT=1
not affected
0x0201 0x0201
REF x (512/4096) 0x0200 ADC0LTH:ADC0LTL REF x (512/4096) 0x0200 ADC0GTH:ADC0GTL
0x01FF 0x01FF
AD0WINT
AD0WINT=1
not affected
0x0101 0x0101
REF x (256/4096) 0x0100 ADC0GTH:ADC0GTL REF x (256/4096) 0x0100 ADC0LTH:ADC0LTL
0x00FF 0x00FF
AD0WINT AD0WINT=1
not affected
0 0x0000 0 0x0000
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x00 AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘0’, AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0200, ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0x0100. ADC0GTH:ADC0GTL = 0x0200.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x0200 and > 0x0100. > 0x0200 or < 0x0100.
Figure 5.6. 12-Bit ADC0 Window Interrupt Example: Right Justified Single-Ended
Data
68 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD0WINT
AD0WINT=1
not affected
0x0101 0x0101
REF x (256/2048) 0x0100 ADC0LTH:ADC0LTL REF x (256/2048) 0x0100 ADC0GTH:ADC0GTL
0x00FF 0x00FF
AD0WINT
AD0WINT=1
not affected
0x0000 0x0000
REF x (-1/2048) 0xFFFF ADC0GTH:ADC0GTL REF x (-1/2048) 0xFFFF ADC0LTH:ADC0LTL
0xFFFE 0xFFFE
AD0WINT AD0WINT=1
not affected
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x01, AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘0’, AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0100, ADC0LTH:ADC0LTL = 0xFFFF,
ADC0GTH:ADC0GTL = 0xFFFF. ADC0GTH:ADC0GTL = 0x0100.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x0100 and > 0xFFFF. (In 2s-complement < 0xFFFF or > 0x0100. (In 2s-complement
math, 0xFFFF = -1.) math, 0xFFFF = -1.)
Figure 5.7. 12-Bit ADC0 Window Interrupt Example: Right Justified Differential
Data
Rev. 1.4 69
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD0WINT
AD0WINT=1
not affected
0x2010 0x2010
REF x (512/4096) 0x2000 ADC0LTH:ADC0LTL REF x (512/4096) 0x2000 ADC0GTH:ADC0GTL
0x1FF0 0x1FF0
AD0WINT
AD0WINT=1
not affected
0x1010 0x1010
REF x (256/4096) 0x1000 ADC0GTH:ADC0GTL REF x (256/4096) 0x1000 ADC0LTH:ADC0LTL
0x0FF0 0x0FF0
AD0WINT AD0WINT=1
not affected
0 0x0000 0 0x0000
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x00, AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘1’, AD0LJST = ‘1’
ADC0LTH:ADC0LTL = 0x2000, ADC0LTH:ADC0LTL = 0x1000,
ADC0GTH:ADC0GTL = 0x1000. ADC0GTH:ADC0GTL = 0x2000.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x2000 and > 0x1000. < 0x1000 or > 0x2000.
Figure 5.8. 12-Bit ADC0 Window Interrupt Example: Left Justified Single-Ended
Data
70 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AD0WINT
AD0WINT=1
not affected
0x1010 0x1010
REF x (256/2048) 0x1000 ADC0LTH:ADC0LTL REF x (256/2048) 0x1000 ADC0GTH:ADC0GTL
0x0FF0 0x0FF0
AD0WINT
AD0WINT=1
not affected
0x0000 0x0000
REF x (-1/2048) 0xFFF0 ADC0GTH:ADC0GTL REF x (-1/2048) 0xFFF0 ADC0LTH:ADC0LTL
0xFFE0 0xFFE0
AD0WINT AD0WINT=1
not affected
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x01, AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘1’, AD0LJST = ‘1’,
ADC0LTH:ADC0LTL = 0x1000, ADC0LTH:ADC0LTL = 0xFFF0,
ADC0GTH:ADC0GTL = 0xFFF0. ADC0GTH:ADC0GTL = 0x1000.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x1000 and > 0xFFF0. (2s-complement < 0xFFF0 or > 0x1000. (2s-complement math.)
math.)
Figure 5.9. 12-Bit ADC0 Window Interrupt Example: Left Justified Differential Data
Rev. 1.4 71
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
72 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
AIN0.0 + AV+ 10
SYSCLK
REF
AIN0.1 - AD0EN
AIN0.2 +
ADC0H
AV+
AIN0.3 -9-to-1
AMUX 10-Bit
AIN0.4 +
(SE or + SAR 10
AIN0.5 - DIFF) X -
AIN0.6 +
AGND
ADC
ADC0L
AIN0.7 -
TEMP
AD0CM
AD0BUSY
AD0WINT
AD0LJST
11 Timer 2 Overflow
AIN67IC
AIN45IC
AIN23IC
AIN01IC
AD0CM1
AD0CM0
AD0SC4
AD0SC3
AD0SC2
AD0SC1
AD0SC0
AD0INT
AD0TM
AD0EN
AD0CM
Rev. 1.4 73
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The Temperature Sensor transfer function is shown in Figure 6.2. The output voltage (VTEMP) is the PGA
input when the Temperature Sensor is selected by bits AMX0AD3-0 in register AMX0SL; this voltage will
be amplified by the PGA according to the user-programmed PGA settings. Typical values for the Slope and
Offset parameters can be found in Table 6.1.
Slope (V / deg C)
Voltage
Offset (V at 0 Celsius)
-50 0 50 100
Temperature (Celsius)
Figure 6.2. Typical Temperature Sensor Transfer Function
74 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
The AD0BUSY bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete.
The falling edge of AD0BUSY triggers an interrupt (when enabled) and sets the AD0INT interrupt flag
(ADC0CN.5). Converted data is available in the ADC0 data word MSB and LSB registers, ADC0H, ADC0L.
Converted data can be either left or right justified in the ADC0H:ADC0L register pair (see example in
Figure 6.5) depending on the programmed state of the AD0LJST bit in the ADC0CN register.
When initiating conversions by writing a ‘1’ to AD0BUSY, the AD0INT bit should be polled to determine
when a conversion has completed (ADC0 interrupts may also be used). The recommended polling proce-
dure is shown below.
When CNVSTR0 is used as a conversion start source, it must be enabled in the crossbar, and the corre-
sponding pin must be set to open-drain, high-impedance mode (see Section “18. Port Input/Output” on
page 235 for more details on Port I/O configuration).
Rev. 1.4 75
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
SAR Clocks
Low Power
ADC0TM=1 Track Convert Low Power Mode
or Convert
SAR Clocks
Low Power
ADC0TM=1 Track Convert Low Power Mode
or Convert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
SAR Clocks
Track or
ADC0TM=0 Convert Track
Convert
76 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
n
t = ln ------- × R TOTAL C SAMPLE
2
SA
Equation 6.1. ADC0 Settling Time Requirements
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the ADC0 MUX resistance and any external source resistance.
n is the ADC resolution in bits (10).
AIN0.x AIN0.x
RMUX = 5k RMUX = 5k
CSAMPLE = 10pF CSAMPLE = 10pF
CSAMPLE = 10pF
AIN0.y
RMUX = 5k
MUX Select
Rev. 1.4 77
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBA
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - AIN67IC AIN45IC AIN23IC AIN01IC 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Note: The ADC0 Data Word is in 2’s complement format for channels configured as differential.
78 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBB
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - AMX0AD3 AMX0AD2 AMX0AD1 AMX0AD0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
AMX0AD3-0
0000 0001 0010 0011 0100 0101 0110 0111 1xxx
TEMP
0000 AIN0.0 AIN0.1 AIN0.2 AIN0.3 AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.0) TEMP
0001 –(AIN0.1)
AIN0.2 AIN0.3 AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.2) TEMP
0010 AIN0.0 AIN0.1
–(AIN0.3)
AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.0) +(AIN0.2) TEMP
0011 –(AIN0.1) –(AIN0.3)
AIN0.4 AIN0.5 AIN0.6 AIN0.7
SENSOR
+(AIN0.4) TEMP
0100 AIN0.0 AIN0.1 AIN0.2 AIN0.3
–(AIN0.5)
AIN0.6 AIN0.7
SENSOR
+(AIN0.0) +(AIN0.4) TEMP
0101 –(AIN0.1)
AIN0.2 AIN0.3
–(AIN0.5)
AIN0.6 AIN0.7
SENSOR
+(AIN0.2) +(AIN0.4) TEMP
0110 AIN0.0 AIN0.1 AIN0.6 AIN0.7
AMX0CF Bits 3-0
Rev. 1.4 79
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBC
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD0SC4 AD0SC3 AD0SC2 AD0SC1 AD0SC0 AMP0GN2 AMP0GN1 AMP0GN0 11111000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SYSCLK
AD0SC = -------------------------------- – 1 ( AD0SC > 00000b )
2 × C LK SAR0
When the AD0SC bits are equal to 00000b, the SAR Conversion clock is equal to SYSCLK
to facilitate faster ADC conversions at slower SYSCLK speeds.
80 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
Rev. 1.4 81
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xBF
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 0
SFR Address: 0xBE
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
82 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
10-bit ADC0 Data Word appears in the ADC0 Data Word Registers as follows:
ADC0H[1:0]:ADC0L[7:0], if AD0LJST = 0
(ADC0H[7:2] will be sign-extension of ADC0H.1 for a differential reading, otherwise
=
000000b).
ADC0H[7:0]:ADC0L[7:6], if AD0LJST = 1
(ADC0L[5:0] = 00b).
Example: ADC0 Data Word Conversion Map, AIN0.0 Input in Single-Ended Mode
(AMX0CF = 0x00, AMX0SL = 0x00)
Example: ADC0 Data Word Conversion Map, AIN0.0-AIN0.1 Differential Input Pair
(AMX0CF = 0x01, AMX0SL = 0x00)
For AD0LJST = 0:
Gain
Code = Vin × --------------- × 2 n ; ‘n’ = 10 for Single-Ended; ‘n’= 9 for Differential.
VREF
Rev. 1.4 83
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xC5
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 0
SFR Address: 0xC4
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
84 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 0
SFR Address: 0xC7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 0
SFR Address: 0xC6
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Rev. 1.4 85
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADWINT
ADWINT=1
not affected
0x0201 0x0201
REF x (512/1024) 0x0200 ADC0LTH:ADC0LTL REF x (512/1024) 0x0200 ADC0GTH:ADC0GTL
0x01FF 0x01FF
ADWINT
ADWINT=1
not affected
0x0101 0x0101
REF x (256/1024) 0x0100 ADC0GTH:ADC0GTL REF x (256/1024) 0x0100 ADC0LTH:ADC0LTL
0x00FF 0x00FF
ADWINT ADWINT=1
not affected
0 0x0000 0 0x0000
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x00 AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘0’, AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0200, ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0x0100. ADC0GTH:ADC0GTL = 0x0200.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x0200 and > 0x0100. > 0x0200 or < 0x0100.
Figure 6.6. 10-Bit ADC0 Window Interrupt Example: Right Justified Single-Ended
Data
86 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADWINT
ADWINT=1
not affected
0x0101 0x0101
REF x (256/512) 0x0100 ADC0LTH:ADC0LTL REF x (256/512) 0x0100 ADC0GTH:ADC0GTL
0x00FF 0x00FF
ADWINT
ADWINT=1
not affected
0x0000 0x0000
REF x (-1/512) 0xFFFF ADC0GTH:ADC0GTL REF x (-1/512) 0xFFFF ADC0LTH:ADC0LTL
0xFFFE 0xFFFE
ADWINT ADWINT=1
not affected
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x01, AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘0’, AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0100, ADC0LTH:ADC0LTL = 0xFFFF,
ADC0GTH:ADC0GTL = 0xFFFF. ADC0GTH:ADC0GTL = 0x0100.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x0100 and > 0xFFFF. (In 2s-complement < 0xFFFF or > 0x0100. (In 2s-complement
math, 0xFFFF = -1.) math, 0xFFFF = -1.)
Figure 6.7. 10-Bit ADC0 Window Interrupt Example: Right Justified Differential
Data
Rev. 1.4 87
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADWINT
ADWINT=1
not affected
0x8040 0x8040
REF x (512/1024) 0x8000 ADC0LTH:ADC0LTL REF x (512/1024) 0x8000 ADC0GTH:ADC0GTL
0x7FC0 0x7FC0
ADWINT
ADWINT=1
not affected
0x4040 0x4040
REF x (256/1024) 0x4000 ADC0GTH:ADC0GTL REF x (256/1024) 0x4000 ADC0LTH:ADC0LTL
0x3FC0 0x3FC0
ADWINT ADWINT=1
not affected
0 0x0000 0 0x0000
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x00, AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘1’, AD0LJST = ‘1’
ADC0LTH:ADC0LTL = 0x2000, ADC0LTH:ADC0LTL = 0x1000,
ADC0GTH:ADC0GTL = 0x1000. ADC0GTH:ADC0GTL = 0x2000.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x2000 and > 0x1000. < 0x1000 or > 0x2000.
Figure 6.8. 10-Bit ADC0 Window Interrupt Example: Left Justified Single-Ended
Data
88 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADWINT
ADWINT=1
not affected
0x2040 0x2040
REF x (128/512) 0x2000 ADC0LTH:ADC0LTL REF x (128/512) 0x2000 ADC0GTH:ADC0GTL
0x1FC0 0x1FC0
ADWINT
ADWINT=1
not affected
0x0000 0x0000
REF x (-1/512) 0xFFC0 ADC0GTH:ADC0GTL REF x (-1/512) 0xFFC0 ADC0LTH:ADC0LTL
0xFF80 0xFF80
ADWINT ADWINT=1
not affected
Given: Given:
AMX0SL = 0x00, AMX0CF = 0x01, AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘1’, AD0LJST = ‘1’,
ADC0LTH:ADC0LTL = 0x2000, ADC0LTH:ADC0LTL = 0xFFC0,
ADC0GTH:ADC0GTL = 0xFFC0. ADC0GTH:ADC0GTL = 0x2000.
An ADC0 End of Conversion will cause an An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is = ‘1’) if the resulting ADC0 Data Word is
< 0x2000 and > 0xFFC0. (2s-complement < 0xFFC0 or > 0x2000. (2s-complement
math.) math.)
Figure 6.9. 10-Bit ADC0 Window Interrupt Example: Left Justified Differential Data
Rev. 1.4 89
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
90 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADC2GTH ADC2LTH
16 Dig
Comp
REF
SYSCLK
AV+
AD2WINT
AD2EN
AIN2.0 (P1.0) +
8
AIN2.1 (P1.1) - AV+
AIN2.2 (P1.2) +
8-Bit
AIN2.3 (P1.3)
ADC2
-
8-to-1 + SAR 8 8
AIN2.4 (P1.4) + AMUX
X -
AIN2.5 (P1.5) - AGND
ADC
AIN2.6 (P1.6) +
000 Write to AD2BUSY
AIN2.7 (P1.7) -
001 Timer 3 Overflow
AD2CM
Start Conversion
010 CNVSTR2
011 Timer 2 Overflow
1xx Write to AD0BUSY
(synchronized with
AMX2AD2
AMX2AD1
AMX2AD0
AMP2GN1
AMP2GN0
AD2BUSY
AD2WINT
PIN67IC
PIN45IC
PIN23IC
PIN01IC
AD2CM2
AD2CM1
AD2CM0
ADC0)
AD2SC4
AD2SC3
AD2SC2
AD2SC1
AD2SC0
AD2INT
AD2TM
AD2EN
AD2CM
Important Note: AIN2 pins also function as Port 1 I/O pins, and must be configured as analog inputs when
used as ADC2 inputs. To configure an AIN2 pin for analog input, set to ‘0’ the corresponding bit in register
P1MDIN. Port 1 pins selected as analog inputs are skipped by the Digital I/O Crossbar. See Section
“18.1.5. Configuring Port 1 Pins as Analog Inputs” on page 240 for more information on configuring
the AIN2 pins.
Rev. 1.4 91
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
During conversion, the AD2BUSY bit is set to logic 1 and restored to 0 when conversion is complete. The
falling edge of AD2BUSY triggers an interrupt (when enabled) and sets the interrupt flag in ADC2CN. Con-
verted data is available in the ADC2 data word, ADC2.
When a conversion is initiated by writing a ‘1’ to AD2BUSY, it is recommended to poll AD2INT to determine
when the conversion is complete. The recommended procedure is:
When CNVSTR2 is used as a conversion start source, it must be enabled in the crossbar, and the corre-
sponding pin must be set to open-drain, high-impedance mode (see Section “18. Port Input/Output” on
page 235 for more details on Port I/O configuration).
92 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
1 2 3 4 5 6 7 8 9
SAR Clocks
Low Power
AD2TM=1 Track Convert Low Power Mode
or Convert
Low Power
AD2TM=1 Track Convert Low Power Mode
or Convert
1 2 3 4 5 6 7 8 9
SAR Clocks
Track or
AD2TM=0 Convert Track
Convert
Rev. 1.4 93
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
n
t = ln ------- × R TOTAL C SAMPLE
2
SA
Equation 7.1. ADC2 Settling Time Requirements
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the ADC2 MUX resistance and any external source resistance.
n is the ADC resolution in bits (8).
AIN2.x AIN2.x
RMUX = 5k RMUX = 5k
CSAMPLE = 5pF CSAMPLE = 5pF
CSAMPLE = 5pF
AIN2.y
RMUX = 5k
MUX Select
94 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 2
SFR Address: 0xBA
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - PIN67IC PIN45IC PIN23IC PIN01IC 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Note: The ADC2 Data Word is in 2’s complement format for channels configured as differential.
Rev. 1.4 95
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 2
SFR Address: 0xBB
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - AMX2AD2 AMX2AD1 AMX2AD0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
AMX2AD2–0
000 001 010 011 100 101 110 111
0000 AIN2.0 AIN2.1 AIN2.2 AIN2.3 AIN2.4 AIN2.5 AIN2.6 AIN2.7
+(AIN2.0)
0001 –(AIN2.1)
AIN2.2 AIN2.3 AIN2.4 AIN2.5 AIN2.6 AIN2.7
+(AIN2.2)
0010 AIN2.0 AIN2.1
–(AIN2.3)
AIN2.4 AIN2.5 AIN2.6 AIN2.7
+(AIN2.0) +(AIN2.2)
0011 –(AIN2.1) –(AIN2.3)
AIN2.4 AIN2.5 AIN2.6 AIN2.7
+(AIN2.4)
0100 AIN2.0 AIN2.1 AIN2.2 AIN2.3
–(AIN2.5)
AIN2.6 AIN2.7
+(AIN2.0) +(AIN2.4)
0101 –(AIN2.1)
AIN2.2 AIN2.3
–(AIN2.5)
AIN2.6 AIN2.7
+(AIN2.2) +(AIN2.4)
0110 AIN2.0 AIN2.1 AIN2.6 AIN2.7
AMX2CF Bits 3–0
–(AIN2.3) –(AIN2.5)
+(AIN2.0) +(AIN2.2) +(AIN2.4)
0111 –(AIN2.1) –(AIN2.3) –(AIN2.5)
AIN2.6 AIN2.7
+(AIN2.6)
1000 AIN2.0 AIN2.1 AIN2.2 AIN2.3 AIN2.4 AIN2.5
–(AIN2.7)
+(AIN2.0) +(AIN2.6)
1001 –(AIN2.1)
AIN2.2 AIN2.3 AIN2.4 AIN2.5
–(AIN2.7)
+(AIN2.2) +(AIN2.6)
1010 AIN2.0 AIN2.1
–(AIN2.3)
AIN2.4 AIN2.5
–(AIN2.7)
+(AIN2.0) +(AIN2.2) +(AIN2.6)
1011 –(AIN2.1) –(AIN2.3)
AIN2.4 AIN2.5
–(AIN2.7)
+(AIN2.4) +(AIN2.6)
1100 AIN2.0 AIN2.1 AIN2.2 AIN2.3
–(AIN2.5) –(AIN2.7)
+(AIN2.0) +(AIN2.4) +(AIN2.6)
1101 –(AIN2.1)
AIN2.2 AIN2.3
–(AIN2.5) –(AIN2.7)
+(AIN2.2) +(AIN2.4) +(AIN2.6)
1110 AIN2.0 AIN2.1
–(AIN2.3) –(AIN2.5) –(AIN2.7)
+(AIN2.0) +(AIN2.2) +(AIN2.4) +(AIN2.6)
1111 –(AIN2.1) –(AIN2.3) –(AIN2.5) –(AIN2.7)
96 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 2
SFR Address: 0xBC
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD2SC4 AD2SC3 AD2SC2 AD2SC1 AD2SC0 - AMP2GN1 AMP2GN0 11111000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Rev. 1.4 97
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 2
SFR Address: 0xE8 (bit addressable)
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD2EN AD2TM AD2INT AD2BUSY AD2CM2 AD2CM1 AD2CM0 AD2WINT 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
98 Rev. 1.4
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
SFR Page: 2
SFR Address: 0xBE
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Single-Ended Example:
8-bit ADC Data Word appears in the ADC2 Data Word Register as follows:
Example: ADC2 Data Word Conversion Map, Single-Ended AIN2.0 Input
(AMX2CF = 0x00; AMX2SL = 0x00)
AIN2.0–AGND
ADC2
(Volts)
VREF * (255/256) 0xFF
VREF * (128/256) 0x80
VREF * (64/256) 0x40
0 0x00
Gain
Code = Vin × --------------- × 256
VREF
Differential Example:
8-bit ADC Data Word appears in the ADC2 Data Word Register as follows:
Example: ADC2 Data Word Conversion Map, Differential AIN2.0-AIN2.1 Input
(AMX2CF = 0x01; AMX2SL = 0x00)
AIN2.0–AIN2.1
ADC2
(Volts)
VREF * (127/128) 0x7F
VREF * (64/128) 0x40
0 0x00
–VREF * (64/128) 0xC0 (-64d)
–VREF * (128/128) 0x80 (-128d)
Gain
Code = Vin × ------------------------- × 256
2 × V REF
Rev. 1.4 99
C8051F120/1/2/3/4/5/6/7 C8051F130/1/2/3
ADC2 ADC2
Input Voltage Input Voltage
(AIN2.x - AGND) (AIN2.x - AGND)
AD2WINT
AD2WINT=1
not affected
0x21 0x21
REF x (32/256) 0x20 ADC2LT REF x (32/256) 0x20 ADC2GT
0x1F 0x1F
AD2WINT
AD2WINT=1
not affected
0x11 0x11
REF x (16/256) 0x10 ADC2GT REF x (16/256) 0x10 ADC2LT
0x0F 0x0F
AD2WINT AD2WINT=1
not affected
0 0x00 0 0x00
ADC2 ADC2
Input Voltage Input Voltage
(AIN2.x - AIN2.y) (AIN2.x - AIN2.y)
AD2WINT
AD2WINT=1
not affected
AD2WINT AD2WINT=1
not affected
SFR Page: 2
SFR Address: 0xC4
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 2
SFR Address: 0xC6
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
NOTES:
Timer 3
Timer 4
Timer 2
DAC0EN
DAC0CN
DAC0MD1
DAC0MD0
DAC0DF2 REF
DAC0DF1 AV+
DAC0DF0
DAC0H
Latch
8 8
Dig. MUX
12
DAC0
DAC0
DAC0L
Latch
8 8
AGND
DAC1H
Timer 3
Timer 4
Timer 2
DAC1EN
DAC1CN
DAC1MD1
DAC1MD0
DAC1DF2 REF
DAC1DF1
DAC1DF0 AV+
DAC1H
Latch
8 8
Dig. MUX
12
DAC1
DAC1
DAC1L
Latch
8 8
AGND
DAC1 is functionally the same as DAC0 described above. The electrical specifications for both DAC0 and
DAC1 are given in Table 8.1.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD3
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD2
SFR Page: 0
000: The most significant nibble of the DAC0 Data Word is in DAC0H[3:0], while the least
significant byte is in DAC0L.
DAC0H DAC0L
MSB LSB
001: The most significant 5-bits of the DAC0 Data Word is in DAC0H[4:0], while the least
significant 7-bits are in DAC0L[7:1].
DAC0H DAC0L
MSB LSB
010: The most significant 6-bits of the DAC0 Data Word is in DAC0H[5:0], while the least
significant 6-bits are in DAC0L[7:2].
DAC0H DAC0L
MSB LSB
011: The most significant 7-bits of the DAC0 Data Word is in DAC0H[6:0], while the least
significant 5-bits are in DAC0L[7:3].
DAC0H DAC0L
MSB LSB
1xx: The most significant 8-bits of the DAC0 Data Word is in DAC0H[7:0], while the least
significant 4-bits are in DAC0L[7:4].
DAC0H DAC0L
MSB LSB
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD3
SFR Page: 1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD2
SFR Page: 1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
DAC1EN - - DAC1MD1 DAC1MD0 DAC1DF2 DAC1DF1 DAC1DF0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD4
SFR Page: 1
000: The most significant nibble of the DAC1 Data Word is in DAC1H[3:0], while the least
significant byte is in DAC1L.
DAC1H DAC1L
MSB LSB
001: The most significant 5-bits of the DAC1 Data Word is in DAC1H[4:0], while the least
significant 7-bits are in DAC1L[7:1].
DAC1H DAC1L
MSB LSB
010: The most significant 6-bits of the DAC1 Data Word is in DAC1H[5:0], while the least
significant 6-bits are in DAC1L[7:2].
DAC1H DAC1L
MSB LSB
011: The most significant 7-bits of the DAC1 Data Word is in DAC1H[6:0], while the least
significant 5-bits are in DAC1L[7:3].
DAC1H DAC1L
MSB LSB
1xx: The most significant 8-bits of the DAC1 Data Word is in DAC1H[7:0], while the least
significant 4-bits are in DAC1L[7:4].
DAC1H DAC1L
MSB LSB
NOTES:
9. Voltage Reference
The voltage reference options available on the C8051F12x and C8051F13x device families vary according
to the device capabilities.
All devices include an internal voltage reference circuit, consisting of a 1.2 V, 15 ppm/°C (typical) bandgap
voltage reference generator and a gain-of-two output buffer amplifier. The internal reference may be routed
via the VREF pin to external system components or to the voltage reference input pins. The maximum load
seen by the VREF pin must be less than 200 µA to AGND. Bypass capacitors of 0.1 µF and 4.7 µF are rec-
ommended from the VREF pin to AGND.
The Reference Control Register, REF0CN enables/disables the internal reference generator and the inter-
nal temperature sensor on all devices. The BIASE bit in REF0CN enables the on-board reference genera-
tor while the REFBE bit enables the gain-of-two buffer amplifier which drives the VREF pin. When
disabled, the supply current drawn by the bandgap and buffer amplifier falls to less than 1 µA (typical) and
the output of the buffer amplifier enters a high impedance state. If the internal bandgap is used as the ref-
erence voltage generator, BIASE and REFBE must both be set to logic 1. If the internal reference is not
used, REFBE may be set to logic 0. Note that the BIASE bit must be set to logic 1 if any DACs or ADCs are
used, regardless of whether the voltage reference is derived from the on-chip reference or supplied by an
off-chip source. If no ADCs or DACs are being used, both of these bits can be set to logic 0 to conserve
power.
When enabled, the temperature sensor connects to the highest order input of the ADC0 input multiplexer.
The TEMPE bit within REF0CN enables and disables the temperature sensor. While disabled, the tem-
perature sensor defaults to a high impedance state. Any ADC measurements performed on the sensor
while disabled will result in undefined data.
The electrical specifications for the internal voltage reference are given in Table 9.1.
REF0CN
AD0VRS
AD2VRS
TEMPE
REFBE
BIASE
ADC2
AV+
Ref
1
VREF2
VDD 0
External
Voltage R1
Reference
Circuit ADC0
DGND VREF0 Ref
0
DAC0
VREFD
Ref
DAC1 BIASE
Bias to
EN ADCs,
VREF DACs
x2 1.2V
+
4.7μF 0.1μF Band-Gap
REFBE
Recommended Bypass
Capacitors
SFR Page: 0
SFR Address: 0xD1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - AD0VRS AD2VRS TEMPE BIASE REFBE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
REF0CN
AD0VRS
AD2VRS
TEMPE
REFBE
BIASE
ADC2
AV+
VDD Ref
1
External
Voltage R1
Reference 0
Circuit
VREFA
DGND
ADC0
Ref
0
DAC0
Ref
DAC1 BIASE
Bias to
EN ADCs,
VREF DACs
x2 1.2V
+
4.7μF 0.1μF Band-Gap
REFBE
Recommended Bypass
Capacitors
SFR Page: 0
SFR Address: 0xD1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - AD0VRS AD2VRS TEMPE BIASE REFBE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
VDD
REF0CN
TEMPE
REFBE
BIASE
EN
VREF Bias to ADC
x2 1.2V
+
4.7μF 0.1μF Band-Gap
Recommended Bypass
Capacitors
SFR Page: 0
SFR Address: 0xD1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - Reserved Reserved TEMPE BIASE REFBE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
10. Comparators
Two on-chip programmable voltage comparators are included, as shown in Figure 10.1. The inputs of each
comparator are available at dedicated pins. The output of each comparator is optionally available at the
package pins via the I/O crossbar. When assigned to package pins, each comparator output can be pro-
grammed to operate in open drain or push-pull modes. See Section “18.1. Ports 0 through 3 and the
Priority Crossbar Decoder” on page 238 for Crossbar and port initialization details.
CPT0MD
CP0RIE
CP0FIE
CP0MD1 CP0MD
CP0MD0
CP0EN
CP0OUT
AV+
CPT0CN
CP0RIF
CP0FIF
CP0HYP1
CP0HYP0 Reset
CP0MD
CP0HYN1 Decision
CP0HYN0 Tree
CP0+ +
D
SET
Q D
SET
Q Crossbar
CP0- - CLR
Q CLR
Q
Interrupt
(SYNCHRONIZER)
Handler
AGND
CPT1MD
CP1RIE
CP1FIE
CP1MD1 CP1MD
CP1MD0
CP1EN
CP1OUT
AV+
CPT1CN
CP1RIF
CP1FIF
CP1HYP1
CP1HYP0
CP1MD
CP1HYN1
CP1HYN0
CP1+ +
D
SET
Q D
SET
Q Crossbar
CP1- - CLR
Q CLR
Q
Interrupt
(SYNCHRONIZER)
Handler
AGND
Comparator interrupts can be generated on rising-edge and/or falling-edge output transitions. (For inter-
rupt enable and priority control, see Section “11.3. Interrupt Handler” on page 154). The CP0FIF flag is
set upon a Comparator0 falling-edge interrupt, and the CP0RIF flag is set upon the Comparator0 rising-
edge interrupt. Once set, these bits remain set until cleared by software. The Output State of Comparator0
can be obtained at any time by reading the CP0OUT bit. Comparator0 is enabled by setting the CP0EN
bit to logic 1, and is disabled by clearing this bit to logic 0. Comparator0 can also be programmed as a
reset source; for details, see Section “13.5. Comparator0 Reset” on page 179.
Note that after being enabled, there is a Power-Up time (listed in Table 10.1) during which the comparator
outputs stabilize. The states of the Rising-Edge and Falling-Edge flags are indeterminant after comparator
Power-Up and should be explicitly cleared before the comparator interrupts are enabled or the compara-
tors are configured as a reset source.
Comparator0 response time may be configured in software via the CP0MD1-0 bits in register CPT0MD
(see SFR Definition 10.2). Selecting a longer response time reduces the amount of current consumed by
Comparator0. See Table 10.1 for complete timing and current consumption specifications.
The hysteresis of each comparator is software-programmable via its respective Comparator control regis-
ter (CPT0CN and CPT1CN for Comparator0 and Comparator1, respectively). The user can program both
the amount of hysteresis voltage (referred to the input voltage) and the positive and negative-going sym-
metry of this hysteresis around the threshold voltage. The output of the comparator can be polled in soft-
ware, or can be used as an interrupt source. Each comparator can be individually enabled or disabled
(shutdown). When disabled, the comparator output (if assigned to a Port I/O pin via the Crossbar) defaults
to the logic low state, its interrupt capability is suspended and its supply current falls to less than 100 nA.
Comparator inputs can be externally driven from –0.25 V to (AV+) + 0.25 V without damage or upset.
Comparator0 hysteresis is programmed using bits 3-0 in the Comparator0 Control Register CPT0CN
(shown in SFR Definition 10.1). The amount of negative hysteresis voltage is determined by the settings of
the CP0HYN bits. As shown in SFR Definition 10.1, the negative hysteresis can be programmed to three
different settings, or negative hysteresis can be disabled. In a similar way, the amount of positive hystere-
sis is determined by the setting the CP0HYP bits.
The operation of Comparator1 is identical to that of Comparator0, though Comparator1 may not be config-
ured as a reset source. Comparator1 is controlled by the CPT1CN Register (SFR Definition 10.3) and the
CPT1MD Register (SFR Definition 10.4). The complete electrical specifications for the Comparators are
given in Table 10.1.
CP0+
VIN+ +
CP0 OUT
CP0- _
VIN-
CIRCUIT CONFIGURATION
VOH
OUTPUT
VOL
Negative Hysteresis Maximum
Disabled Negative Hysteresis
SFR Page: 1
SFR Address: 0x88
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CP0EN CP0OUT CP0RIF CP0FIF CP0HYP1 CP0HYP0 CP0HYN1 CP0HYN0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 1
SFR Address: 0x89
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - CP0RIE CP0FIE - - CP0MD1 CP0MD0 00000010
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 2
SFR Address: 0x88
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CP1EN CP1OUT CP1RIF CP1FIF CP1HYP1 CP1HYP0 CP1HYN1 CP1HYN0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Page: 2
SFR Address: 0x89
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - CP1RIE CP1FIE - - CP1MD1 CP1MD0 00000010
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
The CIP-51 Microcontroller core implements the standard 8051 organization and peripherals as well as
additional custom peripherals and functions to extend its capability (see Figure 11.1 for a block diagram).
- Fully Compatible with MCS-51 Instruction Set - Extended Interrupt Handler
- 100 or 50 MIPS Peak Using the On-Chip PLL - Reset Input
- 256 Bytes of Internal RAM - Power Management Modes
- 8/4 Byte-Wide I/O Ports - On-chip Debug Logic
- Program and Data Memory Security
Performance
The CIP-51 employs a pipelined architecture that greatly increases its instruction throughput over the stan-
dard 8051 architecture. In a standard 8051, all instructions except for MUL and DIV take 12 or 24 system
clock cycles to execute, and usually have a maximum system clock of 12 MHz. By contrast, the CIP-51
core executes 70% of its instructions in one or two system clock cycles, with no instructions taking more
than eight system clock cycles.
With the CIP-51's system clock running at 100 MHz, it has a peak throughput of 100 MIPS. The CIP-51
has a total of 109 instructions. The table below shows the total number of instructions that require each
execution time.
Number of Instructions 26 50 5 14 7 3 1 2 1
DATA BUS
D8
D8
D8
D8
D8
ACCUMULATOR B REGISTER STACK POINTER
DATA BUS
TMP1 TMP2
SRAM
PSW SRAM
ADDRESS
(256 X 8)
ALU REGISTER
D8
D8
D8
D8
DATA BUS
SFR_ADDRESS
BUFFER D8
SFR_CONTROL
SFR
D8 BUS SFR_WRITE_DATA
DATA POINTER D8
INTERFACE
SFR_READ_DATA
PC INCREMENTER DATA BUS
D8 MEM_ADDRESS
PROGRAM COUNTER (PC)
MEM_CONTROL
MEMORY
PRGM. ADDRESS REG. A16 INTERFACE MEM_WRITE_DATA
MEM_READ_DATA
PIPELINE D8
RESET CONTROL
LOGIC
SYSTEM_IRQs
CLOCK
INTERRUPT
D8
INTERFACE EMULATION_IRQ
STOP
POWER CONTROL
D8
IDLE REGISTER
The on-chip debug support logic facilitates full speed in-circuit debugging, allowing the setting of hardware
breakpoints and watch points, starting, stopping and single stepping through program execution (including
interrupt service routines), examination of the program's call stack, and reading/writing the contents of reg-
isters and memory. This method of on-chip debug is completely non-intrusive and non-invasive, requiring
no RAM, Stack, timers, or other on-chip resources.
The CIP-51 is supported by development tools from Silicon Labs and third party vendors. Silicon Labs pro-
vides an integrated development environment (IDE) including editor, macro assembler, debugger and pro-
grammer. The IDE's debugger and programmer interface to the CIP-51 via its JTAG interface to provide
fast and efficient in-system device programming and debugging. Third party macro assemblers and C
compilers are also available.
Due to the pipelined architecture of the CIP-51, most instructions execute in the same number of clock
cycles as there are program bytes in the instruction. Conditional branch instructions take one less clock
cycle to complete when the branch is not taken as opposed to when the branch is taken. Table 11.1 is the
CIP-51 Instruction Set Summary, which includes the mnemonic, number of bytes, and number of clock
cycles for each instruction.
rel - 8-bit, signed (2s complement) offset relative to the first byte of the following instruction. Used by
SJMP and all conditional jumps.
direct - 8-bit internal data location’s address. This could be a direct-access Data RAM location (0x00-
0x7F) or an SFR (0x80-0xFF).
addr11 - 11-bit destination address used by ACALL and AJMP. The destination must be within the same
2K-byte page of program memory as the first byte of the following instruction.
addr16 - 16-bit destination address used by LCALL and LJMP. The destination may be anywhere within
the 64K-byte program memory space.
There is one unused opcode (0xA5) that performs the same function as NOP.
All mnemonics copyrighted © Intel Corporation 1980.
0x00000
EXTERNAL DATA ADDRESS SPACE
C8051F132/3
0x200FF 0xFFFF
Scrachpad Memory
0x20000 (DATA only)
FLASH
(In-System 0x2000
Programmable in 1024 0x1FFF
Byte Sectors) XRAM - 8192 Bytes
(accessable using MOVX
0x0000 instruction)
0x00000
Program memory is normally assumed to be read-only. However, the CIP-51 can write to program memory
by setting the Program Store Write Enable bit (PSCTL.0) and using the MOVX instruction. This feature pro-
vides a mechanism for the CIP-51 to update program code and use the program memory space for non-
volatile data storage. Refer to Section “15. Flash Memory” on page 199 for further details.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - COBANK - - IFBANK 00010001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xB1
SFR Page: All Pages
*Note: On the C8051F132/3, the COBANK and IFBANK bits should both remain set to the default setting of ‘01’ to
ensure proper device functionality.
Internal
Address IFBANK = 0 IFBANK = 1 IFBANK = 2 IFBANK = 3
0xFFFF
0x8000
0x7FFF
0x0000
Figure 11.3. Address Memory Map for Instruction Fetches (128 kB Flash Only)
The upper 128 bytes of data memory are accessible only by indirect addressing. This region occupies the
same address space as the Special Function Registers (SFR) but is physically separate from the SFR
space. The addressing mode used by an instruction when accessing locations above 0x7F determines
whether the CPU accesses the upper 128 bytes of data memory space or the SFR’s. Instructions that use
direct addressing will access the SFR space. Instructions using indirect addressing above 0x7F access the
upper 128 bytes of data memory. Figure 11.2 illustrates the data memory organization of the CIP-51.
MOV C, 22.3h
moves the Boolean value at 0x13 (bit 3 of the byte at location 0x22) into the Carry flag.
11.2.5. Stack
A programmer's stack can be located anywhere in the 256 byte data memory. The stack area is designated
using the Stack Pointer (SP, address 0x81) SFR. The SP will point to the last location used. The next value
pushed on the stack is placed at SP+1 and then SP is incremented. A reset initializes the stack pointer to
location 0x07; therefore, the first value pushed on the stack is placed at location 0x08, which is also the
first register (R0) of register bank 1. Thus, if more than one register bank is to be used, the SP should be
initialized to a location in the data memory not being used for data storage. The stack depth can extend up
to 256 bytes.
The MCUs also have built-in hardware for a stack record which is accessed by the debug logic. The stack
record is a 32-bit shift register, where each PUSH or increment SP pushes one record bit onto the register,
and each CALL pushes two record bits onto the register. (A POP or decrement SP pops one record bit,
and a RET pops two record bits, also.) The stack record circuitry can also detect an overflow or underflow
on the 32-bit shift register, and can notify the debug software even with the MCU running at speed.
The SFR registers are accessed whenever the direct addressing mode is used to access memory loca-
tions from 0x80 to 0xFF. SFR’s with addresses ending in 0x0 or 0x8 (e.g. P0, TCON, P1, SCON, IE, etc.)
are bit-addressable as well as byte-addressable. All other SFR’s are byte-addressable only. Unoccupied
addresses in the SFR space are reserved for future use. Accessing these areas will have an indeterminate
effect and should be avoided. Refer to the corresponding pages of the datasheet, as indicated in
Table 11.3, for a detailed description of each register.
11.2.6.1.SFR Paging
The CIP-51 features SFR paging, allowing the device to map many SFR’s into the 0x80 to 0xFF memory
address space. The SFR memory space has 256 pages. In this way, each memory location from 0x80 to
0xFF can access up to 256 SFR’s. The C8051F12x family of devices utilizes five SFR pages: 0, 1, 2, 3,
and F. SFR pages are selected using the Special Function Register Page Selection register, SFRPAGE
(see SFR Definition 11.3). The procedure for reading and writing an SFR is as follows:
1. Select the appropriate SFR page number using the SFRPAGE register.
2. Use direct accessing mode to read or write the special function register (MOV instruction).
11.2.6.2.Interrupts and SFR Paging
When an interrupt occurs, the SFR Page Register will automatically switch to the SFR page containing the
flag bit that caused the interrupt. The automatic SFR Page switch function conveniently removes the bur-
den of switching SFR pages from the interrupt service routine. Upon execution of the RETI instruction, the
SFR page is automatically restored to the SFR Page in use prior to the interrupt. This is accomplished via
a three-byte SFR Page Stack. The top byte of the stack is SFRPAGE, the current SFR Page. The second
byte of the SFR Page Stack is SFRNEXT. The third, or bottom byte of the SFR Page Stack is SFRLAST.
On interrupt, the current SFRPAGE value is pushed to the SFRNEXT byte, and the value of SFRNEXT is
pushed to SFRLAST. Hardware then loads SFRPAGE with the SFR Page containing the flag bit associated
with the interrupt. On a return from interrupt, the SFR Page Stack is popped resulting in the value of
SFRNEXT returning to the SFRPAGE register, thereby restoring the SFR page context without software
intervention. The value in SFRLAST (0x00 if there is no SFR Page value in the bottom of the stack) of the
stack is placed in SFRNEXT register. If desired, the values stored in SFRNEXT and SFRLAST may be
modified during an interrupt, enabling the CPU to return to a different SFR Page upon execution of the
RETI instruction (on interrupt exit). Modifying registers in the SFR Page Stack does not cause a push or
pop of the stack. Only interrupt calls and returns will cause push/pop operations on the SFR Page Stack.
SFRPGCN Bit
Interrupt
Logic
SFRPAGE
CIP-51
SFRNEXT
SFRLAST
Automatic hardware switching of the SFR Page on interrupts may be enabled or disabled as desired using
the SFR Automatic Page Control Enable Bit located in the SFR Page Control Register (SFRPGCN). This
function defaults to ‘enabled’ upon reset. In this way, the autoswitching function will be enabled unless dis-
abled in software.
A summary of the SFR locations (address and SFR page) is provided in Table 11.2. in the form of an SFR
memory map. Each memory location in the map has an SFR page row, denoting the page in which that
SFR resides. Note that certain SFR’s are accessible from ALL SFR pages, and are denoted by the “(ALL
PAGES)” designation. For example, the Port I/O registers P0, P1, P2, and P3 all have the “(ALL PAGES)”
designation, indicating these SFR’s are accessible from all SFR pages regardless of the SFRPAGE regis-
ter value.
In this example, the SFR Page Control is left in the default enabled state (i.e., SFRPGEN = 1), and the
CIP-51 is executing in-line code that is writing values to Port 5 (SFR “P5”, located at address 0xD8 on SFR
Page 0x0F). The device is also using the Programmable Counter Array (PCA) and the 10-bit ADC (ADC2)
window comparator to monitor a voltage. The PCA is timing a critical control function in its interrupt service
routine (ISR), so its interrupt is enabled and is set to high priority. The ADC2 is monitoring a voltage that is
less important, but to minimize the software overhead its window comparator is being used with an associ-
ated ISR that is set to low priority. At this point, the SFR page is set to access the Port 5 SFR (SFRPAGE =
0x0F). See Figure 11.5 below.
SFR Page
Stack SFR's
0x0F
SFRPAGE
(Port 5)
SFRNEXT
SFRLAST
Figure 11.5. SFR Page Stack While Using SFR Page 0x0F To Access Port 5
While CIP-51 executes in-line code (writing values to Port 5 in this example), ADC2 Window Comparator
Interrupt occurs. The CIP-51 vectors to the ADC2 Window Comparator ISR and pushes the current SFR
Page value (SFR Page 0x0F) into SFRNEXT in the SFR Page Stack. The SFR page needed to access
ADC2’s SFR’s is then automatically placed in the SFRPAGE register (SFR Page 0x02). SFRPAGE is con-
sidered the “top” of the SFR Page Stack. Software can now access the ADC2 SFR’s. Software may switch
to any SFR Page by writing a new value to the SFRPAGE register at any time during the ADC2 ISR to
access SFR’s that are not on SFR Page 0x02. See Figure 11.6 below.
0x02
SFRPAGE
SFRPAGE
(ADC2)
pushed to
SFRNEXT 0x0F
SFRNEXT
(Port 5)
SFRLAST
Figure 11.6. SFR Page Stack After ADC2 Window Comparator Interrupt Occurs
While in the ADC2 ISR, a PCA interrupt occurs. Recall the PCA interrupt is configured as a high priority
interrupt, while the ADC2 interrupt is configured as a low priority interrupt. Thus, the CIP-51 will now vector
to the high priority PCA ISR. Upon doing so, the CIP-51 will automatically place the SFR page needed to
access the PCA’s special function registers into the SFRPAGE register, SFR Page 0x00. The value that
was in the SFRPAGE register before the PCA interrupt (SFR Page 2 for ADC2) is pushed down the stack
into SFRNEXT. Likewise, the value that was in the SFRNEXT register before the PCA interrupt (in this
case SFR Page 0x0F for Port 5) is pushed down to the SFRLAST register, the “bottom” of the stack. Note
that a value stored in SFRLAST (via a previous software write to the SFRLAST register) will be overwritten.
See Figure 11.7 below.
0x00
SFRPAGE
SFRPAGE
(PCA)
pushed to
SFRNEXT 0x02
SFRNEXT
(ADC2)
SFRNEXT
pushed to
SFRLAST 0x0F
SFRLAST
(Port 5)
Figure 11.7. SFR Page Stack Upon PCA Interrupt Occurring During an ADC2 ISR
On exit from the PCA interrupt service routine, the CIP-51 will return to the ADC2 Window Comparator
ISR. On execution of the RETI instruction, SFR Page 0x00 used to access the PCA registers will be auto-
matically popped off of the SFR Page Stack, and the contents of the SFRNEXT register will be moved to
the SFRPAGE register. Software in the ADC2 ISR can continue to access SFR’s as it did prior to the PCA
interrupt. Likewise, the contents of SFRLAST are moved to the SFRNEXT register. Recall this was the
SFR Page value 0x0F being used to access Port 5 before the ADC2 interrupt occurred. See Figure 11.8
below.
0x02
SFRPAGE
SFRNEXT
(ADC2)
popped to
SFRPAGE 0x0F
SFRNEXT
(Port 5)
SFRLAST
popped to
SFRNEXT
SFRLAST
Figure 11.8. SFR Page Stack Upon Return From PCA Interrupt
On the execution of the RETI instruction in the ADC2 Window Comparator ISR, the value in SFRPAGE
register is overwritten with the contents of SFRNEXT. The CIP-51 may now access the Port 5 SFR bits as
it did prior to the interrupts occurring. See Figure 11.9 below.
0x0F
SFRPAGE
SFRNEXT
(Port 5)
popped to
SFRPAGE
SFRNEXT
SFRLAST
Figure 11.9. SFR Page Stack Upon Return From ADC2 Window Interrupt
Note that in the above example, all three bytes in the SFR Page Stack are accessible via the SFRPAGE,
SFRNEXT, and SFRLAST special function registers. If the stack is altered while servicing an interrupt, it is
possible to return to a different SFR Page upon interrupt exit than selected prior to the interrupt call. Direct
access to the SFR Page stack can be useful to enable real-time operating systems to control and manage
context switching between multiple tasks.
Push operations on the SFR Page Stack only occur on interrupt service, and pop operations only occur on
interrupt exit (execution on the RETI instruction). The automatic switching of the SFRPAGE and operation
of the SFR Page Stack as described above can be disabled in software by clearing the SFR Automatic
Page Enable Bit (SFRPGEN) in the SFR Page Control Register (SFRPGCN). See SFR Definition 11.2.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - - - - SFRPGEN 00000001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x96
SFR Page: F
Bits7–1: Reserved.
Bit0: SFRPGEN: SFR Automatic Page Control Enable.
Upon interrupt, the C8051 Core will vector to the specified interrupt service routine and auto-
matically switch the SFR page to the corresponding peripheral or function’s SFR page. This
bit is used to control this autopaging function.
0: SFR Automatic Paging disabled. C8051 core will not automatically change to the appro-
priate SFR page (i.e., the SFR page that contains the SFR’s for the peripheral/function that
was the source of the interrupt).
1: SFR Automatic Paging enabled. Upon interrupt, the C8051 will switch the SFR page to
the page that contains the SFR’s for the peripheral or function that is the source of the inter-
rupt.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x84
SFR Page: All Pages
Bits7–0: SFR Page Bits: Byte Represents the SFR Page the C8051 MCU uses when reading or mod-
ifying SFR’s.
Write: Sets the SFR Page.
Read: Byte is the SFR page the C8051 MCU is using.
When enabled in the SFR Page Control Register (SFRPGCN), the C8051 will automatically
switch to the SFR Page that contains the SFR’s of the corresponding peripheral/function that
caused the interrupt, and return to the previous SFR page upon return from interrupt (unless
SFR Stack was altered before a returning from the interrupt).
SFRPAGE is the top byte of the SFR Page Stack, and push/pop events of this stack are
caused by interrupts (and not by reading/writing to the SFRPAGE register)
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x85
SFR Page: All Pages
Bits7–0: SFR Page Stack Bits: SFR page context is retained upon interrupts/return from interrupts in
a 3 byte SFR Page Stack: SFRPAGE is the first entry, SFRNEXT is the second, and SFR-
LAST is the third entry. The SFR stack bytes may be used alter the context in the SFR Page
Stack, and will not cause the stack to ‘push’ or ‘pop’. Only interrupts and return from inter-
rupts cause pushes and pops of the SFR Page Stack.
Write: Sets the SFR Page contained in the second byte of the SFR Stack. This will cause
the SFRPAGE SFR to have this SFR page value upon a return from interrupt.
Read: Returns the value of the SFR page contained in the second byte of the SFR stack.
This is the value that will go to the SFR Page register upon a return from interrupt.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x86
SFR Page: All Pages
Bits7–0: SFR Page Stack Bits: SFR page context is retained upon interrupts/return from interrupts in
a 3 byte SFR Page Stack: SFRPAGE is the first entry, SFRNEXT is the second, and SFR-
LAST is the third entry. The SFR stack bytes may be used alter the context in the SFR Page
Stack, and will not cause the stack to ‘push’ or ‘pop’. Only interrupts and return from inter-
rupts cause pushes and pops of the SFR Page Stack.
Write: Sets the SFR Page in the last entry of the SFR Stack. This will cause the SFRNEXT
SFR to have this SFR page value upon a return from interrupt.
Read: Returns the value of the SFR page contained in the last entry of the SFR stack.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x81
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x82
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x83
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
ACC.7 ACC.6 ACC.5 ACC.4 ACC.3 ACC.2 ACC.1 ACC.0 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xE0
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
B.7 B.6 B.5 B.4 B.3 B.2 B.1 B.0 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xF0
SFR Page: All Pages
Bits7–0: B: B Register.
This register serves as a second accumulator for certain arithmetic operations.
If interrupts are enabled for the source, an interrupt request is generated when the interrupt-pending flag is
set. As soon as execution of the current instruction is complete, the CPU generates an LCALL to a prede-
termined address to begin execution of an interrupt service routine (ISR). Each ISR must end with an RETI
instruction, which returns program execution to the next instruction that would have been executed if the
interrupt request had not occurred. If interrupts are not enabled, the interrupt-pending flag is ignored by the
hardware and program execution continues as normal. (The interrupt-pending flag is set to logic 1 regard-
less of the interrupt's enable/disable state.)
Each interrupt source can be individually enabled or disabled through the use of an associated interrupt
enable bit in an SFR (IE, EIE1, or EIE2). However, interrupts must first be globally enabled by setting the
EA bit (IE.7) to logic 1 before the individual interrupt enables are recognized. Setting the EA bit to logic 0
disables all interrupt sources regardless of the individual interrupt-enable settings.
Note: Any instruction that clears the EA bit should be immediately followed by an instruction that has two
or more opcode bytes. For example:
// in 'C':
EA = 0; // clear EA bit.
EA = 0; // this is a dummy instruction with two-byte opcode.
; in assembly:
CLR EA ; clear EA bit.
CLR EA ; this is a dummy instruction with two-byte opcode.
If an interrupt is posted during the execution phase of a "CLR EA" opcode (or any instruction which clears
the EA bit), and the instruction is followed by a single-cycle instruction, the interrupt may be taken. How-
ever, a read of the EA bit will return a '0' inside the interrupt service routine. When the "CLR EA" opcode is
followed by a multi-cycle instruction, the interrupt will not be taken.
Some interrupt-pending flags are automatically cleared by the hardware when the CPU vectors to the ISR.
However, most are not cleared by the hardware and must be cleared by software before returning from the
ISR. If an interrupt-pending flag remains set after the CPU completes the return-from-interrupt (RETI)
instruction, a new interrupt request will be generated immediately and the CPU will re-enter the ISR after
the completion of the next instruction.
SFRPAGE (SFRPGEN = 1)
Bit addressable?
Cleared by HW?
Interru
Priority Enable Priority
Interrupt Source pt Pending Flags
Order Flag Control
Vector
Always Always
Reset 0x0000 Top None N/A N/A 0
Enabled Highest
External Interrupt 0 (/INT0) 0x0003 0 IE0 (TCON.1) Y Y 0 EX0 (IE.0) PX0 (IP.0)
Timer 0 Overflow 0x000B 1 TF0 (TCON.5) Y Y 0 ET0 (IE.1) PT0 (IP.1)
External Interrupt 1 (/INT1) 0x0013 2 IE1 (TCON.3) Y Y 0 EX1 (IE.2) PX1 (IP.2)
Timer 1 Overflow 0x001B 3 TF1 (TCON.7) Y Y 0 ET1 (IE.3) PT1 (IP.3)
RI0 (SCON0.0)
UART0 0x0023 4 Y 0 ES0 (IE.4) PS0 (IP.4)
TI0 (SCON0.1)
TF2 (TMR2CN.7)
Timer 2 0x002B 5 Y 0 ET2 (IE.5) PT2 (IP.5)
EXF2 (TMR2CN.6)
SPIF (SPI0CN.7)
WCOL (SPI0CN.6) ESPI0 PSPI0
Serial Peripheral Interface 0x0033 6 Y 0
MODF (SPI0CN.5) (EIE1.0) (EIP1.0)
RXOVRN (SPI0CN.4)
ESMB0 PSMB0
SMBus Interface 0x003B 7 SI (SMB0CN.3) Y 0
(EIE1.1) (EIP1.1)
AD0WINT EWADC0 PWADC0
ADC0 Window Comparator 0x0043 8 Y 0
(ADC0CN.1) (EIE1.2) (EIP1.2)
Programmable Counter CF (PCA0CN.7) EPCA0 PPCA0
0x004B 9 Y 0
Array CCFn (PCA0CN.n) (EIE1.3) (EIP1.3)
ECP0F PCP0F
Comparator 0 Falling Edge 0x0053 10 CP0FIF (CPT0CN.4) Y 1
(EIE1.4) (EIP1.4)
ECP0R PCP0R
Comparator 0 Rising Edge 0x005B 11 CP0RIF (CPT0CN.5) Y 1
(EIE1.5) (EIP1.5)
ECP1F PCP1F
Comparator 1 Falling Edge 0x0063 12 CP1FIF (CPT1CN.4) Y 2
(EIE1.6) (EIP1.6)
SFRPAGE (SFRPGEN = 1)
Bit addressable?
Cleared by HW?
Interru
Priority Enable Priority
Interrupt Source pt Pending Flags
Order Flag Control
Vector
ECP1R PCP1F
Comparator 1 Rising Edge 0x006B 13 CP1RIF (CPT1CN.5) Y 2
(EIE1.7) (EIP1.7)
TF3 (TMR3CN.7) ET3 PT3
Timer 3 0x0073 14 Y 1
EXF3 (TMR3CN.6) (EIE2.0) (EIP2.0)
EADC0 PADC0
ADC0 End of Conversion 0x007B 15 AD0INT (ADC0CN.5) Y 0
(EIE2.1) (EIP2.1)
TF4 (TMR4CN.7) ET4 PT4
Timer 4 0x0083 16 Y 2
EXF4 (TMR4CN.7) (EIE2.2) (EIP2.2)
AD2WINT EWADC2 PWADC2
ADC2 Window Comparator 0x008B 17 Y 2
(ADC2CN.0) (EIE2.3) (EIP2.3)
EADC2 PADC2
ADC2 End of Conversion 0x0093 18 AD2INT (ADC2CN.5) Y 2
(EIE2.4) (EIP2.4)
RESERVED 0x009B 19 N/A N/A N/A N/A N/A N/A
RI1 (SCON1.0) ES1 PS1
UART1 0x00A3 20 Y 1
TI1 (SCON1.1) (EIE2.6) (EIP2.6)
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
EA IEGF0 ET2 ES0 ET1 EX1 ET0 EX0 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xA8
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - PT2 PS0 PT1 PX1 PT0 PX0 11000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xB8
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
ECP1R ECP1F ECP0R ECP0F EPCA0 EWADC0 ESMB0 ESPI0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xE6
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- ES1 - EADC2 EWADC2 ET4 EADC0 ET3 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xE7
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PCP1R PCP1F PCP0R PCP0F PPCA0 PWADC0 PSMB0 PSPI0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xF6
SFR Page: All Pages
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- PS1 - PADC2 PWADC2 PT4 PADC0 PT3 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xF7
SFR Page: All Pages
Although the CIP-51 has Idle and Stop modes built in (as with any standard 8051 architecture), power
management of the entire MCU is better accomplished by enabling/disabling individual peripherals as
needed. Each analog peripheral can be disabled when not in use and put into low power mode. Digital
peripherals, such as timers or serial buses, draw little power whenever they are not in use. Turning off the
Flash memory saves power, similar to entering Idle mode. Turning off the oscillator saves even more
power, but requires a reset to restart the MCU.
Idle mode is terminated when an enabled interrupt or RST is asserted. The assertion of an enabled inter-
rupt will cause the Idle Mode Selection bit (PCON.0) to be cleared and the CPU to resume operation. The
pending interrupt will be serviced and the next instruction to be executed after the return from interrupt
(RETI) will be the instruction immediately following the one that set the Idle Mode Select bit. If Idle mode is
terminated by an internal or external reset, the CIP-51 performs a normal reset sequence and begins pro-
gram execution at address 0x00000.
If enabled, the WDT will eventually cause an internal watchdog reset and thereby terminate the Idle mode.
This feature protects the system from an unintended permanent shutdown in the event of an inadvertent
write to the PCON register. If this behavior is not desired, the WDT may be disabled by software prior to
entering the Idle mode if the WDT was initially configured to allow this operation. This provides the oppor-
tunity for additional power savings, allowing the system to remain in the Idle mode indefinitely, waiting for
an external stimulus to wake up the system. Refer to Section 13 for more information on the use and con-
figuration of the WDT.
Note: Any instruction which sets the IDLE bit should be immediately followed by an instruction which has
two or more opcode bytes. For example:
// in ‘C’:
PCON |= 0x01; // Set IDLE bit
PCON = PCON; // ... Followed by a 3-cycle Dummy Instruction
; in assembly:
ORL PCON, #01h ; Set IDLE bit
MOV PCON, PCON ; ... Followed by a 3-cycle Dummy Instruction
If the instruction following the write to the IDLE bit is a single-byte instruction and an interrupt occurs during
the execution of the instruction of the instruction which sets the IDLE bit, the CPU may not wake from IDLE
mode when a future interrupt occurs.
If enabled, the Missing Clock Detector will cause an internal reset and thereby terminate the Stop mode.
The Missing Clock Detector should be disabled if the CPU is to be put to sleep for longer than the MCD
timeout of 100 µs.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - - - STOP IDLE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x87
SFR Page: All Pages
Bits7–3: Reserved.
Bit1: STOP: STOP Mode Select.
Writing a ‘1’ to this bit will place the CIP-51 into STOP mode. This bit will always read ‘0’.
1: CIP-51 forced into power-down mode. (Turns off oscillator).
Bit0: IDLE: IDLE Mode Select.
Writing a ‘1’ to this bit will place the CIP-51 into IDLE mode. This bit will always read ‘0’.
1: CIP-51 forced into IDLE mode. (Shuts off clock to CPU, but clock to Timers, Interrupts,
and all peripherals remain active.)
MAC0MS
MAC0FM
16 x 16 Multiply
1 0
0
40 bit Add
MAC0 Accumulator
MAC0OVR MAC0ACC3 MAC0ACC2 MAC0ACC1 MAC0ACC0
MAC0SO
MAC0FM
MAC0SC
MAC0SD
MAC0CA
MAC0N
MAC0Z
MAC0RNDH MAC0RNDL
MAC0CF MAC0STA
When the MAC0FM bit is set to ‘1’, the inputs are treated at 16-bit, 2’s complement, fractional values. The
decimal point is located between bits 15 and 14 of the data word. After the operation, the accumulator will
contain a 40-bit, 2’s complement, fractional value, with the decimal point located between bits 31 and 30.
Figure 12.3 shows how fractional numbers are stored in the SFRs.
* The MAC0RND register contains the 16 LSBs of a two's complement number. The MAC0N Flag can be
used to determine the sign of the MAC0RND register.
Write
Multiply Add Round
MAC0BL
Write
Multiply Add Round
MAC0BL
Next MAC0
Operation May
Be Initiated
Here
The rounding engine can also be used to saturate the results stored in the rounding registers. If the
MAC0SAT bit is set to ‘1’ and the rounding register overflows, the rounding registers will saturate. When a
positive overflow occurs, the rounding registers will show a value of 0x7FFF when saturated. For a nega-
tive overflow, the rounding registers will show a value of 0x8000 when saturated. If the MAC0SAT bit is
cleared to ‘0’, the rounding registers will not saturate.
MOV MAC0CF, #01h ; Use integer numbers, and multiply only mode (add to zero)
MOV MAC0AH, #12h ; Load MAC0A register with 1234 hex = 4660 decimal
MOV MAC0AL, #34h
MOV MAC0BH, #FEh ; Load MAC0B register with FEDC hex = -292 decimal
MOV MAC0BL, #DCh ; This line initiates the Multiply operation
NOP
NOP ; After this instruction, the Accumulator should be equal to
; FFFFEB3CB0 hex = -1360720 decimal. The MAC0STA register should
; be 0x01, indicating a negative result.
NOP ; After this instruction, the Rounding register is updated
MOV MAC0OVR, #40h ; The next few instructions load the accumulator with the value
MOV MAC0ACC3, #88h ; 4088442211 Hex.
MOV MAC0ACC2, #44h
MOV MAC0ACC1, #22h
MOV MAC0ACC0, #11h
MOV MAC0CF, #20h ; Initiate a Left-shift
NOP ; After this instruction, the accumulator should be 0x8110884422
NOP ; The rounding register is updated after this instruction
MOV MAC0CF, #30h ; Initiate a Right-shift
MOV MAC0CF, #30h ; Initiate a second Right-shift
NOP ; After this instruction, the accumulator should be 0xE044221108
NOP ; The rounding register is updated after this instruction
Note: The contents of this register should not be changed by software during the first two MAC0
pipeline stages.
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xC2
SFR Page: 3
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xC1
SFR Page: 3
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x92
SFR Page: 3
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x91
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first MAC0 pipeline stage.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x96
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x95
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x94
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x93
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x97
SFR Page: 3
*Note: The contents of this register should not be changed by software during the first two MAC0 pipeline stages.
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xCF
SFR Page: 3
R R R R R R R R Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xCE
SFR Page: 3
All SFRs are reset to the predefined values noted in the SFR detailed descriptions. The contents of internal
data memory are unaffected during a reset; any previously stored data is preserved. However, since the
stack pointer SFR is reset, the stack is effectively lost even though the data on the stack are not altered.
The I/O port latches are reset to 0xFF (all logic 1’s), activating internal weak pullups during and after the
reset. For VDD Monitor resets, the RST pin is driven low until the end of the VDD reset timeout.
On exit from the reset state, the program counter (PC) is reset, and the system clock defaults to the inter-
nal oscillator running at its lowest frequency. Refer to Section “14. Oscillators” on page 185 for informa-
tion on selecting and configuring the system clock source. The Watchdog Timer is enabled using its
longest timeout interval (see Section “13.7. Watchdog Timer Reset” on page 179). Once the system clock
source is stable, program execution begins at location 0x0000.
There are seven sources for putting the MCU into the reset state: power-on, power-fail, external RST pin,
external CNVSTR0 signal, software command, Comparator0, Missing Clock Detector, and Watchdog
Timer. Each reset source is described in the following sections.
VDD
(Port CNVSTR
Crossbar Supply
I/O)
(CNVSTR Monitor
reset Supply
enable) +
Reset /RST
- (wired-OR)
Timeout
Comparator0
CP0+
+
-
CP0- (CP0
reset
enable)
Reset
Missing WDT Funnel
Clock
Detector
(one-
shot)
EN EN PRE
Internal
Enable
Enable
Strobe
Clock
WDT
WDT
MCD
Generator
On exit from a power-on reset, the PORSF flag (RSTSRC.1) is set by hardware to logic 1. All of the other
reset flags in the RSTSRC Register are indeterminate. PORSF is cleared by all other resets. Since all
resets cause program execution to begin at the same location (0x0000) software can read the PORSF flag
to determine if a power-up was the cause of reset. The contents of internal data memory should be
assumed to be undefined after a power-on reset.
volts
2.70
VRST
2.55
2.0
D
VD
1.0
/RST
Logic HIGH
100ms 100ms
Logic LOW
Following a reset the WDT is automatically enabled and running with the default maximum time interval. If
desired the WDT can be disabled by system software or locked on to prevent accidental disabling. Once
locked, the WDT cannot be disabled until the next system reset. The state of the RST pin is unaffected by
this reset.
The WDT consists of a 21-bit timer running from the programmed system clock. The timer measures the
period between specific writes to its control register. If this period exceeds the programmed limit, a WDT
reset is generated. The WDT can be enabled and disabled as needed in software, or can be permanently
enabled if desired. Watchdog features are controlled via the Watchdog Timer Control Register (WDTCN)
shown in SFR Definition 13.1.
The writes of 0xDE and 0xAD must occur within 4 clock cycles of each other, or the disable operation is
ignored. This means that the prefetch engine should be enabled and interrupts should be disabled during
this procedure to avoid any delay between the two writes.
3 + WDTCN [ 2 – 0 ]
4 × T sysclk ; where Tsysclk is the system clock period.
For a 3 MHz system clock, this provides an interval range of 0.021 ms to 349.5 ms. WDTCN.7 must be
logic 0 when setting this interval. Reading WDTCN returns the programmed interval. WDTCN.[2:0] reads
111b after a system reset.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
xxxxx111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xFF
SFR Page: All Pages
Bit7: Reserved.
Bit6: CNVRSEF: Convert Start 0 Reset Source Enable and Flag
Write: 0: CNVSTR0 is not a reset source.
1: CNVSTR0 is a reset source (active low).
Read: 0: Source of prior reset was not CNVSTR0.
1: Source of prior reset was CNVSTR0.
Bit5: C0RSEF: Comparator0 Reset Enable and Flag.
Write: 0: Comparator0 is not a reset source.
1: Comparator0 is a reset source (active low).
Read: 0: Source of last reset was not Comparator0.
1: Source of last reset was Comparator0.
Bit4: SWRSF: Software Reset Force and Flag.
Write: 0: No effect.
1: Forces an internal reset. RST pin is not effected.
Read: 0: Source of last reset was not a write to the SWRSF bit.
1: Source of last reset was a write to the SWRSF bit.
Bit3: WDTRSF: Watchdog Timer Reset Flag.
0: Source of last reset was not WDT timeout.
1: Source of last reset was WDT timeout.
Bit2: MCDRSF: Missing Clock Detector Flag.
Write: 0: Missing Clock Detector disabled.
1: Missing Clock Detector enabled; triggers a reset if a missing clock condition is detected.
Read: 0: Source of last reset was not a Missing Clock Detector timeout.
1: Source of last reset was a Missing Clock Detector timeout.
Bit1: PORSF: Power-On Reset Flag.
Write: If the VDD monitor circuitry is enabled (by tying the MONEN pin to a logic high state), this bit can
be written to select or de-select the VDD monitor as a reset source.
0: De-select the VDD monitor as a reset source.
1: Select the VDD monitor as a reset source.
Important: At power-on, the VDD monitor is enabled/disabled using the external VDD monitor
enable pin (MONEN). The PORSF bit does not disable or enable the VDD monitor circuit. It sim-
ply selects the VDD monitor as a reset source.
Read: This bit is set whenever a power-on reset occurs. This may be due to a true power-on reset or a
VDD monitor reset. In either case, data memory should be considered indeterminate following the
reset.
0: Source of last reset was not a power-on or VDD monitor reset.
1: Source of last reset was a power-on or VDD monitor reset.
Note: When this flag is read as '1', all other reset flags are indeterminate.
Bit0: PINRSF: HW Pin Reset Flag.
Write: 0: No effect.
1: Forces a Power-On Reset. RST is driven low.
Read: 0: Source of prior reset was not RST pin.
1: Source of prior reset was RST pin.
NOTES:
14. Oscillators
The devices include a programmable internal oscillator and an external oscillator drive circuit. The internal
oscillator can be enabled, disabled, and calibrated using the OSCICN and OSCICL registers, as shown in
Figure 14.1. The system clock can be sourced by the external oscillator circuit, the internal oscillator, or the
on-chip phase-locked loop (PLL). The internal oscillator's electrical specifications are given in Table 14.1
on page 185.
CLKDIV1
CLKDIV0
IOSCEN
CLKSL1
CLKSL0
IFRDY
IFCN1
IFCN0
Option 3
XTAL1
XTAL2 AV+
Option 4
XTAL1 EN
Calibrated n 00
Internal
Oscillator
Option 2 Option 1
VDD XTAL1
SYSCLK
Input 01
OSC
Circuit
XTAL1
XTAL2
PLL 10
XOSCMD2
XOSCMD1
XOSCMD0
XTLVLD
XFCN2
XFCN1
XFCN0
AGND
OSCXCN
Electrical specifications for the precision internal oscillator are given in Table 14.1. Note that the system
clock may be derived from the programmed internal oscillator divided by 1, 2, 4, or 8, as defined by the
IFCN bits in register OSCICN.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
Variable
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8B
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - CLKDIV1 CLKDIV0 - - CLKSL1 CLKSL0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x97
SFR Page: F
When the crystal oscillator is enabled, the oscillator amplitude detection circuit requires a settle time to
achieve proper bias. Waiting at least 1 ms between enabling the oscillator and checking the XTLVLD bit
will prevent a premature switch to the external oscillator as the system clock. Switching to the external
oscillator before the crystal oscillator has stabilized can result in unpredictable behavior. The recom-
mended procedure is:
Important Note on External Crystals: Crystal oscillator circuits are quite sensitive to PCB layout. The
crystal should be placed as close as possible to the XTAL pins on the device. The traces should be as
short as possible and shielded with ground plane from any other traces which could introduce noise or
interference.
PLL0CN PLL0FLT
PLLPWR
PLLICO1
PLLICO0
PLLSRC
PLLLCK
PLLLP3
PLLLP2
PLLLP1
PLLLP0
PLLEN
Internal Divided
0 Reference
Oscillator PLL Clock
÷
Clock
Phase / Current Output
Frequency Loop Filter Controlled
External 1 Detection Oscillator
Oscillator
÷
PLLM4
PLLM3
PLLM2
PLLM1
PLLM0
PLLN7
PLLN6
PLLN5
PLLN4
PLLN3
PLLN2
PLLN1
PLLN0
PLL0DIV PLL0MUL
PLLN
PLL Frequency = Reference Frequency × ---------------
PLLM
Step 1. Ensure that the reference clock to be used (internal or external) is running and stable.
Step 2. Set the PLLSRC bit (PLL0CN.2) to select the desired clock source for the PLL.
Step 3. Program the Flash read timing bits, FLRT (FLSCL.5–4) to the appropriate value for the
new clock rate (see Section “15. Flash Memory” on page 199).
Step 4. Enable power to the PLL by setting PLLPWR (PLL0CN.0) to ‘1’.
Step 5. Program the PLL0DIV register to produce the divided reference frequency to the PLL.
Step 6. Program the PLLLP3–0 bits (PLL0FLT.3–0) to the appropriate range for the divided
reference frequency.
Step 7. Program the PLLICO1–0 bits (PLL0FLT.5–4) to the appropriate range for the PLL output
frequency.
Step 8. Program the PLL0MUL register to the desired clock multiplication factor.
Step 9. Wait at least 5 µs, to provide a fast frequency lock.
Step 10. Enable the PLL by setting PLLEN (PLL0CN.1) to ‘1’.
Step 11. Poll PLLLCK (PLL0CN.4) until it changes from ‘0’ to ‘1’.
Step 12. Switch the System Clock source to the PLL using the CLKSEL register.
If the PLL characteristics need to be changed when the PLL is already running, the following procedure
should be implemented:
Step 1. The system clock should first be switched to either the internal oscillator or an external
clock source that is running and stable, using the CLKSEL register.
Step 2. Ensure that the reference clock to be used for the new PLL setting (internal or external) is
running and stable.
Step 3. Set the PLLSRC bit (PLL0CN.2) to select the new clock source for the PLL.
Step 4. If moving to a faster frequency, program the Flash read timing bits, FLRT (FLSCL.5–4) to
the appropriate value for the new clock rate (see Section “15. Flash Memory” on
page 199).
Step 5. Disable the PLL by setting PLLEN (PLL0CN.1) to ‘0’.
Step 6. Program the PLL0DIV register to produce the divided reference frequency to the PLL.
Step 7. Program the PLLLP3–0 bits (PLL0FLT.3–0) to the appropriate range for the divided
reference frequency.
Step 8. Program the PLLICO1-0 bits (PLL0FLT.5–4) to the appropriate range for the PLL output
frequency.
Step 9. Program the PLL0MUL register to the desired clock multiplication factor.
Step 10. Enable the PLL by setting PLLEN (PLL0CN.1) to ‘1’.
Step 11. Poll PLLLCK (PLL0CN.4) until it changes from ‘0’ to ‘1’.
Step 12. Switch the System Clock source to the PLL using the CLKSEL register.
Step 13. If moving to a slower frequency, program the Flash read timing bits, FLRT (FLSCL.5–4)
to the appropriate value for the new clock rate (see Section “15. Flash Memory” on
page 199). Important Note: Cache reads, cache writes, and the prefetch engine
should be disabled whenever the FLRT bits are changed to a lower setting.
To shut down the PLL, the system clock should be switched to the internal oscillator or a stable external
clock source, using the CLKSEL register. Next, disable the PLL by setting PLLEN (PLL0CN.1) to ‘0’.
Finally, the PLL can be powered off, by setting PLLPWR (PLL0CN.0) to ‘0’. Note that the PLLEN and PLL-
PWR bits can be cleared at the same time.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - PLLM4 PLLM3 PLLM2 PLLM1 PLLM0 00000001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8D
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PLLN7 PLLN6 PLLN5 PLLN4 PLLN3 PLLN2 PLLN1 PLLN0 00000001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8E
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - PLLICO1 PLLICO0 PLLLP3 PLLLP2 PLLLP1 PLLLP0 00110001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8F
SFR Page: F
NOTES:
The Flash memory can be programmed from software using the MOVX write instruction with the address
and data byte to be programmed provided as normal operands. Before writing to Flash memory using
MOVX, Flash write operations must be enabled by setting the PSWE Program Store Write Enable bit
(PSCTL.0) to logic 1. This directs the MOVX writes to Flash memory instead of to XRAM, which is the
default target. The PSWE bit remains set until cleared by software. To avoid errant Flash writes, it is rec-
ommended that interrupts be disabled while the PSWE bit is logic 1.
Flash memory is read using the MOVC instruction. MOVX reads are always directed to XRAM, regardless
of the state of PSWE.
On the devices with 128 kB of Flash, the COBANK bits in the PSBANK register (SFR Definition 11.1)
determine which of the upper three Flash banks are mapped to the address range 0x08000 to 0x0FFFF for
Flash writes, reads and erases.
For devices with 64 kB of Flash. the COBANK bits should always remain set to ‘01’ to ensure that Flash
write, erase, and read operations are valid.
NOTE: To ensure the integrity of Flash memory contents, it is strongly recommended that the on-
chip VDD monitor be enabled by connecting the VDD monitor enable pin (MONEN) to VDD and set-
ting the PORSF bit in the RSTSRC register to ‘1’ in any system that writes and/or erases Flash
memory from software. See “Reset Sources” on page 177 for more information.
A write to Flash memory can clear bits but cannot set them; only an erase operation can set bits in Flash.
A byte location to be programmed must be erased before a new value can be written.
Write/Erase timing is automatically controlled by hardware. Note that on the 128 k Flash versions, 1024
bytes beginning at location 0x1FC00 are reserved. Flash writes and erases targeting the reserved area
should be avoided.
Two additional 128-byte sectors (256 bytes total) of Flash memory are included for non-volatile data stor-
age. The smaller sector size makes them particularly well suited as general purpose, non-volatile scratch-
pad memory. Even though Flash memory can be written a single byte at a time, an entire sector must be
erased first. In order to change a single byte of a multi-byte data set, the data must be moved to temporary
storage. The 128-byte sector-size facilitates updating data without wasting program memory or RAM
space. The 128-byte sectors are double-mapped over the normal Flash memory for MOVC reads and
MOVX writes only; their addresses range from 0x00 to 0x7F and from 0x80 to 0xFF (see Figure 15.2). To
access the 128-byte sectors, the SFLE bit in PSCTL must be set to logic 1. Code execution from the 128-
byte Scratchpad areas is not permitted. The 128-byte sectors can be erased individually, or both at the
same time. To erase both sectors simultaneously, the address 0x0400 should be targeted during the erase
operation with SFLE set to ‘1’. See Figure 15.1 for the memory map under different COBANK and SFLE
settings.
Undefined
0x8000
0x7FFF
0x00FF
Scratchpad
Areas (2)
0x0000
Figure 15.1. Flash Memory Map for MOVC Read and MOVX Write Operations
For single-byte writes to Flash, bytes are written individually, and the Flash write is performed after each
MOVX write instruction. The recommended procedure for writing Flash in single bytes is as follows:
A set of security lock bytes protect the Flash program memory from being read or altered across the JTAG
interface. Each bit in a security lock-byte protects one 16k-byte block of memory. Clearing a bit to logic 0 in
the Read Lock Byte prevents the corresponding block of Flash memory from being read across the JTAG
interface. Clearing a bit in the Write/Erase Lock Byte protects the block from JTAG erasures and/or writes.
The Scratchpad area is read or write/erase locked when all bits in the corresponding security byte are
cleared to logic 0.
On the C8051F12x and C8051F130/1, the security lock bytes are located at 0x1FBFE (Write/Erase Lock)
and 0x1FBFF (Read Lock), as shown in Figure 15.2. On the C8051F132/3, the security lock bytes are
located at 0x0FFFE (Write/Erase Lock) and 0x0FFFF (Read Lock), as shown in Figure 15.3. The 1024-
byte sector containing the lock bytes can be written to, but not erased, by software. An attempted read of a
read-locked byte returns undefined data. Debugging code in a read-locked sector is not possible through
the JTAG interface. The lock bits can always be read from and written to logic 0 regardless of the security
setting applied to the block containing the security bytes. This allows additional blocks to be protected after
the block containing the security bytes has been locked.
Important Note: To ensure protection from external access, the block containing the lock bytes
must be Write/Erase locked. On the 128 kB devices (C8051F12x and C8051F130/1), the block con-
taining the security bytes is 0x18000-0x1BFFF, and is locked by clearing bit 7 of the Write/Erase
Lock Byte. On the 64 kB devices (C8051F132/3), the block containing the security bytes is
0x0C000-0x0FFFF, and is locked by clearing bit 3 of the Write/Erase Lock Byte. If the page contain-
ing the security bytes is not Write/Erase locked, it is still possible to erase this page of Flash mem-
ory through the JTAG port and reset the security bytes.
When the page containing the security bytes has been Write/Erase locked, a JTAG full device erase
must be performed to unlock any areas of Flash protected by the security bytes. A JTAG full
device erase is initiated by performing a normal JTAG erase operation on either of the security byte
locations. This operation must be initiated through the JTAG port, and cannot be performed from
firmware running on the device.
SFLE = 1
0x00FF
Scratchpad Memory
0x00000
(Data only)
0x0000
Program/Data
Memory Space
Flash Read Lock Byte
Bits7–0: Each bit locks a corresponding block of memory. (Bit7 is MSB).
0: Read operations are locked (disabled) for corresponding block across the JTAG interface.
1: Read operations are unlocked (enabled) for corresponding block across the JTAG inter-
face.
Flash Write/Erase Lock Byte
Bits7–0: Each bit locks a corresponding block of memory.
0: Write/Erase operations are locked (disabled) for corresponding block across the JTAG
interface.
1: Write/Erase operations are unlocked (enabled) for corresponding block across the JTAG
interface.
NOTE: When the highest block is locked, the security bytes may be written but not erased.
Flash access Limit Register (FLACL)
The Flash Access Limit is defined by the setting of the FLACL register, as described in SFR
Definition 15.1. Firmware running at or above this address is prohibited from using the
MOVX and MOVC instructions to read, write, or erase Flash locations below this address.
SFLE = 1
0x00FF
Scratchpad Memory
0x00000
(Data only)
0x0000
Program/Data
Memory Space
Flash Read Lock Byte
Bits7–0: Each bit locks a corresponding block of memory. (Bit7 is MSB).
0: Read operations are locked (disabled) for corresponding block across the JTAG interface.
1: Read operations are unlocked (enabled) for corresponding block across the JTAG inter-
face.
Flash Write/Erase Lock Byte
Bits7–0: Each bit locks a corresponding block of memory.
0: Write/Erase operations are locked (disabled) for corresponding block across the JTAG
interface.
1: Write/Erase operations are unlocked (enabled) for corresponding block across the JTAG
interface.
NOTE: When the highest block is locked, the security bytes may be written but not erased.
Flash access Limit Register (FLACL)
The Flash Access Limit is defined by the setting of the FLACL register, as described in SFR
Definition 15.1. Firmware running at or above this address is prohibited from using the
MOVX and MOVC instructions to read, write, or erase Flash locations below this address.
The Flash Access Limit security feature (see SFR Definition 15.1) protects proprietary program code and
data from being read by software running on the device. This feature provides support for OEMs that wish
to program the MCU with proprietary value-added firmware before distribution. The value-added firmware
can be protected while allowing additional code to be programmed in remaining program memory space
later.
The Flash Access Limit (FAL) is a 17-bit address that establishes two logical partitions in the program
memory space. The first is an upper partition consisting of all the program memory locations at or above
the FAL address, and the second is a lower partition consisting of all the program memory locations start-
ing at 0x00000 up to (but excluding) the FAL address. Software in the upper partition can execute code in
the lower partition, but is prohibited from reading locations in the lower partition using the MOVC instruc-
tion. (Executing a MOVC instruction from the upper partition with a source address in the lower partition
will return indeterminate data.) Software running in the lower partition can access locations in both the
upper and lower partition without restriction.
The Value-added firmware should be placed in the lower partition. On reset, control is passed to the value-
added firmware via the reset vector. Once the value-added firmware completes its initial execution, it
branches to a predetermined location in the upper partition. If entry points are published, software running
in the upper partition may execute program code in the lower partition, but it cannot read or change the
contents of the lower partition. Parameters may be passed to the program code running in the lower parti-
tion either through the typical method of placing them on the stack or in registers before the call or by plac-
ing them in prescribed memory locations in the upper partition.
The FAL address is specified using the contents of the Flash Access Limit Register. The 8 MSBs of the 17-
bit FAL address are determined by the setting of the FLACL register. Thus, the FAL can be located on 512-
byte boundaries anywhere in program memory space. However, the 1024-byte erase sector size essen-
tially requires that a 1024 boundary be used. The contents of a non-initialized FLACL security byte are
0x00, thereby setting the FAL address to 0x00000 and allowing read access to all locations in program
memory space by default.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
SFR Address: 0xB7
SFR Page: F
1. The Read and Write/Erase Lock bytes (security bytes) provide security for Flash access
through the JTAG interface.
2. Any unlocked page may be read from, written to, or erased.
3. Locked pages cannot be read from, written to, or erased.
4. Reading the security bytes is always permitted.
5. Locking additional pages by writing to the security bytes is always permitted.
6. If the page containing the security bytes is unlocked, it can be directly erased. Doing so will
reset the security bytes and unlock all pages of Flash.
7. If the page containing the security bytes is locked, it cannot be directly erased. To unlock the
page containing the security bytes, a full JTAG device erase is required. A full JTAG
device erase will erase all Flash pages, including the page containing the security bytes and
the security bytes themselves.
8. The Reserved Area cannot be read from, written to, or erased at any time.
Accessing Flash from firmware residing below the Flash Access Limit:
1. The Read and Write/Erase Lock bytes (security bytes) do not restrict Flash access from user
firmware.
2. Any page of Flash except the page containing the security bytes may be read from, written to,
or erased.
3. The page containing the security bytes cannot be erased. Unlocking pages of Flash can
only be performed via the JTAG interface.
4. The page containing the security bytes may be read from or written to. Pages of Flash can be
locked from JTAG access by writing to the security bytes.
5. The Reserved Area cannot be read from, written to, or erased at any time.
Accessing Flash from firmware residing at or above the Flash Access Limit:
1. The Read and Write/Erase Lock bytes (security bytes) do not restrict Flash access from user
firmware.
2. Any page of Flash at or above the Flash Access Limit except the page containing the security
bytes may be read from, written to, or erased.
3. Any page of Flash below the Flash Access Limit cannot be read from, written to, or erased.
4. Code branches to locations below the Flash Access Limit are permitted.
5. The page containing the security bytes cannot be erased. Unlocking pages of Flash can
only be performed via the JTAG interface.
6. The page containing the security bytes may be read from or written to. Pages of Flash can be
locked from JTAG access by writing to the security bytes.
7. The Reserved Area cannot be read from, written to, or erased at any time.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - FLRT Reserved Reserved Reserved FLWE 10000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
SFR Address: 0xB7
SFR Page: 0
Important Note: When changing the FLRT bits to a lower setting (e.g. when changing from a
value of 11b to 00b), cache reads, cache writes, and the prefetch engine should be
disabled using the CCH0CN register (see SFR Definition 16.1).
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - - SFLE PSEE PSWE 00000000
SFR
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Address:
SFR Address: 0x8F
SFR Page: 0
NOTES:
Instruction
Data
CIP-51
FLASH
Memory
Prefetch Branch Target
Engine Cache
Instruction Address
The replacement algorithm is selected with the Cache Algorithm bit, CHALGM (CCH0TN.3). When
CHALGM is cleared to ‘0’, the cache will use the rebound algorithm to replace cache locations. The
rebound algorithm replaces locations in order from the beginning of cache memory to the end, and then
from the end of cache memory to the beginning. When CHALGM is set to ‘1’, the cache will use the
pseudo-random algorithm to replace cache locations. The pseudo-random algorithm uses a pseudo-ran-
dom number to determine which cache location to replace. The cache can be manually emptied by writing
a ‘1’ to the CHFLUSH bit (CCH0CN.4).
Valid
Bit Address Data
V0 TAG 0 SLOT 0
V1 TAG 1 SLOT 1
V2 TAG 2 SLOT 2
Cache Data
V58 TAG 58 SLOT 58
V59 TAG 59 SLOT 59
V60 TAG 60 SLOT 60
V61 TAG 61 SLOT 61
V62 TAG 62 SLOT 62
A16 A2 A1 A0
0 0 Byte 0
0 1 Byte 1
TAG = 15 MSBs of Absolute FLASH Address
1 0 Byte 2
1 1 Byte 3
SLOT = 4 Instruction
Data Bytes
The most basic level of cache control is implemented with the Cache Miss Penalty Threshold bits,
CHMSTH (CCH0TN.1-0). If the processor is stalled during a prefetch operation for more clock cycles than
the number stored in CHMSTH, the requested data will be cached when it becomes available. The
CHMSTH bits are set to zero by default, meaning that any time the processor is stalled, the new data will
be cached. If, for example, CHMSTH is equal to 2, any cache miss causing a delay of 3 or 4 clock cycles
will be cached, while a cache miss causing a delay of 1-2 clock cycles will not be cached.
Certain types of instruction data or certain blocks of code can also be excluded from caching. The destina-
tions of RETI instructions are, by default, excluded from caching. To enable caching of RETI destinations,
the CHRETI bit (CCH0CN.3) can be set to ‘1’. It is generally not beneficial to cache RETI destinations
unless the same instruction is likely to be interrupted repeatedly (such as a code loop that is waiting for an
interrupt to happen). Instructions that are part of an interrupt service routine (ISR) can also be excluded
from caching. By default, ISR instructions are cached, but this can be disabled by clearing the CHISR bit
(CCH0CN.2) to ‘0’. The other information that can be explicitly excluded from caching are the data
returned by MOVC instructions. Clearing the CHMOV bit (CCH0CN.1) to ‘0’ will disable caching of MOVC
data. If MOVC caching is allowed, it can be restricted to only use slot 0 for the MOVC information (exclud-
ing cache push operations). The CHFIXM bit (CCH0TN.2) controls this behavior.
Further cache control can be implemented by disabling all cache writes. Cache writes can be disabled by
clearing the CHWREN bit (CCH0CN.7) to ‘0’. Although normal cache writes (such as those after a cache
miss) are disabled, data can still be written to the cache with a cache push operation. Disabling cache
writes can be used to prevent a non-critical section of code from changing the cache contents. Note that
regardless of the value of CHWREN, a Flash write or erase operation automatically removes the affected
bytes from the cache. Cache reads and the prefetch engine can also be individually disabled. Disabling
cache reads forces all instructions data to execute from Flash memory or from the prefetch engine. To dis-
able cache reads, the CHRDEN bit (CCH0CN.6) can be cleared to ‘0’. Note that when cache reads are
disabled, cache writes will still occur (if CHWREN is set to ‘1’). Disabling the prefetch engine is accom-
plished using the CHPFEN bit (CCH0CN.5). When this bit is cleared to ‘0’, the prefetch engine will be dis-
abled. If both CHPFEN and CHRDEN are ‘0’, code will execute at a fixed rate, as instructions become
available from the Flash memory.
Cache locations can also be pre-loaded and locked with time-critical branch destinations. For example, in
a system with an ISR that must respond as fast as possible, the entry point for the ISR can be locked into
a cache location to minimize the response latency of the ISR. Up to 61 locations can be locked into the
cache at one time. Instructions are locked into cache by enabling cache push operations with the
CHPUSH bit (CCH0LC.7). When CHPUSH is set to ‘1’, a MOVC instruction will cause the four-byte seg-
ment containing the data byte to be written to the cache slot location indicated by CHSLOT (CCH0LC.5-0).
CHSLOT is them decremented to point to the next lockable cache location. This process is called a cache
push operation. Cache locations that are above CHSLOT are “locked”, and cannot be changed by the pro-
cessor core, as shown in Figure 16.3. Cache locations can be unlocked by using a cache pop operation.
A cache pop is performed by writing a ‘1’ to the CHPOP bit (CCH0LC.6). When a cache pop is initiated,
the value of CHSLOT is incremented. This unlocks the most recently locked cache location, but does not
remove the information from the cache. Note that a cache pop should not be initiated if CHSLOT is equal
to 111110b. Doing so may have an adverse effect on cache performance. Important: Although locking
cache location 1 is not explicitly disabled by hardware, the entire cache will be unlocked when
CHSLOT is equal to 000000b. Therefore, cache locations 1 and 0 must remain unlocked at all
times.
Lock Status
TAG 0 SLOT 0 UNLOCKED
TAG 1 SLOT 1 UNLOCKED
Cache Push TAG 2 SLOT 2 UNLOCKED
Operations UNLOCKED
Decrement
CHSLOT
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CHWREN CHRDEN CHPFEN CHFLSH CHRETI CHISR CHMOVC CHBLKW 11100110
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA1
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CHMSCTL CHALGM CHFIXM CHMSTH 00000100
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA2
SFR Page: F
NOTES:
MOV DPTR, #1234h ; load DPTR with 16-bit address to read (0x1234)
MOVX A, @DPTR ; load contents of 0x1234 into accumulator A
The above example uses the 16-bit immediate MOV instruction to set the contents of DPTR. Alternately,
the DPTR can be accessed through the SFR registers DPH, which contains the upper 8-bits of DPTR, and
DPL, which contains the lower 8-bits of DPTR.
1. Select EMIF on Low Ports (P3, P2, P1, and P0) or High Ports (P7, P6, P5, and P4).
2. Configure the Output Modes of the port pins as either push-pull or open-drain (push-pull is
most common).
3. Configure Port latches to “park” the EMIF pins in a dormant state (usually by setting them to
logic ‘1’).
4. Select Multiplexed mode or Non-multiplexed mode.
5. Select the memory mode (on-chip only, split mode without bank select, split mode with bank
select, or off-chip only).
6. Set up timing to interface with off-chip memory or peripherals.
Each of these five steps is explained in detail in the following sections. The Port selection, Multiplexed
mode selection, and Mode bits are located in the EMI0CF register shown in SFR Definition 17.2.
The External Memory Interface claims the associated Port pins for memory operations ONLY during the
execution of an off-chip MOVX instruction. Once the MOVX instruction has completed, control of the Port
pins reverts to the Port latches or to the Crossbar (on Ports 3, 2, 1, and 0). See Section “18. Port Input/
Output” on page 235 for more information about the Crossbar and Port operation and configuration. The
Port latches should be explicitly configured to ‘park’ the External Memory Interface pins in a dor-
mant state, most commonly by setting them to a logic 1.
During the execution of the MOVX instruction, the External Memory Interface will explicitly disable the driv-
ers on all Port pins that are acting as Inputs (Data[7:0] during a READ operation, for example). The Output
mode of the Port pins (whether the pin is configured as Open-Drain or Push-Pull) is unaffected by the
External Memory Interface operation, and remains controlled by the PnMDOUT registers. In most cases,
the output modes of all EMIF pins should be configured for push-pull mode. See“Configuring the Output
Modes of the Port Pins” on page 239.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PGSEL7 PGSEL6 PGSEL5 PGSEL4 PGSEL3 PGSEL2 PGSEL1 PGSEL0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA2
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - PRTSEL EMD2 EMD1 EMD0 EALE1 EALE0 00000011
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA3
SFR Page: 0
In Multiplexed mode, the external MOVX operation can be broken into two phases delineated by the state
of the ALE signal. During the first phase, ALE is high and the lower 8-bits of the Address Bus are pre-
sented to AD[7:0]. During this phase, the address latch is configured such that the ‘Q’ outputs reflect the
states of the ‘D’ inputs. When ALE falls, signaling the beginning of the second phase, the address latch
outputs remain fixed and are no longer dependent on the latch inputs. Later in the second phase, the Data
Bus controls the state of the AD[7:0] port at the time /RD or /WR is asserted.
See Section “17.6.2. Multiplexed Mode” on page 230 for more information.
74HC373
ALE G
E AD[7:0] ADDRESS/DATA BUS D Q A[7:0]
M VDD 64K X 8
SRAM
I 8
(Optional)
F I/O[7:0]
CE
/WR WE
/RD OE
M (Optional) 64K X 8
8 SRAM
I D[7:0] DATA BUS I/O[7:0]
F /WR
CE
WE
/RD OE
• 8-bit MOVX operations use the contents of EMI0CN to determine the high-byte of the effective address
and R0 or R1 to determine the low-byte of the effective address.
• 16-bit MOVX operations use the contents of the 16-bit DPTR to determine the effective address.
17.5.2. Split Mode without Bank Select
When EMI0CF.[3:2] are set to ‘01’, the XRAM memory map is split into two areas, on-chip space and off-
chip space.
• Effective addresses below the 8 k boundary will access on-chip XRAM space.
• Effective addresses above the 8 k boundary will access off-chip space.
• 8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-
chip or off-chip. However, in the “No Bank Select” mode, an 8-bit MOVX operation will not drive the
upper 8-bits A[15:8] of the Address Bus during an off-chip access. This allows the user to manipulate
the upper address bits at will by setting the Port state directly via the port latches. This behavior is in
contrast with “Split Mode with Bank Select” described below. The lower 8-bits of the Address Bus
A[7:0] are driven, determined by R0 or R1.
• 16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-
chip or off-chip, and unlike 8-bit MOVX operations, the full 16-bits of the Address Bus A[15:0] are
driven during the off-chip transaction.
On-Chip XRAM
On-Chip XRAM On-Chip XRAM
On-Chip XRAM
0x0000 0x0000 0x0000 0x0000
• Effective addresses below the 8k boundary will access on-chip XRAM space.
• Effective addresses above the 8k boundary will access off-chip space.
• 8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-
chip or off-chip. The upper 8-bits of the Address Bus A[15:8] are determined by EMI0CN, and the lower
8-bits of the Address Bus A[7:0] are determined by R0 or R1. All 16-bits of the Address Bus A[15:0] are
driven in “Bank Select” mode.
• 16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-
chip or off-chip, and the full 16-bits of the Address Bus A[15:0] are driven during the off-chip transac-
tion.
17.5.4. External Only
When EMI0CF[3:2] are set to ‘11’, all MOVX operations are directed to off-chip space. On-chip XRAM is
not visible to the CPU. This mode is useful for accessing off-chip memory located between 0x0000 and the
8k boundary.
• 8-bit MOVX operations ignore the contents of EMI0CN. The upper Address bits A[15:8] are not driven
(identical behavior to an off-chip access in “Split Mode without Bank Select” described above). This
allows the user to manipulate the upper address bits at will by setting the Port state directly. The lower
8-bits of the effective address A[7:0] are determined by the contents of R0 or R1.
• 16-bit MOVX operations use the contents of DPTR to determine the effective address A[15:0]. The full
16-bits of the Address Bus A[15:0] are driven during the off-chip transaction.
The timing for an off-chip MOVX instruction can be calculated by adding 4 SYSCLK cycles to the timing
parameters defined by the EMI0TC register. Assuming non-multiplexed operation, the minimum execution
time for an off-chip XRAM operation is 5 SYSCLK cycles (1 SYSCLK for /RD or /WR pulse + 4 SYSCLKs).
For multiplexed operations, the Address Latch Enable signal will require a minimum of 2 additional
SYSCLK cycles. Therefore, the minimum execution time for an off-chip XRAM operation in multiplexed
mode is 7 SYSCLK cycles (2 for /ALE + 1 for /RD or /WR + 4). The programmable setup and hold times
default to the maximum delay settings after a reset. Table 17.1 lists the ac parameters for the External
Memory Interface, and Figure 17.4 through Figure 17.9 show the timing diagrams for the different External
Memory Interface modes and MOVX operations.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
EAS1 EAS0 ERW3 EWR2 EWR1 EWR0 EAH1 EAH0 11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA1
SFR Page: 0
T T
WDS WDH
T T T
ACS ACW ACH
T T
RDS RDH
T T T
ACS ACW ACH
ADDR[15:8] P1/P5
T T
WDS WDH
T T T
ACS ACW ACH
ADDR[15:8] P1/P5
T T
RDS RDH
T T T
ACS ACW ACH
T T
WDS WDH
T T T
ACS ACW ACH
T T
RDS RDH
T T T
ACS ACW ACH
T T
ALEH ALEL
T T
WDS WDH
T T T
ACS ACW ACH
T T
ALEH ALEL T T
RDS RDH
T T T
ACS ACW ACH
ADDR[15:8] P2/P6
T T
ALEH ALEL
T T
WDS WDH
T T T
ACS ACW ACH
ADDR[15:8] P2/P6
T T
ALEH ALEL T T
RDS RDH
T T T
ACS ACW ACH
T T
ALEH ALEL
T T
WDS WDH
T T T
ACS ACW ACH
T T
ALEH ALEL T T
RDS RDH
T T T
ACS ACW ACH
NOTES:
/WEAK-PULLUP
/PORT-OUTENABLE
(WEAK)
PORT
PAD
PORT-OUTPUT
PORT-INPUT
0.3 x
Input Low Voltage (VIL)
VDD
Input Capacitance 5 pF
A wide array of digital resources is available through the four lower I/O Ports: P0, P1, P2, and P3. Each of
the pins on P0, P1, P2, and P3, can be defined as a General-Purpose I/O (GPIO) pin or can be controlled
by a digital peripheral or function (like UART0 or /INT1 for example), as shown in Figure 18.2. The system
designer controls which digital functions are assigned pins, limited only by the number of pins available.
This resource assignment flexibility is achieved through the use of a Priority Crossbar Decoder. Note that
the state of a Port I/O pin can always be read from its associated Data register regardless of whether that
pin has been assigned to a digital peripheral or behaves as GPIO. The Port pins on Port 1 can be used as
Analog Inputs to ADC2.
An External Memory Interface which is active during the execution of an off-chip MOVX instruction can be
active on either the lower Ports or the upper Ports. See Section “17. External Data Memory Interface
and On-Chip XRAM” on page 219 for more information about the External Memory Interface.
2 External
SMBus Priority Pins
2 Decoder
UART1 P0.0
P0 Highest
(Internal Digital Signals)
8
7 I/O Priority
PCA Cells P0.7
Comptr. 2
Outputs Digital
P1 P1.0
Crossbar 8
I/O
T0, T1, Cells P1.7
T2, T2EX, 8
T4,T4EX
/INT0,
/INT1 P2 P2.0
8
I/O
Cells P2.7
Lowest /SYSCLK divided by 1,2,4, or 8
Priority CNVSTR0/2 2
P3 P3.0
8 8
I/O Lowest
Cells P3.7 Priority
P0
(P0.0-P0.7)
P1
(P1.0-P1.7) To External
Port Memory
Latches 8 Interface
To ADC2 Input
(EMIF)
P2 (‘F12x Only)
(P2.0-P2.7)
P3
(P3.0-P3.7)
AIN2.5/A13
AIN2.6/A14
AIN2.7/A15
AIN2.0/A8
AIN2.1/A9
A10m/A2
A11m/A3
A12m/A4
A13m/A5
A14m/A6
A15m/A7
A8m/A0
A9m/A1
AD0/D0
AD1/D1
AD2/D2
AD3/D3
AD4/D4
AD5/D5
AD6/D6
AD7/D7
/WR
ALE
/RD
AIN2 Inputs/Non-muxed Addr H Muxed Addr H/Non-muxed Addr L Muxed Data/Non-muxed Data
Because UART0 has the highest priority, its pins will always be mapped to P0.0 and P0.1 when UART0EN
is set to a logic 1. If a digital peripheral’s enable bits are not set to a logic 1, then its ports are not accessi-
ble at the Port pins of the device. Also note that the Crossbar assigns pins to all associated functions when
a serial communication peripheral is selected (i.e. SMBus, SPI, UART). It would be impossible, for exam-
ple, to assign TX0 to a Port pin without assigning RX0 as well. Each combination of enabled peripherals
results in a unique device pinout.
All Port pins on Ports 0 through 3 that are not allocated by the Crossbar can be accessed as General-Pur-
pose I/O (GPIO) pins by reading and writing the associated Port Data registers (See SFR Definition 18.4,
SFR Definition 18.6, SFR Definition 18.9, and SFR Definition 18.11), a set of SFR’s which are both byte-
and bit-addressable. The output states of Port pins that are allocated by the Crossbar are controlled by the
digital peripheral that is mapped to those pins. Writes to the Port Data registers (or associated Port bits)
will have no effect on the states of these pins.
A Read of a Port Data register (or Port bit) will always return the logic state present at the pin itself, regard-
less of whether the Crossbar has allocated the pin for peripheral use or not. An exception to this occurs
during the execution of a read-modify-write instruction (ANL, ORL, XRL, CPL, INC, DEC, DJNZ, JBC,
CLR, SETB, and the bitwise MOV write operation). During the read cycle of the read-modify-write instruc-
tion, it is the contents of the Port Data register, not the state of the Port pins themselves, which is read.
Note that at clock rates above 50 MHz, when a pin is written and then immediately read (i.e. a write instruc-
tion followed immediately by a read instruction), the propagation delay of the port drivers may cause the
read instruction to return the previous logic level of the pin.
Because the Crossbar registers affect the pinout of the peripherals of the device, they are typically config-
ured in the initialization code of the system before the peripherals themselves are configured. Once config-
ured, the Crossbar registers are typically left alone.
Once the Crossbar registers have been properly configured, the Crossbar is enabled by setting XBARE
(XBR2.4) to a logic 1. Until XBARE is set to a logic 1, the output drivers on Ports 0 through 3 are
explicitly disabled in order to prevent possible contention on the Port pins while the Crossbar reg-
isters and other registers which can affect the device pinout are being written.
The output drivers on Crossbar-assigned input signals (like RX0, for example) are explicitly disabled; thus
the values of the Port Data registers and the PnMDOUT registers have no effect on the states of these
pins.
The output mode of each port pin can be configured to be either Open-Drain or Push-Pull. In the Push-Pull
configuration, writing a logic 0 to the associated bit in the Port Data register will cause the Port pin to be
driven to GND, and writing a logic 1 will cause the Port pin to be driven to VDD. In the Open-Drain configu-
ration, writing a logic 0 to the associated bit in the Port Data register will cause the Port pin to be driven to
GND, and a logic 1 will cause the Port pin to assume a high-impedance state. The Open-Drain configura-
tion is useful to prevent contention between devices in systems where the Port pin participates in a shared
interconnection in which multiple outputs are connected to the same physical wire (like the SDA signal on
an SMBus connection).
The output modes of the Port pins on Ports 0 through 3 are determined by the bits in the associated
PnMDOUT registers (See SFR Definition 18.5, SFR Definition 18.8, SFR Definition 18.10, and SFR Defini-
tion 18.12). For example, a logic 1 in P3MDOUT.7 will configure the output mode of P3.7 to Push-Pull; a
logic 0 in P3MDOUT.7 will configure the output mode of P3.7 to Open-Drain. All Port pins default to Open-
Drain output.
The PnMDOUT registers control the output modes of the port pins regardless of whether the Crossbar has
allocated the Port pin for a digital peripheral or not. The exceptions to this rule are: the Port pins connected
to SDA, SCL, RX0 (if UART0 is in Mode 0), and RX1 (if UART1 is in Mode 0) are always configured as
Open-Drain outputs, regardless of the settings of the associated bits in the PnMDOUT registers.
If the Port pin has been assigned to a digital peripheral by the Crossbar and that pin functions as an input
(for example RX0, the UART0 receive pin), then the output drivers on that pin are automatically disabled.
1. Disables the digital input path from the pin. This prevents additional power supply current from
being drawn when the voltage at the pin is near VDD / 2. A read of the Port Data bit will return
a logic 0 regardless of the voltage at the Port pin.
2. Disables the weak pullup device on the pin.
3. Causes the Crossbar to “skip over” the pin when allocating Port pins for digital peripherals.
Note that the output drivers on a pin configured as an Analog Input are not explicitly disabled. Therefore,
the associated P1MDOUT bits of pins configured as Analog Inputs should explicitly be set to logic 0
(Open-Drain output mode), and the associated Port1 Data bits should be set to logic 1 (high-impedance).
Also note that it is not required to configure a Port pin as an Analog Input in order to use it as an input to
ADC2, however, it is strongly recommended. See the ADC2 section in this datasheet for further informa-
tion.
If the External Memory Interface is enabled on the Low ports and an off-chip MOVX operation occurs, the
External Memory Interface will control the output states of the affected Port pins during the execution
phase of the MOVX instruction, regardless of the settings of the Crossbar registers or the Port Data regis-
ters. The output configuration of the Port pins is not affected by the EMIF operation, except that Read
operations will explicitly disable the output drivers on the Data Bus. See Section “17. External Data Mem-
ory Interface and On-Chip XRAM” on page 219 for more information about the External Memory Inter-
face.
A10m/A2
A11m/A3
A12m/A4
A13m/A5
A14m/A6
A15m/A7
A8m/A0
A9m/A1
AD0/D0
AD1/D1
AD2/D2
AD3/D3
AD4/D4
AD5/D5
AD6/D6
AD7/D7
/WR
ALE
/RD
AIN2 Inputs/Non-muxed Addr H Muxed Addr H/Non-muxed Addr L Muxed Data/Non-muxed Data
AIN2.5/A13
AIN2.6/A14
AIN2.7/A15
AIN2.0/A8
AIN2.1/A9
A10m/A2
A11m/A3
A12m/A4
A13m/A5
A14m/A6
A15m/A7
A8m/A0
A9m/A1
AD0/D0
AD1/D1
AD2/D2
AD3/D3
AD4/D4
AD5/D5
AD6/D6
AD7/D7
/WR
ALE
/RD
AIN2 Inputs/Non-muxed Addr H Muxed Addr H/Non-muxed Addr L Muxed Data/Non-muxed Data
1. XBR0, XBR1, and XBR2 are set such that UART0EN = 1, SMB0EN = 1, INT0E = 1,
INT1E = 1, and EMIFLE = 1. Thus: XBR0 = 0x05, XBR1 = 0x14, and XBR2 = 0x02.
2. We configure the External Memory Interface to use Multiplexed mode and to appear on the
Low ports. PRTSEL = 0, EMD2 = 0.
3. We configure the desired Port 1 pins to Analog Input mode by setting P1MDIN to 0xE3
(P1.4, P1.3, and P1.2 are Analog Inputs, so their associated P1MDIN bits are set to logic 0).
4. We enable the Crossbar by setting XBARE = 1: XBR2 = 0x42.
- UART0 has the highest priority, so P0.0 is assigned to TX0, and P0.1 is assigned to RX0.
- The SMBus is next in priority order, so P0.2 is assigned to SDA, and P0.3 is assigned to
SCL.
- UART1 is next in priority order, so P0.4 is assigned to TX1. Because the External Memory
Interface is selected on the lower Ports, EMIFLE = 1, which causes the Crossbar to skip
P0.6 (/RD) and P0.7 (/WR). Because the External Memory Interface is configured in Multi-
plexed mode, the Crossbar will also skip P0.5 (ALE). RX1 is assigned to the next non-
skipped pin, which in this case is P1.0.
- /INT0 is next in priority order, so it is assigned to P1.1.
- P1MDIN is set to 0xE3, which configures P1.2, P1.3, and P1.4 as Analog Inputs, causing
the Crossbar to skip these pins.
- /INT1 is next in priority order, so it is assigned to the next non-skipped pin, which is P1.5.
- The External Memory Interface will drive Ports 2 and 3 (denoted by red dots in
Figure 18.6) during the execution of an off-chip MOVX instruction.
5. We set the UART0 TX pin (TX0, P0.0) and UART1 TX pin (TX1, P0.4) outputs to Push-Pull by
setting P0MDOUT = 0x11.
6. We configure all EMIF-controlled pins to push-pull output mode by setting P0MDOUT |= 0xE0;
P2MDOUT = 0xFF; P3MDOUT = 0xFF.
7. We explicitly disable the output drivers on the 3 Analog Input pins by setting P1MDOUT =
0x00 (configure outputs to Open-Drain) and P1 = 0xFF (a logic 1 selects the high-impedance
state).
AIN2.5/A13
AIN2.6/A14
AIN2.7/A15
AIN2.0/A8
AIN2.1/A9
A10m/A2
A11m/A3
A12m/A4
A13m/A5
A14m/A6
A15m/A7
A8m/A0
A9m/A1
AD0/D0
AD1/D1
AD2/D2
AD3/D3
AD4/D4
AD5/D5
AD6/D6
AD7/D7
ALE
/WR
/RD
AIN2 Inputs/Non-muxed Addr H Muxed Addr H/Non-muxed Addr L Muxed Data/Non-muxed Data
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CP0E ECI0E PCA0ME UART0EN SPI0EN SMB0EN 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xE1
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
SYSCKE T2EXE T2E INT1E T1E INT0E T0E CP1E 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xE2
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P0.7 P0.6 P0.5 P0.4 P0.3 P0.2 P0.1 P0.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0x80
SFR Page: All Pages
Note: P0.7 (/WR), P0.6 (/RD), and P0.5 (ALE) can be driven by the External Data Memory Interface.
See Section “17. External Data Memory Interface and On-Chip XRAM” on page 219 for
more information. See also SFR Definition 18.3 for information about configuring the Crossbar
for External Memory accesses.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA4
SFR Page: F
Note: SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are
always configured as Open-Drain when they appear on Port pins.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0x90
SFR Page: All Pages
Notes:
1. On C8051F12x devices, P1.[7:0] can be configured as inputs to ADC2 as AIN2.[7:0], in which
case they are ‘skipped’ by the Crossbar assignment process and their digital input paths are
disabled, depending on P1MDIN (See SFR Definition 18.7). Note that in analog mode, the
output mode of the pin is determined by the Port 1 latch and P1MDOUT (SFR Definition 18.8).
See Section “7. ADC2 (8-Bit ADC, C8051F12x Only)” on page 91 for more information
about ADC2.
2. P1.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Non-
multiplexed mode). See Section “17. External Data Memory Interface and On-Chip
XRAM” on page 219 for more information about the External Memory Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
11111111
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xAD
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA5
SFR Page: F
Note: SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are
always configured as Open-Drain when they appear on Port pins.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR
0xA0
Address:
All Pages
SFR Page:
Note: P2.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Multiplexed
mode, or as Address[7:0] in Non-multiplexed mode). See Section “17. External Data
Memory Interface and On-Chip XRAM” on page 219 for more information about the
External Memory Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA6
SFR Page: F
Note: SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are
always configured as Open-Drain when they appear on Port pins.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P3.7 P3.6 P3.5 P3.4 P3.3 P3.2 P3.1 P3.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xB0
SFR Page: All Pages
Note: P3.[7:0] can be driven by the External Data Memory Interface (as AD[7:0] in Multiplexed
mode, or as D[7:0] in Non-multiplexed mode). See Section “17. External Data Memory
Interface and On-Chip XRAM” on page 219 for more information about the External Memory
Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA7
SFR Page: F
A Read of a Port Data register (or Port bit) will always return the logic state present at the pin itself, regard-
less of whether the Crossbar has allocated the pin for peripheral use or not. An exception to this occurs
during the execution of a read-modify-write instruction (ANL, ORL, XRL, CPL, INC, DEC, DJNZ, JBC,
CLR, SETB, and the bitwise MOV write operation). During the read cycle of the read-modify-write instruc-
tion, it is the contents of the Port Data register, not the state of the Port pins themselves, which is read.
Note that at clock rates above 50 MHz, when a pin is written and then immediately read (i.e. a write instruc-
tion followed immediately by a read instruction), the propagation delay of the port drivers may cause the
read instruction to return the previous logic level of the pin.
1. Leave the weak pullup devices enabled by setting WEAKPUD (XBR2.7) to a logic 0.
2. Configure the output modes of P4, P5, P6, and P7 to “Push-Pull” by writing PnMDOUT = 0xFF.
3. Force the output states of P4, P5, P6, and P7 to logic 0 by writing zeros to the Port Data regis-
ters: P4 = 0x00, P5 = 0x00, P6= 0x00, and P7 = 0x00.
18.2.2. Configuring the Output Modes of the Port Pins
The output mode of each port pin can be configured to be either Open-Drain or Push-Pull. In the Push-Pull
configuration, a logic 0 in the associated bit in the Port Data register will cause the Port pin to be driven to
GND, and a logic 1 will cause the Port pin to be driven to VDD. In the Open-Drain configuration, a logic 0 in
the associated bit in the Port Data register will cause the Port pin to be driven to GND, and a logic 1 will
cause the Port pin to assume a high-impedance state. The Open-Drain configuration is useful to prevent
contention between devices in systems where the Port pin participates in a shared interconnection in
which multiple outputs are connected to the same physical wire.
The output modes of the Port pins on Ports 4 through 7 are determined by the bits in their respective
PnMDOUT Output Mode Registers. Each bit in PnMDOUT controls the output mode of its corresponding
port pin (see SFR Definition 18.14, SFR Definition 18.16, SFR Definition 18.18, and SFR Definition 18.20).
For example, to place Port pin 4.3 in push-pull mode (digital output), set P4MDOUT.3 to logic 1. All port
pins default to open-drain mode upon device reset.
If the External Memory Interface is enabled on the High ports and an off-chip MOVX operation occurs, the
External Memory Interface will control the output states of the affected Port pins during the execution
phase of the MOVX instruction, regardless of the settings of the Port Data registers. The output configura-
tion of the Port pins is not affected by the EMIF operation, except that Read operations will explicitly dis-
able the output drivers on the Data Bus during the MOVX execution. See Section “17. External Data
Memory Interface and On-Chip XRAM” on page 219 for more information about the External Memory
Interface.
Note: P4.7 (/WR), P4.6 (/RD), and P4.5 (ALE) can be driven by the External Data Memory Interface.
See Section “17. External Data Memory Interface and On-Chip XRAM” on page 219 for
more information.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9C
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P5.7 P5.6 P5.5 P5.4 P5.3 P5.2 P5.1 P5.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xD8
SFR Page: F
Note: P5.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Non-
multiplexed mode). See Section “17. External Data Memory Interface and On-Chip
XRAM” on page 219 for more information about the External Memory Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9D
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P6.7 P6.6 P6.5 P6.4 P6.3 P6.2 P6.1 P6.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xE8
SFR Page: F
Note: P6.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Multiplexed
mode, or as Address[7:0] in Non-multiplexed mode). See Section “17. External Data
Memory Interface and On-Chip XRAM” on page 219 for more information about the
External Memory Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9E
SFR Page: F
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
P7.7 P7.6 P7.5 P7.4 P7.3 P7.2 P7.1 P7.0 11111111
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0xF8
SFR Page: F
Note: P7.[7:0] can be driven by the External Data Memory Interface (as AD[7:0] in Multiplexed
mode, or as D[7:0] in Non-multiplexed mode). See Section “17. External Data Memory
Interface and On-Chip XRAM” on page 219 for more information about the External Memory
Interface.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9F
SFR Page: F
NOTES:
SMBus0 may operate as a master and/or slave, and may function on a bus with multiple masters. SMBus0
provides control of SDA (serial data), SCL (serial clock) generation and synchronization, arbitration logic,
and START/STOP control and generation.
SFR Bus
Clock Divide
SYSCLK
Logic
SCL
FILTER
SMBUS CONTROL LOGIC
Arbitration
SMBUS Interrupt SCL Synchronization SCL
Request N
IRQ Status Generation Control
SCL Generation (Master Mode)
IRQ Generation
Data Path SDA
Control Control C
R
O
S
Port I/O
S
A=B
A=B
B
B A B A A
R
0000000b
7 MSBs 8
SMB0DAT
SDA
7 6 5 4 3 2 1 0 FILTER
8 8 1
S S S S S S S N
L L L L L L L 0
V V V V V V V G
6 5 4 3 2 1 0 C
SMB0ADR Read Write to
SMB0DAT SMB0DAT
SFR Bus
Figure 19.2 shows a typical SMBus configuration. The SMBus0 interface will work at any voltage between
3.0 and 5.0 V and different devices on the bus may operate at different voltage levels. The bi-directional
SCL (serial clock) and SDA (serial data) lines must be connected to a positive power supply voltage
through a pullup resistor or similar circuit. Every device connected to the bus must have an open-drain or
open-collector output for both the SCL and SDA lines, so that both are pulled high when the bus is free.
The maximum number of devices on the bus is limited only by the requirement that the rise and fall times
on the bus will not exceed 300 ns and 1000 ns, respectively.
SDA
SCL
A typical SMBus transaction consists of a START condition followed by an address byte (Bits7–1: 7-bit
slave address; Bit0: R/W direction bit), one or more bytes of data, and a STOP condition. Each byte that is
received (by a master or slave) must be acknowledged (ACK) with a low SDA during a high SCL (see
Figure 19.3). If the receiving device does not ACK, the transmitting device will read a “not acknowledge”
(NACK), which is a high SDA during a high SCL.
The direction bit (R/W) occupies the least-significant bit position of the address. The direction bit is set to
logic 1 to indicate a "READ" operation and cleared to logic 0 to indicate a "WRITE" operation.
All transactions are initiated by a master, with one or more addressed slave devices as the target. The
master generates the START condition and then transmits the slave address and direction bit. If the trans-
action is a WRITE operation from the master to the slave, the master transmits the data a byte at a time
waiting for an ACK from the slave at the end of each byte. For READ operations, the slave transmits the
data waiting for an ACK from the master at the end of each byte. At the end of the data transfer, the master
generates a STOP condition to terminate the transaction and free the bus. Figure 19.3 illustrates a typical
SMBus transaction.
SCL
SDA
SLA6 SLA5-0 R/W D7 D6-0
19.2.1. Arbitration
A master may start a transfer only if the bus is free. The bus is free after a STOP condition or after the SCL
and SDA lines remain high for a specified time (see Section 19.2.4). In the event that two or more devices
attempt to begin a transfer at the same time, an arbitration scheme is employed to force one master to give
up the bus. The master devices continue transmitting until one attempts a HIGH while the other transmits a
LOW. Since the bus is open-drain, the bus will be pulled LOW. The master attempting the HIGH will detect
a LOW SDA and give up the bus. The winning master continues its transmission without interruption; the
losing master becomes a slave and receives the rest of the transfer. This arbitration scheme is non-
destructive: one device always wins, and no data is lost.
Interrupt
Interrupt
Setting the ENSMB flag to logic 1 enables the SMBus0 interface. Clearing the ENSMB flag to logic 0 dis-
ables the SMBus0 interface and removes it from the bus. Momentarily clearing the ENSMB flag and then
resetting it to logic 1 will reset SMBus0 communication. However, ENSMB should not be used to tempo-
rarily remove a device from the bus since the bus state information will be lost. Instead, the Assert
Acknowledge (AA) flag should be used to temporarily remove the device from the bus (see description of
AA flag below).
Setting the Start flag (STA, SMB0CN.5) to logic 1 will put SMBus0 in a master mode. If the bus is free,
SMBus0 will generate a START condition. If the bus is not free, SMBus0 waits for a STOP condition to free
the bus and then generates a START condition after a 5 µs delay per the SMB0CR value (In accordance
with the SMBus protocol, the SMBus0 interface also considers the bus free if the bus is idle for 50 µs and
no STOP condition was recognized). If STA is set to logic 1 while SMBus0 is in master mode and one or
more bytes have been transferred, a repeated START condition will be generated.
When the Stop flag (STO, SMB0CN.4) is set to logic 1 while the SMBus0 interface is in master mode, the
interface generates a STOP condition. In a slave mode, the STO flag may be used to recover from an error
condition. In this case, a STOP condition is not generated on the bus, but the SMBus hardware behaves
as if a STOP condition has been received and enters the "not addressed" slave receiver mode. Note that
this simulated STOP will not cause the bus to appear free to SMBus0. The bus will remain occupied until a
STOP appears on the bus or a Bus Free Timeout occurs. Hardware automatically clears the STO flag to
logic 0 when a STOP condition is detected on the bus.
The Serial Interrupt flag (SI, SMB0CN.3) is set to logic 1 by hardware when the SMBus0 interface enters
one of 27 possible states. If interrupts are enabled for the SMBus0 interface, an interrupt request is gener-
ated when the SI flag is set. The SI flag must be cleared by software.
Important Note: If SI is set to logic 1 while the SCL line is low, the clock-low period of the serial clock will
be stretched and the serial transfer is suspended until SI is cleared to logic 0. A high level on SCL is not
affected by the setting of the SI flag.
The Assert Acknowledge flag (AA, SMB0CN.2) is used to set the level of the SDA line during the acknowl-
edge clock cycle on the SCL line. Setting the AA flag to logic 1 will cause an ACK (low level on SDA) to be
sent during the acknowledge cycle if the device has been addressed. Setting the AA flag to logic 0 will
cause a NACK (high level on SDA) to be sent during acknowledge cycle. After the transmission of a byte in
slave mode, the slave can be temporarily removed from the bus by clearing the AA flag. The slave's own
address and general call address will be ignored. To resume operation on the bus, the AA flag must be
reset to logic 1 to allow the slave's address to be recognized.
Setting the SMBus0 Free Timer Enable bit (FTE, SMB0CN.1) to logic 1 enables the timer in SMB0CR.
When SCL goes high, the timer in SMB0CR counts up. A timer overflow indicates a free bus timeout: if
SMBus0 is waiting to generate a START, it will do so after this timeout. The bus free period should be less
than 50 µs (see SFR Definition 19.2, SMBus0 Clock Rate Register).
When the TOE bit in SMB0CN is set to logic 1, Timer 3 is used to detect SCL low timeouts. If Timer 3 is
enabled (see Section “23.2. Timer 2, Timer 3, and Timer 4” on page 317), Timer 3 is forced to reload
when SCL is high, and forced to count when SCL is low. With Timer 3 enabled and configured to overflow
after 25 ms (and TOE set), a Timer 3 overflow indicates a SCL low timeout; the Timer 3 interrupt service
routine can then be used to reset SMBus0 communication in the event of an SCL low timeout.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xCF
SFR Page: 0
The SMB0CR setting should be bounded by the following equation , where SMB0CR is the
unsigned 8-bit value in register SMB0CR, and SYSCLK is the system clock frequency in
MHz:
Using the same value of SMB0CR from above, the Bus Free Timeout period is given in the
following equation:
4 × ( 256 – SMB0CR ) + 1
T BFT ≅ 10 × --------------------------------------------------------------
SYSCLK
Data in SMB0DAT is always shifted out MSB first. After a byte has been received, the first bit of received
data is located at the MSB of SMB0DAT. While data is being shifted out, data on the bus is simultaneously
being shifted in. Therefore, SMB0DAT always contains the last data byte present on the bus. In the event
of lost arbitration, the transition from master transmitter to slave receiver is made with the correct data in
SMB0DAT.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xC2
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
SLV6 SLV5 SLV4 SLV3 SLV2 SLV1 SLV0 GC 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xC3
SFR Page: 0
For the purposes of user software, the contents of the SMB0STA register is only defined when the SI flag is
logic 1. Software should never write to the SMB0STA register; doing so will yield indeterminate results. The
28 SMBus0 states, along with their corresponding status codes, are given in Table 1.1.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
STA7 STA6 STA5 STA4 STA3 STA2 STA1 STA0 11111000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xC1
SFR Page: 0
Bits2–0: STA2–STA0: The three least significant bits of SMB0STA are always read as logic 0 when
the SI flag is logic 1.
Status
Mode SMBus State Typical Action
Code
0x08 START condition transmitted. Load SMB0DAT with Slave Address +
R/W. Clear STA.
MT/
MR
0x10 Repeated START condition transmitted. Load SMB0DAT with Slave Address +
R/W. Clear STA.
0x18 Slave Address + W transmitted. ACK Load SMB0DAT with data to be transmit-
received. ted.
Master Transmitter
0x20 Slave Address + W transmitted. NACK Acknowledge poll to retry. Set STO +
received. STA.
0x40 Slave Address + R transmitted. ACK received. If only receiving one byte, clear AA (send
Master Receiver
0x48 Slave Address + R transmitted. NACK Acknowledge poll to retry. Set STO +
received. STA.
0x50 Data byte received. ACK transmitted. Read SMB0DAT. Wait for next byte. If
next byte is last byte, clear AA.
Status
Mode SMBus State Typical Action
Code
0x60 Own slave address + W received. ACK trans- Wait for data.
mitted.
0x68 Arbitration lost in sending SLA + R/W as mas- Save current data for retry when bus is
ter. Own address + W received. ACK transmit- free. Wait for data.
ted.
0x70 General call address received. ACK transmit- Wait for data.
ted.
Slave Receiver
0x78 Arbitration lost in sending SLA + R/W as mas- Save current data for retry when bus is
ter. General call address received. ACK trans- free.
mitted.
0x80 Data byte received. ACK transmitted. Read SMB0DAT. Wait for next byte or
STOP.
0x88 Data byte received. NACK transmitted. Set STO to reset SMBus.
0x90 Data byte received after general call address. Read SMB0DAT. Wait for next byte or
ACK transmitted. STOP.
0x98 Data byte received after general call address. Set STO to reset SMBus.
NACK transmitted.
0xA8 Own address + R received. ACK transmitted. Load SMB0DAT with data to transmit.
Slave Transmitter
0xB0 Arbitration lost in transmitting SLA + R/W as Save current data for retry when bus is
master. Own address + R received. ACK free. Load SMB0DAT with data to trans-
transmitted. mit.
0xB8 Data byte transmitted. ACK received. Load SMB0DAT with data to transmit.
0xC8 Last data byte transmitted (AA=0). ACK Set STO to reset SMBus.
received.
Slave
0xD0 SCL Clock High Timer per SMB0CR timed out Set STO to reset SMBus.
0x00 Bus Error (illegal START or STOP) Set STO to reset SMBus.
All
NOTES:
SFR Bus
RXOVRN
NSSMD1
NSSMD0
SLVSEL
SPIBSY
CKPHA
MSTEN
RXBMT
CKPOL
TXBMT
NSSIN
WCOL
SPIEN
MODF
SRMT
SCR7
SCR6
SCR5
SCR4
SCR3
SCR2
SCR1
SCR0
SPIF
Clock Divide
SYSCLK
Logic
Tx Data MOSI
C
SPI0DAT R
SCK
Transmit Data Buffer O
Pin
S
Control Port I/O
Shift Register Logic S
Rx Data MISO
7 6 5 4 3 2 1 0 B
A
R
Receive Data Buffer NSS
Write Read
SPI0DAT SPI0DAT
SFR Bus
Figure 20.1. SPI Block Diagram
1. NSSMD[1:0] = 00: 3-Wire Master or 3-Wire Slave Mode: SPI0 operates in 3-wire mode, and
NSS is disabled. When operating as a slave device, SPI0 is always selected in 3-wire mode.
Since no select signal is present, SPI0 must be the only slave on the bus in 3-wire mode. This
is intended for point-to-point communication between a master and one slave.
2. NSSMD[1:0] = 01: 4-Wire Slave or Multi-Master Mode: SPI0 operates in 4-wire mode, and
NSS is enabled as an input. When operating as a slave, NSS selects the SPI0 device. When
operating as a master, a 1-to-0 transition of the NSS signal disables the master function of
SPI0 so that multiple master devices can be used on the same SPI bus.
3. NSSMD[1:0] = 1x: 4-Wire Master Mode: SPI0 operates in 4-wire mode, and NSS is enabled as
an output. The setting of NSSMD0 determines what logic level the NSS pin will output. This
configuration should only be used when operating SPI0 as a master device.
See Figure 20.2, Figure 20.3, and Figure 20.4 for typical connection diagrams of the various operational
modes. Note that the setting of NSSMD bits affects the pinout of the device. When in 3-wire master or
3-wire slave mode, the NSS pin will not be mapped by the crossbar. In all other modes, the NSS signal will
be mapped to a pin on the device. See Section “18. Port Input/Output” on page 235 for general purpose
port I/O and crossbar information.
When configured as a master, SPI0 can operate in one of three different modes: multi-master mode, 3-wire
single-master mode, and 4-wire single-master mode. The default, multi-master mode is active when NSS-
MD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 1. In this mode, NSS is an input to the device, and is
used to disable the master SPI0 when another master is accessing the bus. When NSS is pulled low in this
mode, MSTEN (SPI0CN.6) and SPIEN (SPI0CN.0) are set to 0 to disable the SPI master device, and a
Mode Fault is generated (MODF, SPI0CN.5 = 1). Mode Fault will generate an interrupt if enabled. SPI0
must be manually re-enabled in software under these circumstances. In multi-master systems, devices will
typically default to being slave devices while they are not acting as the system master device. In multi-mas-
ter mode, slave devices can be addressed individually (if needed) using general-purpose I/O pins.
Figure 20.2 shows a connection diagram between two master devices in multiple-master mode.
3-wire single-master mode is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 0. In this
mode, NSS is not used, and is not mapped to an external port pin through the crossbar. Any slave devices
that must be addressed in this mode should be selected using general-purpose I/O pins. Figure 20.3
shows a connection diagram between a master device in 3-wire master mode and a slave device.
4-wire single-master mode is active when NSSMD1 (SPI0CN.3) = 1. In this mode, NSS is configured as an
output pin, and can be used as a slave-select signal for a single SPI device. In this mode, the output value
of NSS is controlled (in software) with the bit NSSMD0 (SPI0CN.2). Additional slave devices can be
addressed using general-purpose I/O pins. Figure 20.4 shows a connection diagram for a master device in
4-wire master mode and two slave devices.
NSS GPIO
MISO MISO
Master MOSI MOSI
Master
Device 1 SCK SCK
Device 2
GPIO NSS
Master Slave
Device MISO MISO Device
MOSI MOSI
SCK SCK
Figure 20.3. 3-Wire Single Master and Slave Mode Connection Diagram
MISO Slave
MOSI Device
SCK
NSS
Figure 20.4. 4-Wire Single Master and Slave Mode Connection Diagram
When configured as a slave, SPI0 can be configured for 4-wire or 3-wire operation. The default, 4-wire
slave mode, is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 1. In 4-wire mode, the
NSS signal is routed to a port pin and configured as a digital input. SPI0 is enabled when NSS is logic 0,
and disabled when NSS is logic 1. The bit counter is reset on a falling edge of NSS. Note that the NSS sig-
nal must be driven low at least 2 system clocks before the first active edge of SCK for each byte transfer.
Figure 20.4 shows a connection diagram between two slave devices in 4-wire slave mode and a master
device.
3-wire slave mode is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 0. NSS is not
used in this mode, and is not mapped to an external port pin through the crossbar. Since there is no way of
uniquely addressing the device in 3-wire slave mode, SPI0 must be the only slave device present on the
bus. It is important to note that in 3-wire slave mode there is no external means of resetting the bit counter
that determines when a full byte has been received. The bit counter can only be reset by disabling and re-
enabling SPI0 with the SPIEN bit. Figure 20.3 shows a connection diagram between a slave device in 3-
wire slave mode and a master device.
1. The SPI Interrupt Flag, SPIF (SPI0CN.7) is set to logic 1 at the end of each byte transfer. This
flag can occur in all SPI0 modes.
2. The Write Collision Flag, WCOL (SPI0CN.6) is set to logic 1 if a write to SPI0DAT is attempted
when the transmit buffer has not been emptied to the SPI shift register. When this occurs, the
write to SPI0DAT will be ignored, and the transmit buffer will not be written.This flag can occur
in all SPI0 modes.
3. The Mode Fault Flag MODF (SPI0CN.5) is set to logic 1 when SPI0 is configured as a master,
and for multi-master mode and the NSS pin is pulled low. When a Mode Fault occurs, the
MSTEN and SPIEN bits in SPI0CN are set to logic 0 to disable SPI0 and allow another master
device to access the bus.
4. The Receive Overrun Flag RXOVRN (SPI0CN.4) is set to logic 1 when configured as a slave,
and a transfer is completed and the receive buffer still holds an unread byte from a previous
transfer. The new byte is not transferred to the receive buffer, allowing the previously received
data byte to be read. The data byte which caused the overrun is lost.
The SPI0 Clock Rate Register (SPI0CKR) as shown in SFR Definition 20.3 controls the master mode
serial clock frequency. This register is ignored when operating in slave mode. When the SPI is configured
as a master, the maximum data transfer rate (bits/sec) is one-half the system clock frequency or 12.5 MHz,
whichever is slower. When the SPI is configured as a slave, the maximum data transfer rate (bits/sec) for
full-duplex operation is 1/10 the system clock frequency, provided that the master issues SCK, NSS (in 4-
wire slave mode), and the serial input data synchronously with the slave’s system clock. If the master
issues SCK, NSS, and the serial input data asynchronously, the maximum data transfer rate (bits/sec)
must be less than 1/10 the system clock frequency. In the special case where the master only wants to
transmit data to the slave and does not need to receive data from the slave (i.e. half-duplex operation), the
SPI slave can receive data at a maximum data transfer rate (bits/sec) of 1/4 the system clock frequency.
This is provided that the master issues SCK, NSS, and the serial input data synchronously with the slave’s
system clock.
SCK
(CKPOL=0, CKPHA=0)
SCK
(CKPOL=0, CKPHA=1)
SCK
(CKPOL=1, CKPHA=0)
SCK
(CKPOL=1, CKPHA=1)
SCK
(CKPOL=0, CKPHA=0)
SCK
(CKPOL=1, CKPHA=0)
SCK
(CKPOL=0, CKPHA=1)
SCK
(CKPOL=1, CKPHA=1)
*Note: In slave mode, data on MOSI is sampled in the center of each data bit. In master mode, data
on MISO is sampled one SYSCLK before the end of each data bit, to provide maximum
settling time for the slave device. See Table 20.1 for timing parameters.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
SCR7 SCR6 SCR5 SCR4 SCR3 SCR2 SCR1 SCR0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9D
SFR Page: 0
SYSCLK
f SCK = -----------------------------------------------
2 × ( SPI0CKR + 1 )
2000000
f SCK = --------------------------
2 × (4 + 1)
f SCK = 200kHz
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x9B
SFR Page: 0
SCK*
T T
MCKH MCKL
T T
MIS MIH
MISO
MOSI
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
SCK*
T T
MCKH MCKL
T T
MIS MIH
MISO
MOSI
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
NSS
T T T
SE CKL SD
SCK*
T
CKH
T T
SIS SIH
MOSI
T T T
SEZ SOH SDZ
MISO
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
NSS
T T T
SE CKL SD
SCK*
T
CKH
T T
SIS SIH
MOSI
T T T T
SEZ SOH SLH SDZ
MISO
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
NOTES:
21. UART0
UART0 is an enhanced serial port with frame error detection and address recognition hardware. UART0
may operate in full-duplex asynchronous or half-duplex synchronous modes, and mutiproccessor commu-
nication is fully supported. Receive data is buffered in a holding register, allowing UART0 to start reception
of a second incoming data byte before software has finished reading the previous data byte. A Receive
Overrun bit indicates when new received data is latched into the receive buffer before the previously
received byte has been read.
UART0 is accessed via its associated SFR’s, Serial Control (SCON0) and Serial Data Buffer (SBUF0). The
single SBUF0 location provides access to both transmit and receive registers. Reading SCON0 accesses
the Receive register and writing SCON0 accesses the Transmit register.
UART0 may be operated in polled or interrupt mode. UART0 has two sources of interrupts: a Transmit
Interrupt flag, TI0 (SCON0.1) set when transmission of a data byte is complete, and a Receive Interrupt
flag, RI0 (SCON0.0) set when reception of a data byte is complete. UART0 interrupt flags are not cleared
by hardware when the CPU vectors to the interrupt service routine; they must be cleared manually by soft-
ware. This allows software to determine the cause of the UART0 interrupt (transmit complete or receive
complete).
SFR Bus
Write to
SBUF0
TB80
SET
D Q SBUF0 TX0
SSTA0
CLR
Crossbar
F R T S S S S S
E X X M 0 0 0 0
0 O C O T T R R
Zero Detector
V O D C C C C
0 L 0 L L L L
0 K K K K
1 1 1 1 Stop Bit Shift
Data
Gen.
Start Tx Control
Tx Clock Send
Tx IRQ
SCON0 TI0
UART0 S S S R T R T R Serial Port
Baud Rate Generation M M M E B B I I (UART0) Interrupt
Logic 0 1 2 N 8 8 0 0
0 0 0 0 0 0 RI0
EN Rx IRQ
Rx Clock Load
SBUF
Rx Control
Address
Match
Start
Shift 0x1FF Port I/O
Load
SBUF0 RB80
SADDR0
SBUF0 Match Detect
SADEN0
Read
SBUF0
SFR Bus
RX0
Crossbar
Data transmission begins when an instruction writes a data byte to the SBUF0 register. Eight data bits are
transferred LSB first (see the timing diagram in Figure 21.2), and the TI0 Transmit Interrupt Flag
(SCON0.1) is set at the end of the eighth bit time. Data reception begins when the REN0 Receive Enable
bit (SCON0.4) is set to logic 1 and the RI0 Receive Interrupt Flag (SCON0.0) is cleared. One cycle after
the eighth bit is shifted in, the RI0 flag is set and reception stops until software clears the RI0 bit. An inter-
rupt will occur if enabled when either TI0 or RI0 are set.
The Mode 0 baud rate is SYSCLK / 12. RX0 is forced to open-drain in Mode 0, and an external pullup will
typically be required.
MODE 0 TRANSMIT
RX (data out) D0 D1 D2 D3 D4 D5 D6 D7
TX (clk out)
MODE 0 RECEIVE
RX (data in) D0 D1 D2 D3 D4 D5 D6 D7
TX (clk out)
TX CLK
Shift
C8051Fxxx
RX DATA Reg.
8 Extra Outputs
Figure 21.3. UART0 Mode 0 Interconnect
Data transmission begins when an instruction writes a data byte to the SBUF0 register. The TI0 Transmit
Interrupt Flag (SCON0.1) is set at the end of the transmission (the beginning of the stop-bit time). Data
reception can begin any time after the REN0 Receive Enable bit (SCON0.4) is set to logic 1. After the stop
bit is received, the data byte will be loaded into the SBUF0 receive register if the following conditions are
met: RI0 must be logic 0, and if SM20 is logic 1, the stop bit must be logic 1.
If these conditions are met, the eight bits of data is stored in SBUF0, the stop bit is stored in RB80 and the
RI0 flag is set. If these conditions are not met, SBUF0 and RB80 will not be loaded and the RI0 flag will not
be set. An interrupt will occur if enabled when either TI0 or RI0 are set.
MARK START
BIT D0 D1 D2 D3 D4 D5 D6 D7 STOP
SPACE BIT
BIT TIMES
BIT SAMPLING
The baud rate generated in Mode 1 is a function of timer overflow. UART0 can use Timer 1 operating in 8-
Bit Auto-Reload Mode, or Timer 2, 3, or 4 operating in Auto-reload Mode to generate the baud rate (note
that the TX and RX clocks are selected separately). On each timer overflow event (a rollover from all ones
- (0xFF for Timer 1, 0xFFFF for Timer 2, 3, or 4) - to zero) a clock is sent to the baud rate logic.
Timers 1, 2, 3, or 4 are selected as the baud rate source with bits in the SSTA0 register (see SFR Defini-
tion 21.2). The transmit baud rate clock is selected using the S0TCLK1 and S0TCLK0 bits, and the receive
baud rate clock is selected using the S0RCLK1 and S0RCLK0 bits.
When Timer 1 is selected as a baud rate source, the SMOD0 bit (SSTA0.4) selects whether or not to divide
the Timer 1 overflow rate by two. On reset, the SMOD0 bit is logic 0, thus selecting the lower speed baud
rate by default. The SMOD0 bit affects the baud rate generated by Timer 1 as shown in Equation 21.1.
The Mode 1 baud rate equations are shown below, where T1M is bit4 of register CKCON, TH1 is the 8-bit
reload register for Timer 1, and [RCAPnH , RCAPnL] is the 16-bit reload register for Timer 2, 3, or 4.
Equation 21.1. Mode 1 Baud Rate using Timer 1
When SMOD0 = 0:
Mode1_BaudRate = 1 ⁄ 32 ⋅ Timer1_OverflowRate
When SMOD0 = 1:
Mode1_BaudRate = 1 ⁄ 16 ⋅ Timer1_OverflowRate
The Timer 1 overflow rate is determined by the Timer 1 clock source (T1CLK) and reload value (TH1). The
frequency of T1CLK is selected as described in Section “23.1. Timer 0 and Timer 1” on page 309. The
Timer 1 overflow rate is calculated as shown in Equation 21.2.
When Timers 2, 3, or 4 are selected as a baud rate source, the baud rate is generated as shown in
Equation 21.3.
Mode1_BaudRate = 1 ⁄ 16 ⋅ Timer234_OverflowRate
The overflow rate for Timer 2, 3, or 4 is determined by the clock source for the timer (TnCLK) and the 16-
bit reload value stored in the RCAPn register (n = 2, 3, or 4), as shown in Equation 21.4.
Data transmission begins when an instruction writes a data byte to the SBUF0 register. The TI0 Transmit
Interrupt Flag (SCON0.1) is set at the end of the transmission (the beginning of the stop-bit time). Data
reception can begin any time after the REN0 Receive Enable bit (SCON0.4) is set to logic 1. After the stop
bit is received, the data byte will be loaded into the SBUF0 receive register if RI0 is logic 0 and one of the
following requirements are met:
1. SM20 is logic 0
2. SM20 is logic 1, the received 9th bit is logic 1, and the received address matches the UART0
address as described in Section 21.2.
If the above conditions are satisfied, the eight bits of data are stored in SBUF0, the ninth bit is stored in
RB80 and the RI0 flag is set. If these conditions are not met, SBUF0 and RB80 will not be loaded and the
RI0 flag will not be set. An interrupt will occur if enabled when either TI0 or RI0 are set.
The baud rate in Mode 2 is either SYSCLK / 32 or SYSCLK / 64, according to the value of the SMOD0 bit
in register SSTA0.
MARK START
BIT D0 D1 D2 D3 D4 D5 D6 D7 D8 STOP
SPACE BIT
BIT TIMES
BIT SAMPLING
TX
RS-232 RS-232
LEVEL RX C8051Fxxx
XLTR
OR
TX TX
MCU C8051Fxxx
RX RX
Setting the SM20 bit (SCON0.5) configures UART0 such that when a stop bit is received, UART0 will gen-
erate an interrupt only if the ninth bit is logic 1 (RB80 = ‘1’) and the received data byte matches the UART0
slave address. Following the received address interrupt, the slave will clear its SM20 bit to enable interrupts
on the reception of the following data byte(s). Once the entire message is received, the addressed slave
resets its SM20 bit to ignore all transmissions until it receives the next address byte. While SM20 is logic 1,
UART0 ignores all bytes that do not match the UART0 address and include a ninth bit that is logic 1.
Note in the above examples 4, 5, and 6, each slave would recognize as “valid” an address of 0xFF as a
broadcast address. Also note that examples 4, 5, and 6 uses the same SADDR0 and SADEN0 register
values as shown in the examples 1, 2, and 3 respectively (slaves #1, 2, and 3). Thus, a master could
address each slave device individually using a masked address, and also broadcast to all three slave
devices. For example, if a Master were to send an address “11110101”, only slave #1 would recognize the
address as valid. If a master were to then send an address of “11111111”, all three slave devices would rec-
ognize the address as a valid broadcast address.
Modes 1, 2, and 3:
The Receive Overrun bit (RXOV0 in register SSTA0) reads ‘1’ if a new data byte is latched into the receive
buffer before software has read the previous byte. The Frame Error bit (FE0 in register SSTA0) reads ‘1’ if
an invalid (low) STOP bit is detected.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
SM00 SM10 SM20 REN0 TB80 RB80 TI0 RI0 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0x98
SFR Page: 0
Reading these bits returns the current UART0 mode as defined above.
Bit5: SM20: Multiprocessor Communication Enable.
The function of this bit is dependent on the Serial Port Operation Mode.
Mode 0: No effect
Mode 1: Checks for valid stop bit.
0: Logic level of stop bit is ignored.
1: RI0 will only be activated if stop bit is logic level 1.
Mode 2 and 3: Multiprocessor Communications Enable.
0: Logic level of ninth bit is ignored.
1: RI0 is set and an interrupt is generated only when the ninth bit is logic 1 and the
received address matches the UART0 address or the broadcast address.
Bit4: REN0: Receive Enable.
This bit enables/disables the UART0 receiver.
0: UART0 reception disabled.
1: UART0 reception enabled.
Bit3: TB80: Ninth Transmission Bit.
The logic level of this bit will be assigned to the ninth transmission bit in Modes 2 and 3. It is
not used in Modes 0 and 1. Set or cleared by software as required.
Bit2: RB80: Ninth Receive Bit.
The bit is assigned the logic level of the ninth bit received in Modes 2 and 3. In Mode 1, if
SM20 is logic 0, RB80 is assigned the logic level of the received stop bit. RB8 is not used in
Mode 0.
Bit1: TI0: Transmit Interrupt Flag.
Set by hardware when a byte of data has been transmitted by UART0 (after the 8th bit in
Mode 0, or at the beginning of the stop bit in other modes). When the UART0 interrupt is
enabled, setting this bit causes the CPU to vector to the UART0 interrupt service routine.
This bit must be cleared manually by software
Bit0: RI0: Receive Interrupt Flag.
Set by hardware when a byte of data has been received by UART0 (as selected by the
SM20 bit). When the UART0 interrupt is enabled, setting this bit causes the CPU to vector
to the UART0 interrupt service routine. This bit must be cleared manually by software.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
FE0 RXOV0 TXCOL0 SMOD0 S0TCLK1 S0TCLK0 S0RCLK1 S0RCLK0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x91
SFR Page: 0
*Note: FE0, RXOV0, and TXCOL0 are flags only, and no interrupt is generated by these conditions.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x99
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xA9
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xB9
SFR Page: 0
22. UART1
UART1 is an asynchronous, full duplex serial port offering modes 1 and 3 of the standard 8051 UART.
Enhanced baud rate support allows a wide range of clock sources to generate standard baud rates (details
in Section “22.1. Enhanced Baud Rate Generation” on page 300). Received data buffering allows
UART1 to start reception of a second incoming data byte before software has finished reading the previous
data byte.
UART1 has two associated SFRs: Serial Control Register 1 (SCON1) and Serial Data Buffer 1 (SBUF1).
The single SBUF1 location provides access to both transmit and receive registers. Reading SBUF1
accesses the buffered Receive register; writing SBUF1 accesses the Transmit register.
With UART1 interrupts enabled, an interrupt is generated each time a transmit is completed (TI1 is set in
SCON1), or a data byte has been received (RI1 is set in SCON1). The UART1 interrupt flags are not
cleared by hardware when the CPU vectors to the interrupt service routine. They must be cleared manually
by software, allowing software to determine the cause of the UART1 interrupt (transmit complete or receive
complete).
SFR Bus
Write to
SBUF1
TB81
SET
SBUF1
D Q (TX Shift)
TX1
CLR
Crossbar
Zero Detector
SCON1
TI1
UART1 Baud Serial
S1MODE
RB81
TB81
RI1
TI1
Interrupt
RI1
Rx IRQ
Rx Clock
Rx Control
Load
Start
Shift 0x1FF RB81 SBUF1
Load SBUF1
SBUF1
(RX Latch)
Read
SBUF1
Timer 1 UART1
Overflow
TL1 2 TX Clock
TH1
Start
Detected
Overflow
RX Timer 2 RX Clock
Timer 1 should be configured for Mode 2, 8-bit auto-reload (see Section “23.1.3. Mode 2: 8-bit Counter/
Timer with Auto-Reload” on page 311). The Timer 1 reload value should be set so that overflows will
occur at two times the desired baud rate. Note that Timer 1 may be clocked by one of five sources:
SYSCLK, SYSCLK / 4, SYSCLK / 12, SYSCLK / 48, or the external oscillator clock / 8. For any given
Timer 1 clock source, the UART1 baud rate is determined by Equation 22.1.
TX
RS-232 RS-232
LEVEL RX C8051Fxxx
XLTR
OR
TX TX
MCU C8051Fxxx
RX RX
Data transmission begins when software writes a data byte to the SBUF1 register. The TI1 Transmit Inter-
rupt Flag (SCON1.1) is set at the end of the transmission (the beginning of the stop-bit time). Data recep-
tion can begin any time after the REN1 Receive Enable bit (SCON1.4) is set to logic 1. After the stop bit is
received, the data byte will be loaded into the SBUF1 receive register if the following conditions are met:
RI1 must be logic 0, and if MCE1 is logic 1, the stop bit must be logic 1. In the event of a receive data over-
run, the first received 8 bits are latched into the SBUF1 receive register and the following overrun data bits
are lost.
If these conditions are met, the eight bits of data is stored in SBUF1, the stop bit is stored in RB81 and the
RI1 flag is set. If these conditions are not met, SBUF1 and RB81 will not be loaded and the RI1 flag will not
be set. An interrupt will occur if enabled when either TI1 or RI1 is set.
MARK START
BIT D0 D1 D2 D3 D4 D5 D6 D7 STOP
SPACE BIT
BIT TIMES
BIT SAMPLING
Data transmission begins when an instruction writes a data byte to the SBUF1 register. The TI1 Transmit
Interrupt Flag (SCON1.1) is set at the end of the transmission (the beginning of the stop-bit time). Data
reception can begin any time after the REN1 Receive Enable bit (SCON1.4) is set to ‘1’. After the stop bit
is received, the data byte will be loaded into the SBUF1 receive register if the following conditions are met:
(1) RI1 must be logic 0, and (2) if MCE1 is logic 1, the 9th bit must be logic 1 (when MCE1 is logic 0, the
state of the ninth data bit is unimportant). If these conditions are met, the eight bits of data are stored in
SBUF1, the ninth bit is stored in RB81, and the RI1 flag is set to ‘1’. If the above conditions are not met,
SBUF1 and RB81 will not be loaded and the RI1 flag will not be set to ‘1’. A UART1 interrupt will occur if
enabled when either TI1 or RI1 is set to ‘1’.
MARK START
BIT D0 D1 D2 D3 D4 D5 D6 D7 D8 STOP
SPACE BIT
BIT TIMES
BIT SAMPLING
Setting the MCE1 bit (SCON.5) of a slave processor configures its UART such that when a stop bit is
received, the UART will generate an interrupt only if the ninth bit is logic one (RB81 = 1) signifying an
address byte has been received. In the UART interrupt handler, software should compare the received
address with the slave's own assigned 8-bit address. If the addresses match, the slave should clear its
MCE1 bit to enable interrupts on the reception of the following data byte(s). Slaves that weren't addressed
leave their MCE1 bits set and do not generate interrupts on the reception of the following data bytes,
thereby ignoring the data. Once the entire message is received, the addressed slave should reset its
MCE1 bit to ignore all transmissions until it receives the next address byte.
Multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple
slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. The master
processor can be configured to receive all transmissions or a protocol can be implemented such that the
master/slave role is temporarily reversed to enable half-duplex transmission between the original master
and slave(s).
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
S1MODE - MCE1 REN1 TB81 RB81 TI1 RI1 01000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0x98
SFR Page: 1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x99
SFR Page: 1
Table 22.1. Timer Settings for Standard Baud Rates Using The Internal 24.5 MHz
Oscillator
Frequency: 24.5 MHz
Target Baud Rate Oscilla- Timer Clock SCA1-SCA0 T1M* Timer 1
Baud Rate % Error tor Divide Source (pre-scale Reload
(bps) Factor select)* Value (hex)
230400 -0.32% 106 SYSCLK XX 1 0xCB
115200 -0.32% 212 SYSCLK XX 1 0x96
57600 0.15% 426 SYSCLK XX 1 0x2B
SYSCLK from
Table 22.2. Timer Settings for Standard Baud Rates Using an External 25.0 MHz
Oscillator
Frequency: 25.0 MHz
Target Baud Rate Oscilla- Timer Clock SCA1-SCA0 T1M* Timer 1
Baud Rate % Error tor Divide Source (pre-scale Reload
(bps) Factor select)* Value (hex)
230400 -0.47% 108 SYSCLK XX 1 0xCA
115200 0.45% 218 SYSCLK XX 1 0x93
57600 -0.01% 434 SYSCLK XX 1 0x27
SYSCLK from SYSCLK from
X = Don’t care
*Note: SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
Table 22.3. Timer Settings for Standard Baud Rates Using an External 22.1184 MHz
Oscillator
Frequency: 22.1184 MHz
Target Baud Rate Oscilla- Timer Clock SCA1-SCA0 T1M* Timer 1
Baud Rate % Error tor Divide Source (pre-scale Reload
(bps) Factor select)* Value (hex)
230400 0.00% 96 SYSCLK XX 1 0xD0
115200 0.00% 192 SYSCLK XX 1 0xA0
57600 0.00% 384 SYSCLK XX 1 0x40
SYSCLK from
Table 22.4. Timer Settings for Standard Baud Rates Using the PLL
Frequency: 50.0 MHz
Target Baud Rate Oscilla- Timer Clock SCA1-SCA0 T1M* Timer 1
Baud Rate % Error tor Divide Source (pre-scale Reload
(bps) Factor select)* Value (hex)
230400 0.45% 218 SYSCLK XX 1 0x93
115200 -0.01% 434 SYSCLK XX 1 0x27
57600 0.45% 872 SYSCLK / 4 01 0 0x93
28800 -0.01% 1736 SYSCLK / 4 01 0 0x27
14400 0.22% 3480 SYSCLK / 12 00 0 0x6F
9600 -0.01% 5208 SYSCLK / 12 00 0 0x27
2400 -0.01% 20832 SYSCLK / 48 10 0 0x27
X = Don’t care
*Note: SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
Table 22.5. Timer Settings for Standard Baud Rates Using the PLL
Frequency: 100.0 MHz
Target Baud Rate Oscilla- Timer Clock SCA1-SCA0 T1M* Timer 1
Baud Rate % Error tor Divide Source (pre-scale Reload
(bps) Factor select)* Value (hex)
230400 -0.01% 434 SYSCLK XX 1 0x27
115200 0.45% 872 SYSCLK / 4 01 0 0x93
57600 -0.01% 1736 SYSCLK / 4 01 0 0x27
28800 0.22% 3480 SYSCLK / 12 00 0 0x6F
14400 -0.47% 6912 SYSCLK / 48 10 0 0xB8
9600 0.45% 10464 SYSCLK / 48 10 0 0x93
X = Don’t care
*Note: SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
NOTES:
23. Timers
Each MCU includes 5 counter/timers: Timer 0 and Timer 1 are 16-bit counter/timers compatible with those
found in the standard 8051. Timer 2, Timer 3, and Timer 4 are 16-bit auto-reload and capture counter/tim-
ers for use with the ADCs, DACs, square-wave generation, or for general-purpose use. These timers can
be used to measure time intervals, count external events and generate periodic interrupt requests. Timer 0
and Timer 1 are nearly identical and have four primary modes of operation. Timer 3 offers 16-bit auto-
reload and capture. Timers 2 and 4 are identical, and offer not only 16-bit auto-reload and capture, but
have the ability to produce a 50% duty-cycle square-wave (toggle output) at an external port pin.
Timers 0 and 1 may be clocked by one of five sources, determined by the Timer Mode Select bits (T1M-
T0M) and the Clock Scale bits (SCA1-SCA0). The Clock Scale bits define a pre-scaled clock by which
Timer 0 and/or Timer 1 may be clocked (See SFR Definition 23.3 for pre-scaled clock selection). Timers 0
and 1 can be configured to use either the pre-scaled clock signal or the system clock directly. Timers 2, 3,
and 4 may be clocked by the system clock, the system clock divided by 12, or the external oscillator clock
source divided by 8.
Timer 0 and Timer 1 may also be operated as counters. When functioning as a counter, a counter/timer
register is incremented on each high-to-low transition at the selected input pin. Events with a frequency of
up to one-fourth the system clock's frequency can be counted. The input signal need not be periodic, but it
should be held at a given logic level for at least two full system clock cycles to ensure the level is properly
sampled.
The TH0 register holds the eight MSBs of the 13-bit counter/timer. TL0 holds the five LSBs in bit positions
TL0.4–TL0.0. The three upper bits of TL0 (TL0.7–TL0.5) are indeterminate and should be masked out or
ignored when reading the TL0 register. As the 13-bit timer register increments and overflows from 0x1FFF
(all ones) to 0x0000, the timer overflow flag TF0 (TCON.5) is set and an interrupt will occur if Timer 0 inter-
rupts are enabled.
The C/T0 bit (TMOD.2) selects the counter/timer's clock source. When C/T0 is set to logic 1, high-to-low
transitions at the selected Timer 0 input pin (T0) increment the timer register (Refer to Section
“18.1. Ports 0 through 3 and the Priority Crossbar Decoder” on page 238 for information on selecting
and configuring external I/O pins). Clearing C/T selects the clock defined by the T0M bit (CKCON.3). When
T0M is set, Timer 0 is clocked by the system clock. When T0M is cleared, Timer 0 is clocked by the source
selected by the Clock Scale bits in CKCON (see SFR Definition 23.3).
Setting the TR0 bit (TCON.4) enables the timer when either GATE0 (TMOD.3) is logic 0 or the input signal
/INT0 is logic-level 1. Setting GATE0 to ‘1’ allows the timer to be controlled by the external input signal /
INT0 (see Section “11.3.5. Interrupt Register Descriptions” on page 157), facilitating pulse width mea-
surements.
Setting TR0 does not force the timer to reset. The timer registers should be loaded with the desired initial
value before the timer is enabled.
TL1 and TH1 form the 13-bit register for Timer 1 in the same manner as described above for TL0 and TH0.
Timer 1 is configured and controlled using the relevant TCON and TMOD bits just as with Timer 0. The
input signal /INT1 is used with Timer 1.
CKCON TMOD
TT SS G CT TG C T T
1 0 CC A / 1 1 A / 0 0
MM AA T T MM T T MM
E 1 1 0 E 0 1 0
1 0
1 0
Pre-scaled Clock 0
SYSCLK 1
1
TF1
T0 TR1
TCLK TL0 TH0 TF0 Interrupt
TR0 TR0
(5 bits) (8 bits) IE1
TCON
GATE0 IT1
Crossbar IE0
IT0
/INT0
Both counter/timers are enabled and configured in Mode 2 in the same manner as Mode 0. Setting the
TR0 bit (TCON.4) enables the timer when either GATE0 (TMOD.3) is logic 0 or when the input signal /INT0
is low
CKCON TMOD
TT SS G C T TG C T T
1 0 CC A / 1 1 A / 0 0
MM AA T T MM T T MM
E 1 1 0 E 0 1 0
1 0
1 0
Pre-scaled Clock 0
SYSCLK 1
T0 TF1
TCLK TL0 TR1
TF0 Interrupt
(8 bits) TR0
IE1
TCON
TR0 IT1
Crossbar IE0
GATE0 IT0
TH0 Reload
(8 bits)
/INT0
Timer 1 is inactive in Mode 3. When Timer 0 is operating in Mode 3, Timer 1 can be operated in Modes 0,
1 or 2, but cannot be clocked by external signals nor set the TF1 flag and generate an interrupt. However,
the Timer 1 overflow can be used to generate baud rates for the SMBus and/or UART, and/or initiate ADC
conversions. While Timer 0 is operating in Mode 3, Timer 1 run control is handled through its mode set-
tings. To run Timer 1 while Timer 0 is in Mode 3, set the Timer 1 Mode as 0, 1, or 2. To disable Timer 1,
configure it for Mode 3.
CKCON TMOD
T T SS G C T T G C T T
1 0 CC A / 1 1 A / 0 0
MM AA T T MM T T MM
E 1 1 0 E 0 1 0
1 0
1 0
Pre-scaled Clock 0
TR1 TH0
TF1 Interrupt
(8 bits) TR1
TF0 Interrupt
SYSCLK 1 TR0
0 IE1
TCON
IT1
IE0
IT0
T0
TL0
(8 bits)
TR0
Crossbar GATE0
/INT0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: 0x88
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
GATE1 C/T1 T1M1 T1M0 GATE0 C/T0 T0M1 T0M0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x89
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - T1M T0M - SCA1 SCA0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8E
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8A
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8B
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8C
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x8D
SFR Page: 0
The Counter/Timer Select bit C/Tn bit (TMRnCN.1) configures the peripheral as a counter or timer. Clear-
ing C/Tn configures the Timer to be in a timer mode (i.e., the system clock or transitions on an external pin
as the input for the timer). When C/Tn is set to 1, the timer is configured as a counter (i.e., high-to-low tran-
sitions at the Tn input pin increment (or decrement) the counter/timer register. Timer 3 and Timer 2 share
the T2 input pin. Refer to Section “18.1. Ports 0 through 3 and the Priority Crossbar Decoder” on
page 238 for information on selecting and configuring external I/O pins for digital peripherals, such as the
Tn pin.
Timer 2, 3, and 4 can use either SYSCLK, SYSCLK divided by 2, SYSCLK divided by 12, an external clock
divided by 8, or high-to-low transitions on the Tn input pin as its clock source when operating in Counter/
Timer with Capture mode. Clearing the C/Tn bit (TMRnCN.1) selects the system clock/external clock as
the input for the timer. The Timer Clock Select bits TnM0 and TnM1 in TMRnCF can be used to select the
system clock undivided, system clock divided by two, system clock divided by 12, or an external clock pro-
vided at the XTAL1/XTAL2 pins divided by 8 (see SFR Definition 23.13). When C/Tn is set to logic 1, a
high-to-low transition at the Tn input pin increments the counter/timer register (i.e., configured as a
counter).
Note: When DCENn = 1, other functions of the TnEX input (i.e., capture and auto-reload) are not
available. TnEX will only control the direction of the timer when DCENn = 1.
As the 16-bit timer register increments and overflows TMRnH:TMRnL, the TFn Timer Overflow/Underflow
Flag (TMRnCN.7) is set to ‘1’ and an interrupt will occur if the interrupt is enabled. The timer can be config-
ured to count down by setting the Decrement Enable Bit (TMRnCF.0) to ‘1’. This will cause the timer to
decrement with every timer clock/count event and underflow when the timer transitions from 0x0000 to
0xFFFF. Just as in overflows, the Overflow/Underflow Flag (TFn) will be set to ‘1’, and an interrupt will
occur if enabled.
Counter/Timer with Capture mode is selected by setting the Capture/Reload Select bit CP/RLn
(TMRnCN.0) and the Timer 2, 3, and 4 Run Control bit TRn (TMRnCN.2) to logic 1. The Timer 2, 3, and 4
respective External Enable EXENn (TMRnCN.3) must also be set to logic 1 to enable captures. If EXENn
is cleared, transitions on TnEX will be ignored.
TMRnCF
T T T T D
n nO n C
MMGO E
1 0 n E n
Toggle Logic
0
2
Tn
0xFF 0xFF (Port Pin)
SYSCLK 12 1
External Clock 8 0
(XTAL1)
1
TCLK TMRnL TMRnH CP/RLn
Tn Crossbar C/Tn
TMRnCN
TRn
TRn EXENn
When counting down, the counter/timer will set its overflow/underflow flag (TFn) and cause an interrupt (if
enabled) when the value in the TMRnH and TMRnL registers matches the 16-bit value in the Reload/Cap-
ture Registers (RCAPnH and RCAPnL). This is considered an underflow event, and will cause the timer to
load the value 0xFFFF. The timer is automatically restarted when an underflow occurs.
Counter/Timer with Auto-Reload mode is selected by clearing the CP/RLn bit. Setting TRn to logic 1
enables and starts the timer.
In Auto-Reload Mode, the External Flag (EXFn) toggles upon every overflow or underflow and does not
cause an interrupt. The EXFn flag can be used as the most significant bit (MSB) of a 17-bit counter.
TMRnCF
D
T T T T
E
n nO n
C
MMGO
E
1 0 n E
n
Toggle Logic
0
2 Tn
0xFF 0xFF (Port Pin)
SYSCLK 12 1
External Clock 0
8
(XTAL1)
1 OVF
TCLK TMRnL TMRnH CP/RLn
Tn Crossbar C/Tn
TMRnCN
TRn
TRn EXENn
EXENn
EXFn Interrupt
Reload TFn
RCAPnL RCAPnH
TnE Crossbar
X
Figure 23.5. Tn Auto-reload (T2,3,4) and Toggle Mode (T2,4) Block Diagram
To output a square wave, the timer is placed in reload mode (the Capture/Reload Select Bit in TMRnCN
and the Timer/Counter Select Bit in TMRnCN are cleared to ‘0’). The timer output is enabled by setting the
Timer Output Enable Bit in TMRnCF to ‘1’. The timer should be configured via the timer clock source and
reload/underflow values such that the timer overflow/underflows at 1/2 the desired output frequency. The
port pin assigned by the crossbar as the timer’s output pin should be configured as a digital output (see
Section “18. Port Input/Output” on page 235). Setting the timer’s Run Bit (TRn) to ‘1’ will start the toggle
of the pin. A Read/Write of the Timer’s Toggle Output State Bit (TMRnCF.2) is used to read the state of the
toggle output, or to force a value of the output. This is useful when it is desired to start the toggle of a pin in
a known state, or to force the pin into a desired state when the toggle mode is halted.
F TCLK
F sq = ------------------------------------------------------
2 × ( 65536 – RCAPn )
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
TFn EXFn - - EXENn TRn C/Tn CP/RLn 00000000
Bit
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Addressable
SFR Address: TMR2CN:0xC8;TMR3CN:0xC8;TMR4CN:0xC8
SFR Page: TMR2CN: page 0;TMR3CN: page 1;TMR4CN: page 2
Bit7–5: Reserved.
Bit4–3: TnM1 and TnM0: Timer Clock Mode Select Bits.
Bits used to select the Timer clock source. The sources can be the System Clock
(SYSCLK), SYSCLK divided by 2 or 12, or the external clock divided by 8. Clock source is
selected as follows:
00: SYSCLK/12
01: SYSCLK
10: EXTERNAL CLOCK/8 (Synchronized to the System Clock)
11: SYSCLK/2
Bit2: TOGn: Toggle output state bit.
When timer is used to toggle a port pin, this bit can be used to read the state of the output, or
can be written to in order to force the state of the output (Timer 2 and Timer 4 Only).
Bit1: TnOE: Timer output enable bit.
This bit enables the timer to output a 50% duty cycle output to the timer’s assigned external
port pin.
NOTE: A timer is configured for Square Wave Output as follows:
CP/RLn = 0
C/Tn = 0
TnOE = 1
Load RCAPnH:RCAPnL (See “Square Wave Frequency (Timer 2 and Timer 4 Only)” on
page 320.)
Configure Port Pin to output squarewave (See Section “18. Port Input/Output” on
page 235)
0: Output of toggle mode not available at Timers’s assigned port pin.
1: Output of toggle mode available at Timers’s assigned port pin.
Bit0: DCENn: Decrement Enable Bit.
This bit enables the timer to count up or down as determined by the state of TnEX.
0: Timer will count up, regardless of the state of TnEX.
1: Timer will count up or down depending on the state of TnEX as follows:
if TnEX = 0, the timer counts DOWN.
if TnEX = 1, the timer counts UP.
SFR Definition 23.10. RCAPnL: Timer 2, 3, and 4 Capture Register Low Byte
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: RCAP2L: 0xCA; RCAP3L: 0xCA; RCAP4L: 0xCA
SFR Page: RCAP2L: page 0; RCAP3L: page 1; RCAP4L: page 2
Bits 7–0: RCAP2, 3, and 4L: Timer 2, 3, and 4 Capture Register Low Byte.
The RCAP2, 3, and 4L register captures the low byte of Timer 2, 3, and 4 when Timer 2, 3,
and 4 is configured in capture mode. When Timer 2, 3, and 4 is configured in auto-reload
mode, it holds the low byte of the reload value.
SFR Definition 23.11. RCAPnH: Timer 2, 3, and 4 Capture Register High Byte
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: RCAP2H: 0xCB; RCAP3H: 0xCB; RCAP4H: 0xCB
SFR Page: RCAP2H: page 0; RCAP3H: page 1; RCAP4H: page 2
Bits 7–0: RCAP2, 3, and 4H: Timer 2, 3, and 4 Capture Register High Byte.
The RCAP2, 3, and 4H register captures the high byte of Timer 2, 3, and 4 when Timer 2, 3,
and 4 is configured in capture mode. When Timer 2, 3, and 4 is configured in auto-reload
mode, it holds the high byte of the reload value.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: TMR2L: 0xCC; TMR3L: 0xCC; TMR4L: 0xCC
SFR Page: TMR2L: page 0; TMR3L: page 1; TMR4L: page 2
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: TMR2H: 0xCD; TMR3H: 0xCD; TMR4H: 0xCD
SFR Page: TMR2H: page 0; TMR3H: page 1; TMR4H: page 2
SYSCLK/12
SYSCLK/4
Timer 0 Overflow PCA
16-Bit Counter/Timer
ECI CLOCK
MUX
SYSCLK
External Clock/8
CEX1
CEX2
CEX3
CEX4
CEX5
ECI
Crossbar
Port I/O
When the counter/timer overflows from 0xFFFF to 0x0000, the Counter Overflow Flag (CF) in PCA0MD is
set to logic 1 and an interrupt request is generated if CF interrupts are enabled. Setting the ECF bit in
PCA0MD to logic 1 enables the CF flag to generate an interrupt request. The CF bit is not automatically
cleared by hardware when the CPU vectors to the interrupt service routine, and must be cleared by soft-
ware (Note: PCA0 interrupts must be globally enabled before CF interrupts are recognized. PCA0 inter-
rupts are globally enabled by setting the EA bit (IE.7) and the EPCA0 bit in EIE1 to logic 1). Clearing the
CIDL bit in the PCA0MD register allows the PCA to continue normal operation while the CPU is in Idle
mode.
IDLE
PCA0MD PCA0CN
CWW C C CE CCC C C C C C
I D D P P PC FRC C C C C C
D T L S S SF F F F F F F
L E C 2 1 0 5 4 3 2 1 0 To SFR Bus
K PCA0L
read
Snapshot
Register
SYSCLK/12
000
SYSCLK/4
001
Timer 0 Overflow
010 0
Overflow
ECI PCA0H PCA0L To PCA Interrupt System
011 1
SYSCLK CF
100
External Clock/8
101
To PCA Modules
Important Note About the PCA0CN Register: If the main PCA counter (PCA0H : PCA0L) overflows
during the execution phase of a read-modify-write instruction (bit-wise SETB or CLR, ANL, ORL, XRL) that
targets the PCA0CN register, the CF (Counter Overflow) bit will not be set. If the CF flag is used by soft-
ware to keep track of counter overflows, the following steps should be taken when performing a bit-wise
operation on the PCA0CN register:
Table 24.2 summarizes the bit settings in the PCA0CPMn registers used to select the PCA0 capture/com-
pare module’s operating modes. Setting the ECCFn bit in a PCA0CPMn register enables the module's
CCFn interrupt. Note: PCA0 interrupts must be globally enabled before individual CCFn interrupts are rec-
ognized. PCA0 interrupts are globally enabled by setting the EA bit (IE.7) and the EPCA0 bit (EIE1.3) to
logic 1. See Figure 24.3 for details on the PCA interrupt configuration.
(for n = 0 to 5)
PCA0CPMn PCA0CN PCA0MD
P EC CMT P E CCC C C C C C C C C CE
WCA A A OWC FRC C C C C C I P P PC
MOP P TGMC F F F F F F D S S S F
1 MP N n n n F 5 4 3 2 1 0 L 2 1 0
6 n n n n
n
0
PCA Counter/
Timer Overflow 1
ECCF0 EPCA0 EA
PCA Module 0 0 (EIE.3) (IE.7) Interrupt
(CCF0) 1 0 0
Priority
1 1 Decoder
ECCF1
PCA Module 1 0
(CCF1) 1
ECCF2
PCA Module 2 0
(CCF2) 1
ECCF3
PCA Module 3 0
(CCF3) 1
ECCF4
PCA Module 4 0
(CCF4) 1
ECCF5
PCA Module 5 0
(CCF5) 1
PCA Interrupt
PCA0CPMn
P ECCMT P E PCA0CN
WC A A AOWC CCCCCCCC
MOPP TGMC FRCCCCCC
1 MP N n n n F FFFFFF
6 n n n n 5 4 3 2 1 0
n
(to CCFn)
PCA0CPLn PCA0CPHn
0
1
CEXn Capture
Port I/O Crossbar
0
1
PCA
Timebase
PCA0L PCA0H
Note: The signal at CEXn must be high or low for at least 2 system clock cycles in order to be valid.
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Capture/
Compare registers, the low byte should always be written first. Writing to PCA0CPLn clears the ECOMn bit
to ‘0’; writing to PCA0CPHn sets ECOMn to ‘1’.
Write to
PCA0CPLn 0
ENB
Reset
PCA
Write to Interrupt
PCA0CPHn ENB
1
PCA0CPMn
P ECCMT P E PCA0CN
WC A A AOWC CCCCCCCC
MOPP TGMC PCA0CPLn PCA0CPHn
FRCCCCCC
1 MP N n n n F FFFFFF
6 n n n n 5 4 3 2 1 0
n
x 0 0 0 0 x
0
Enable Match
16-bit Comparator
1
PCA
Timebase
PCA0L PCA0H
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Capture/
Compare registers, the low byte should always be written first. Writing to PCA0CPLn clears the ECOMn bit
to ‘0’; writing to PCA0CPHn sets ECOMn to ‘1’.
Write to
PCA0CPLn 0
ENB
Reset
PCA0CPMn
Write to
PCA0CPHn ENB P ECCMT P E
1 WC A A AOWC
MOPP TGMC
1 MP N n n n F
6 n n n n
n PCA
x 0 0 0 x Interrupt
PCA0CN
CCCCCCCC
FRCCCCCC
PCA0CPLn PCA0CPHn
FFFFFF
5 4 3 2 1 0
0
Enable Match
16-bit Comparator
1
TOGn
Toggle
0 CEXn
Crossbar Port I/O
1
PCA
Timebase
PCA0L PCA0H
Where FPCA is the frequency of the clock selected by the CPS2–0 bits in the PCA mode register,
PCA0MD. The lower byte of the capture/compare module is compared to the PCA0 counter low byte; on a
match, CEXn is toggled and the offset held in the high byte is added to the matched value in PCA0CPLn.
Frequency Output Mode is enabled by setting the ECOMn, TOGn, and PWMn bits in the PCA0CPMn reg-
ister.
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Capture/
Compare registers, the low byte should always be written first. Writing to PCA0CPLn clears the ECOMn bit
to ‘0’; writing to PCA0CPHn sets ECOMn to ‘1’.
PCA0CPMn
P ECCMT P E
WC A A AOWC
PCA0CPLn 8-bit Adder PCA0CPHn
MOPP TGMC
1 MP N n n n F
Adder
6 n n n n
Enable
n TOGn
0 0 0 0 1 0 Toggle
0 CEXn
Enable 8-bit match Crossbar Port I/O
Comparator 1
PCA Timebase
PCA0L
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Capture/
Compare registers, the low byte should always be written first. Writing to PCA0CPLn clears the ECOMn bit
to ‘0’; writing to PCA0CPHn sets ECOMn to ‘1’.
PCA0CPHn
PCA0CPMn
P ECCMT P E
WC A A AOWC
PCA0CPLn
MOPP TGMC
1 MP N n n n F
6 n n n n
n
0 0 0 0 0 0
R CLR
Q
PCA Timebase
PCA0L
Overflow
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Capture/
Compare registers, the low byte should always be written first. Writing to PCA0CPLn clears the ECOMn bit
to ‘0’; writing to PCA0CPHn sets ECOMn to ‘1’.
PCA0CPMn
P ECCMT P E
WC A A AOWC
PCA0CPHn PCA0CPLn
MOPP TGMC
1 MP N n n n F
6 n n n n
n
1 0 0 0 0 0
R CLR
Q
PCA Timebase
PCA0H PCA0L
Overflow
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CF CR CCF5 CCF4 CCF3 CCF2 CCF1 CCF0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD8
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CIDL - - - CPS2 CPS1 CPS0 ECF 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xD9
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PWM16n ECOMn CAPPn CAPNn MATn TOGn PWMn ECCFn 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR PCA0CPM0: 0xDA, PCA0CPM1: 0xDB, PCA0CPM2: 0xDC, PCA0CPM3: 0xDD, PCA0CPM4: 0xDE,
Address: PCA0CPM5: 0xDF
PCA0CPM0: page 0, PCA0CPM1: page 0, PCA0CPM2: page 0, PCA0CPM3: 0, PCA0CPM4: page 0,
SFR Page:
PCA0CPM5: page 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xF9
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xFA
SFR Page: 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
PCA0CPL0: 0xFB, PCA0CPL1: 0xFD, PCA0CPL2: 0xE9, PCA0CPL3: 0xEB, PCA0CPL4: 0xED, PCA0CPL5:
SFR Address:
0xE1
PCA0CPL0: page 0, PCA0CPL1: page 0, PCA0CPL2: page 0, PCA0CPL3: page 0, PCA0CPL4: page 0,
SFR Page:
PCA0CPL5: page 0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
PCA0CPH0: 0xFC, PCA0CPH1: 0xFD, PCA0CPH2: 0xEA, PCA0CPH3: 0xEC, PCA0CPH4: 0xEE, PCA0CPH5:
SFR Address:
0xE2
PCA0CPH0: page 0, PCA0CPH1: page 0, PCA0CPH2: page 0, PCA0CPH3: page 0, PCA0CPH4: page 0,
SFR Page:
PCA0CPH5: page 0
NOTES:
The JTAG interface is accessed via four dedicated pins on the MCU: TCK, TMS, TDI, and TDO.
Through the 16-bit JTAG Instruction Register (IR), any of the eight instructions shown in Figure 25.1 can
be commanded. There are three DR’s associated with JTAG Boundary-Scan, and four associated with
Flash read/write operations on the MCU.
Reset Value
0x0000
Bit15 Bit0
Reset Value
Version Part Number Manufacturer ID 1 0xn0003243
Bit31 Bit28 Bit27 Bit12 Bit11 Bit1 Bit0
Version = 0000b
19:18 17:0
IndOpCode WriteData
IndOpCode: These bit set the operation to perform according to the following table:
IndOpCode Operation
0x Poll
10 Read
11 Write
The Poll operation is used to check the Busy bit as described below. Although a Capture-DR is performed,
no Update-DR is allowed for the Poll operation. Since updates are disabled, polling can be accomplished
by shifting in/out a single bit.
The Read operation initiates a read from the register addressed by the DRAddress. Reads can be initiated
by shifting only 2 bits into the indirect register. After the read operation is initiated, polling of the Busy bit
must be performed to determine when the operation is complete.
The write operation initiates a write of WriteData to the register addressed by DRAddress. Registers of any
width up to 18 bits can be written. If the register to be written contains fewer than 18 bits, the data in Write-
Data should be left-justified, i.e. its MSB should occupy bit 17 above. This allows shorter registers to be
written in fewer JTAG clock cycles. For example, an 8-bit register could be written by shifting only 10 bits.
After a Write is initiated, the Busy bit should be polled to determine when the next operation can be initi-
ated. The contents of the Instruction Register should not be altered while either a read or write operation is
busy.
Outgoing data from the indirect Data Register has the following format:
19 18:1 0
0 ReadData Busy
The Busy bit indicates that the current operation is not complete. It goes high when an operation is initiated
and returns low when complete. Read and Write commands are ignored while Busy is high. In fact, if poll-
ing for Busy to be low will be followed by another read or write operation, JTAG writes of the next operation
can be made while checking for Busy to be low. They will be ignored until Busy is read low, at which time
the new operation will initiate. This bit is placed ate bit 0 to allow polling by single-bit shifts. When waiting
for a Read to complete and Busy is 0, the following 18 bits can be shifted out to obtain the resulting data.
ReadData is always right-justified. This allows registers shorter than 18 bits to be read using a reduced
number of shifts. For example, the results from a byte-read requires 9 bit shifts (Busy + 8 bits).
Reset Value
SFLE WRMD2 WRMD1 WRMD0 RDMD3 RDMD2 RDMD1 RDMD0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
This register determines how the Flash interface logic will respond to reads and writes to the FLASH-
DAT Register.
Reset Value
0000000000
Bit9 Bit0
This register is used to read or write data to the Flash memory across the JTAG interface.
Reset Value
0x00000
Bit16 Bit0
This register holds the address for all JTAG Flash read, write, and erase operations. This register
autoincrements after each read or write, regardless of whether the operation succeeded or failed.
The C8051F120DK is a development kit with all the hardware and software necessary to develop applica-
tion code and perform in-circuit debug with each MCU in the C8051F12x and C8051F13x device families.
Each kit includes development software for the PC, a Serial Adapter (for connection to JTAG) and a target
application board with a C8051F120 installed. Serial cables and wall-mount power supply are also
included.
NOTES:
Disclaimer
Silicon Laboratories intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers
using or intending to use the Silicon Laboratories products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific
device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Laboratories
reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy
or completeness of the included information. Silicon Laboratories shall have no liability for the consequences of use of the information supplied herein. This document does not imply
or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products must not be used within any Life Support System without the specific
written consent of Silicon Laboratories. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected
to result in significant personal injury or death. Silicon Laboratories products are generally not intended for military applications. Silicon Laboratories products shall under no
circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons.
Trademark Information
Silicon Laboratories Inc., Silicon Laboratories, Silicon Labs, SiLabs and the Silicon Labs logo, CMEMS®, EFM, EFM32, EFR, Energy Micro, Energy Micro logo and combinations
thereof, "the world’s most energy friendly microcontrollers", Ember®, EZLink®, EZMac®, EZRadio®, EZRadioPRO®, DSPLL®, ISOmodem ®, Precision32®, ProSLIC®, SiPHY®,
USBXpress® and others are trademarks or registered trademarks of Silicon Laboratories Inc. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of
ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders.
http://www.silabs.com