C 8051 F 310/1/2/3/4/5/6/7
C 8051 F 310/1/2/3/4/5/6/7
Port 0
A 10-bit SMBus
+
M SPI Port 1
U
200ksps
- PCA
X ADC + Port 2
Timer 0
TEMP - Timer 1 Port 3
SENSOR Timer 2
VOLTAGE
COMPARATORS Timer 3
C8051F310/1/2/3/6 only
NOTES:
2 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Table Of Contents
1. System Overview.................................................................................................... 17
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. On-Chip Debug Circuitry................................................................................... 30
1.4. Programmable Digital I/O and Crossbar ........................................................... 31
1.5. Serial Ports ....................................................................................................... 32
1.6. Programmable Counter Array ........................................................................... 32
1.7. 10-Bit Analog to Digital Converter..................................................................... 33
1.8. Comparators ..................................................................................................... 34
2. Absolute Maximum Ratings .................................................................................. 35
3. Global DC Electrical Characteristics .................................................................... 36
4. Pinout and Package Definitions............................................................................ 39
5. 10-Bit ADC (ADC0, C8051F310/1/2/3/6 only) ........................................................ 51
5.1. Analog Multiplexer ............................................................................................ 51
5.2. Temperature Sensor ......................................................................................... 52
5.3. Modes of Operation .......................................................................................... 54
5.3.1. Starting a Conversion............................................................................... 54
5.3.2. Tracking Modes........................................................................................ 55
5.3.3. Settling Time Requirements ..................................................................... 56
5.4. Programmable Window Detector ...................................................................... 61
5.4.1. Window Detector In Single-Ended Mode ................................................. 63
5.4.2. Window Detector In Differential Mode...................................................... 64
6. Voltage Reference (C8051F310/1/2/3/6 only)........................................................ 67
7. Comparators ........................................................................................................... 69
8. CIP-51 Microcontroller .......................................................................................... 79
8.1. Instruction Set ................................................................................................... 80
8.1.1. Instruction and CPU Timing ..................................................................... 80
8.1.2. MOVX Instruction and Program Memory ................................................. 81
8.2. Memory Organization........................................................................................ 85
8.2.1. Program Memory...................................................................................... 85
8.2.2. Data Memory............................................................................................ 86
8.2.3. General Purpose Registers ...................................................................... 86
8.2.4. Bit Addressable Locations........................................................................ 86
8.2.5. Stack ....................................................................................................... 86
8.2.6. Special Function Registers....................................................................... 87
8.2.7. Register Descriptions ............................................................................... 90
8.3. Interrupt Handler ............................................................................................... 93
8.3.1. MCU Interrupt Sources and Vectors ........................................................ 94
8.3.2. External Interrupts .................................................................................... 95
8.3.3. Interrupt Priorities ..................................................................................... 95
Rev. 1.7 3
C8051F310/1/2/3/4/5/6/7
4 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 5
C8051F310/1/2/3/4/5/6/7
6 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
List of Figures
1. System Overview
Figure 1.1. C8051F310 Block Diagram .................................................................... 19
Figure 1.2. C8051F311 Block Diagram .................................................................... 20
Figure 1.3. C8051F312 Block Diagram .................................................................... 21
Figure 1.4. C8051F313 Block Diagram .................................................................... 22
Figure 1.5. C8051F314 Block Diagram .................................................................... 23
Figure 1.6. C8051F315 Block Diagram .................................................................... 24
Figure 1.7. C8051F316 Block Diagram .................................................................... 25
Figure 1.8. C8051F317 Block Diagram .................................................................... 26
Figure 1.9. Comparison of Peak MCU Execution Speeds ....................................... 27
Figure 1.10. On-Chip Clock and Reset..................................................................... 28
Figure 1.11. On-Board Memory Map........................................................................ 29
Figure 1.12. Development/In-System Debug Diagram............................................. 30
Figure 1.13. Digital Crossbar Diagram ..................................................................... 31
Figure 1.14. PCA Block Diagram.............................................................................. 32
Figure 1.15. 10-Bit ADC Block Diagram ................................................................... 33
Figure 1.16. Comparator0 Block Diagram ................................................................ 34
2. Absolute Maximum Ratings
3. Global DC Electrical Characteristics
4. Pinout and Package Definitions
Figure 4.1. LQFP-32 Pinout Diagram (Top View) .................................................... 41
Figure 4.2. LQFP-32 Package Diagram ................................................................... 42
Figure 4.3. QFN-28 Pinout Diagram (Top View) ...................................................... 43
Figure 4.4. QFN-28 Package Drawing ..................................................................... 44
Figure 4.5. Typical QFN-28 Landing Diagram.......................................................... 45
Figure 4.6. QFN-28 Solder Paste Recommendation................................................ 46
Figure 4.7. QFN-24 Pinout Diagram (Top View) ...................................................... 47
Figure 4.8. QFN-24 Package Drawing ..................................................................... 48
Figure 4.9. Typical QFN-24 Landing Diagram.......................................................... 49
Figure 4.10. QFN-24 Solder Paste Recommendation.............................................. 50
5. 10-Bit ADC (ADC0, C8051F310/1/2/3/6 only)
Figure 5.1. ADC0 Functional Block Diagram............................................................ 51
Figure 5.2. Typical Temperature Sensor Transfer Function..................................... 52
Figure 5.3. Temperature Sensor Error with 1-Point Calibration ............................... 53
Figure 5.4. 10-Bit ADC Track and Conversion Example Timing .............................. 55
Figure 5.5. ADC0 Equivalent Input Circuits.............................................................. 56
Figure 5.6. ADC Window Compare Example: Right-Justified Single-Ended Data ... 63
Figure 5.7. ADC Window Compare Example: Left-Justified Single-Ended Data ..... 63
Figure 5.8. ADC Window Compare Example: Right-Justified Differential Data ....... 64
Figure 5.9. ADC Window Compare Example: Left-Justified Differential Data.......... 64
6. Voltage Reference (C8051F310/1/2/3/6 only)
Figure 6.1. Voltage Reference Functional Block Diagram ....................................... 67
Rev. 1.7 7
C8051F310/1/2/3/4/5/6/7
7. Comparators
Figure 7.1. Comparator0 Functional Block Diagram ................................................ 69
Figure 7.2. Comparator1 Functional Block Diagram ................................................ 70
Figure 7.3. Comparator Hysteresis Plot ................................................................... 71
8. CIP-51 Microcontroller
Figure 8.1. CIP-51 Block Diagram............................................................................ 79
Figure 8.2. Memory Map .......................................................................................... 85
9. Reset Sources
Figure 9.1. Reset Sources...................................................................................... 105
Figure 9.2. Power-On and VDD Monitor Reset Timing ........................................... 106
10. Flash Memory
Figure 10.1. Flash Program Memory Map.............................................................. 113
11. External RAM
12. Oscillators
Figure 12.1. Oscillator Diagram.............................................................................. 121
Figure 12.2. 32.768 kHz External Crystal Example................................................ 126
13. Port Input/Output
Figure 13.1. Port I/O Functional Block Diagram ..................................................... 129
Figure 13.2. Port I/O Cell Block Diagram ............................................................... 130
Figure 13.3. Crossbar Priority Decoder with No Pins Skipped ............................... 131
Figure 13.4. Crossbar Priority Decoder with Crystal Pins Skipped ........................ 132
14. SMBus
Figure 14.1. SMBus Block Diagram ....................................................................... 145
Figure 14.2. Typical SMBus Configuration ............................................................. 146
Figure 14.3. SMBus Transaction ............................................................................ 147
Figure 14.4. Typical SMBus SCL Generation......................................................... 151
Figure 14.5. Typical Master Transmitter Sequence................................................ 157
Figure 14.6. Typical Master Receiver Sequence.................................................... 158
Figure 14.7. Typical Slave Receiver Sequence...................................................... 159
Figure 14.8. Typical Slave Transmitter Sequence.................................................. 160
15. UART0
Figure 15.1. UART0 Block Diagram ....................................................................... 163
Figure 15.2. UART0 Baud Rate Logic .................................................................... 164
Figure 15.3. UART Interconnect Diagram .............................................................. 165
Figure 15.4. 8-Bit UART Timing Diagram............................................................... 165
Figure 15.5. 9-Bit UART Timing Diagram............................................................... 166
Figure 15.6. UART Multi-Processor Mode Interconnect Diagram .......................... 167
16. Enhanced Serial Peripheral Interface (SPI0)
Figure 16.1. SPI Block Diagram ............................................................................. 173
Figure 16.2. Multiple-Master Mode Connection Diagram ....................................... 176
Figure 16.3. 3-Wire Single Master and Slave Mode Connection Diagram ............. 176
Figure 16.4. 4-Wire Single Master and Slave Mode Connection Diagram ............. 176
Figure 16.5. Master Mode Data/Clock Timing ........................................................ 178
Figure 16.6. Slave Mode Data/Clock Timing (CKPHA = 0) .................................... 179
Figure 16.7. Slave Mode Data/Clock Timing (CKPHA = 1) .................................... 179
8 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 9
C8051F310/1/2/3/4/5/6/7
NOTES:
10 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
List of Tables
1. System Overview
Table 1.1. Product Selection Guide ......................................................................... 18
2. Absolute Maximum Ratings
Table 2.1. Absolute Maximum Ratings .................................................................... 35
3. Global DC Electrical Characteristics
Table 3.1. Global DC Electrical Characteristics ....................................................... 36
Table 3.2. Electrical Characteristics Quick Reference ............................................ 38
4. Pinout and Package Definitions
Table 4.1. Pin Definitions for the C8051F31x .......................................................... 39
Table 4.2. LQFP-32 Package Dimensions .............................................................. 42
Table 4.3. QFN-28 Package Dimensions ................................................................ 44
Table 4.4. QFN-24 Package Dimensions ................................................................ 48
5. 10-Bit ADC (ADC0, C8051F310/1/2/3/6 only)
Table 5.1. ADC0 Electrical Characteristics .............................................................. 65
6. Voltage Reference (C8051F310/1/2/3/6 only)
Table 6.1. External Voltage Reference Circuit Electrical Characteristics ................ 68
7. Comparators
Table 7.1. Comparator Electrical Characteristics .................................................... 78
8. CIP-51 Microcontroller
Table 8.1. CIP-51 Instruction Set Summary ............................................................ 81
Table 8.2. Special Function Register (SFR) Memory Map ...................................... 87
Table 8.3. Special Function Registers ..................................................................... 88
Table 8.4. Interrupt Summary .................................................................................. 96
9. Reset Sources
Table 9.1. Reset Electrical Characteristics ............................................................ 110
10. Flash Memory
Table 10.1. Flash Electrical Characteristics .......................................................... 112
Table 10.2. Flash Security Summary .................................................................... 114
11. External RAM
12. Oscillators
Table 12.1. Internal Oscillator Electrical Characteristics ....................................... 123
13. Port Input/Output
Table 13.1. Port I/O DC Electrical Characteristics ................................................ 143
14. SMBus
Table 14.1. SMBus Clock Source Selection .......................................................... 150
Table 14.2. Minimum SDA Setup and Hold Times ................................................ 151
Table 14.3. Sources for Hardware Changes to SMB0CN ..................................... 155
Table 14.4. SMBus Status Decoding ..................................................................... 161
Rev. 1.7 11
C8051F310/1/2/3/4/5/6/7
15. UART0
Table 15.1. Timer Settings for Standard Baud Rates
Using the Internal Oscillator ............................................................... 170
Table 15.2. Timer Settings for Standard Baud Rates
Using an External 25 MHz Oscillator .................................................. 170
Table 15.3. Timer Settings for Standard Baud Rates
Using an External 22.1184 MHz Oscillator ......................................... 171
Table 15.4. Timer Settings for Standard Baud Rates
Using an External 18.432 MHz Oscillator ........................................... 171
Table 15.5. Timer Settings for Standard Baud Rates
Using an External 11.0592 MHz Oscillator ......................................... 172
Table 15.6. Timer Settings for Standard Baud Rates
Using an External 3.6864 MHz Oscillator ........................................... 172
16. Enhanced Serial Peripheral Interface (SPI0)
Table 16.1. SPI Slave Timing Parameters ............................................................ 185
17. Timers
18. Programmable Counter Array
Table 18.1. PCA Timebase Input Options ............................................................. 204
Table 18.2. PCA0CPM Register Settings for PCA Capture/Compare Modules .... 205
Table 18.3. Watchdog Timer Timeout Intervals ..................................................... 214
19. Revision Specific Behavior
20. C2 Interface
12 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
List of Registers
SFR Definition 5.1. AMX0P: AMUX0 Positive Channel Select . . . . . . . . . . . . . . . . . . . 57
SFR Definition 5.2. AMX0N: AMUX0 Negative Channel Select . . . . . . . . . . . . . . . . . . 58
SFR Definition 5.3. ADC0CF: ADC0 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
SFR Definition 5.4. ADC0H: ADC0 Data Word MSB . . . . . . . . . . . . . . . . . . . . . . . . . . 59
SFR Definition 5.5. ADC0L: ADC0 Data Word LSB . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
SFR Definition 5.6. ADC0CN: ADC0 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
SFR Definition 5.7. ADC0GTH: ADC0 Greater-Than Data High Byte . . . . . . . . . . . . . 61
SFR Definition 5.8. ADC0GTL: ADC0 Greater-Than Data Low Byte . . . . . . . . . . . . . . 61
SFR Definition 5.9. ADC0LTH: ADC0 Less-Than Data High Byte . . . . . . . . . . . . . . . . 62
SFR Definition 5.10. ADC0LTL: ADC0 Less-Than Data Low Byte . . . . . . . . . . . . . . . . 62
SFR Definition 6.1. REF0CN: Reference Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
SFR Definition 7.1. CPT0CN: Comparator0 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
SFR Definition 7.2. CPT0MX: Comparator0 MUX Selection . . . . . . . . . . . . . . . . . . . . 73
SFR Definition 7.3. CPT0MD: Comparator0 Mode Selection . . . . . . . . . . . . . . . . . . . . 74
SFR Definition 7.4. CPT1CN: Comparator1 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
SFR Definition 7.5. CPT1MX: Comparator1 MUX Selection . . . . . . . . . . . . . . . . . . . . 76
SFR Definition 7.6. CPT1MD: Comparator1 Mode Selection . . . . . . . . . . . . . . . . . . . . 77
SFR Definition 8.1. DPL: Data Pointer Low Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
SFR Definition 8.2. DPH: Data Pointer High Byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
SFR Definition 8.3. SP: Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
SFR Definition 8.4. PSW: Program Status Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
SFR Definition 8.5. ACC: Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
SFR Definition 8.6. B: B Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
SFR Definition 8.7. IE: Interrupt Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
SFR Definition 8.8. IP: Interrupt Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
SFR Definition 8.9. EIE1: Extended Interrupt Enable 1 . . . . . . . . . . . . . . . . . . . . . . . . 99
SFR Definition 8.10. EIP1: Extended Interrupt Priority 1 . . . . . . . . . . . . . . . . . . . . . . 100
SFR Definition 8.11. IT01CF: INT0/INT1 Configuration . . . . . . . . . . . . . . . . . . . . . . . 101
SFR Definition 8.12. PCON: Power Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
SFR Definition 9.1. VDM0CN: VDD Monitor Control . . . . . . . . . . . . . . . . . . . . . . . . . . 107
SFR Definition 9.2. RSTSRC: Reset Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
SFR Definition 10.1. PSCTL: Program Store R/W Control . . . . . . . . . . . . . . . . . . . . . 116
SFR Definition 10.2. FLKEY: Flash Lock and Key . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
SFR Definition 10.3. FLSCL: Flash Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
SFR Definition 11.1. EMI0CN: External Memory Interface Control . . . . . . . . . . . . . . 119
SFR Definition 12.1. OSCICL: Internal Oscillator Calibration . . . . . . . . . . . . . . . . . . . 122
SFR Definition 12.2. OSCICN: Internal Oscillator Control . . . . . . . . . . . . . . . . . . . . . 122
SFR Definition 12.3. CLKSEL: Clock Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
SFR Definition 12.4. OSCXCN: External Oscillator Control . . . . . . . . . . . . . . . . . . . . 125
SFR Definition 13.1. XBR0: Port I/O Crossbar Register 0 . . . . . . . . . . . . . . . . . . . . . 134
SFR Definition 13.2. XBR1: Port I/O Crossbar Register 1 . . . . . . . . . . . . . . . . . . . . . 135
SFR Definition 13.3. P0: Port0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
SFR Definition 13.4. P0MDIN: Port0 Input Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Rev. 1.7 13
C8051F310/1/2/3/4/5/6/7
14 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
SFR Definition 18.7. PCA0CPHn: PCA Capture Module High Byte . . . . . . . . . . . . . . 219
C2 Register Definition 20.1. C2ADD: C2 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
C2 Register Definition 20.2. DEVICEID: C2 Device ID . . . . . . . . . . . . . . . . . . . . . . . . 223
C2 Register Definition 20.3. REVID: C2 Revision ID . . . . . . . . . . . . . . . . . . . . . . . . . 224
C2 Register Definition 20.4. FPCTL: C2 Flash Programming Control . . . . . . . . . . . . 224
C2 Register Definition 20.5. FPDAT: C2 Flash Programming Data . . . . . . . . . . . . . . 224
Rev. 1.7 15
C8051F310/1/2/3/4/5/6/7
NOTES:
16 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
1. System Overview
C8051F31x devices are fully integrated mixed-signal System-on-a-Chip MCUs. Highlighted features are
listed below. Refer to Table 1.1 for specific product feature selection.
With on-chip Power-On Reset, VDD monitor, Watchdog Timer, and clock oscillator, the C8051F31x devices
are truly stand-alone System-on-a-Chip solutions. The Flash memory can be reprogrammed even in-cir-
cuit, providing non-volatile data storage, and also allowing field upgrades of the 8051 firmware. User soft-
ware has complete control of all peripherals, and may individually shut down any or all peripherals for
power savings.
The on-chip Silicon Labs 2-Wire (C2) Development Interface allows non-intrusive (uses no on-chip
resources), full speed, in-circuit debugging using the production MCU installed in the final application. This
debug logic supports inspection and modification of memory and registers, setting breakpoints, single
stepping, run and halt commands. All analog and digital peripherals are fully functional while debugging
using C2. The two C2 interface pins can be shared with user functions, allowing in-system programming
and debugging without occupying package pins.
Each device is specified for 2.7-to-3.6 V operation over the industrial temperature range (–45 to +85 °C).
The Port I/O and RST pins are tolerant of input signals up to 5 V. The C8051F31x are available in 32-pin
LQFP, 28-pin QFN, and 24-pin QFN packages. See Table 1.1 for ordering part numbers. Note: QFN pack-
ages are also referred to as MLP or MLF packages.
Rev. 1.7 17
C8051F310/1/2/3/4/5/6/7
Analog Comparators
Temperature Sensor
Digital Port I/Os
Timers (16-bit)
Enhanced SPI
Flash Memory
MIPS (Peak)
SMBus/I2C
Package
UART
RAM
18 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 16kbyte
Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
Latch v
2% e P2.7
Internal P3.0/C2D
Oscillator P P3.1
3 P3.2
Port 3 P3.3
Latch D P3.4
r
v
CP0 +
-
CP1 +
-
VDD VREF
Temp
A
10-bit
M AIN0-AIN20
200ksps U
ADC X
VDD
Rev. 1.7 19
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 16kbyte Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
v
2% e Latch P2.7
Internal P3.0/C2D
Oscillator P
3
Port 3
Latch D
r
v
CP0 +
-
CP1 +
-
VDD VREF
Temp
A
10-bit
M AIN0-AIN20
200ksps U
ADC X
VDD
20 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 8 kB
Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
Latch v
2% e P2.7
Internal P3.0/C2D
Oscillator P P3.1
3 P3.2
Port 3 P3.3
Latch D P3.4
r
v
CP0 +
-
CP1 +
-
VDD VREF
Temp
A
10-bit
M AIN0-AIN20
200ksps U
ADC X
VDD
Rev. 1.7 21
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 8 kB
Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
Latch v
2% e P2.7
Internal P3.0/C2D
Oscillator P
3
Port 3
Latch D
r
v
CP0 +
-
CP1 +
-
VDD VREF
Temp
A
10-bit
M AIN0-AIN20
200ksps U
ADC X
VDD
22 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 8 kB
Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
v
2% e Latch P2.7
Internal P3.0/C2D
Oscillator P P3.1
3 P3.2
Port 3 P3.3
Latch D P3.4
r
v
CP0 +
-
CP1 +
-
Rev. 1.7 23
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND
v P0.7
UART
C
C2D
Debug HW
8 8 kB
Timer R P
P1.0
P1.1
FLASH
0 0,1,2,3 /
RTC
O 1 P1.2
P1.3
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.4
P1.5
PCA/ B r
Brown-
1 WDT A v
P1.6
P1.7
POR 1K byte
Out R
SRAM SMBus P2.0
P
C 2
P2.1
P2.2
External SPI
XTAL1
Oscillator
o P2.3
P2.4
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.5
P2.6
Latch v
2% e P2.7
Internal P3.0/C2D
Oscillator P
3
Port 3
Latch D
r
v
CP0 +
-
CP1 +
-
24 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND v P0.7
UART
C
C2D
Debug HW
8 16 kB
Timer R P
FLASH P1.0
0 0,1,2,3 /
RTC
O 1 P1.1
S P1.2
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.3
PCA/ B r P1.4
Brown-
1 WDT A v P1.5
POR 1 kB
Out R
SRAM SMBus
P
C 2
P2.0
P2.1
XTAL1 External SPI
Oscillator
o P2.2
P2.3
System Clock SFR Bus D
XTAL2 Circuit r Port 2 r P2.4
P2.5
v
2% e Latch
Internal P3.0/C2D
Oscillator P
3
Port 3
Latch D
r
v
CP0 +
-
CP1 +
-
VDD VREF
Temp
A
10-bit AIN0–AIN20
M
200 ksps U
ADC X
VDD
Rev. 1.7 25
C8051F310/1/2/3/4/5/6/7
P0.0/VREF
Analog/Digital P
Port 0 P0.1
Power 0
VDD Latch P0.2/XTAL1
P0.3/XTAL2
Port 1 D P0.4/TX
Latch P0.5/RX
r P0.6/CNVST
GND v P0.7
UART
C
C2D
Debug HW
8 16 kB
Timer R P P1.0
FLASH
0 0,1,2,3 /
RTC
O 1 P1.1
P1.2
S
/RST/C2CK
Reset
5 256 byte
SRAM
S D P1.3
P1.4
PCA/ B r
Brown-
1 WDT A v
P1.5
POR 1 kB
Out R
SRAM SMBus
P
C 2
P2.0
P2.1
XTAL1 External SPI
Oscillator
o P2.2
System Clock SFR Bus D P2.3
XTAL2 Circuit r Port 2 r P2.4
P2.5
v
2% e Latch
Internal P3.0/C2D
Oscillator P
3
Port 3
Latch D
r
v
CP0 +
-
CP1 +
-
26 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
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 25 MHz, it has a peak throughput of 25 MIPS. Figure 1.9
shows a comparison of peak throughputs for various 8-bit microcontroller cores with their maximum sys-
tem clocks.
25
20
MIPS
15
10
Rev. 1.7 27
C8051F310/1/2/3/4/5/6/7
The extended interrupt handler provides 14 interrupt sources into the CIP-51 (as opposed to 7 for the stan-
dard 8051), allowing 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 interrupt
sources are very useful when building multi-tasking, real-time systems.
Eight reset sources are available: power-on reset circuitry (POR), an on-chip VDD monitor (forces reset
when power supply voltage drops below VRST as given in Table 9.1 on page 110), a Watchdog Timer, a
Missing Clock Detector, a voltage level detection from Comparator0, a forced software reset, an external
reset pin, and an errant Flash read/write protection circuit. Each reset source except for the POR, Reset
Input Pin, or Flash error may be disabled by the user in software. The WDT may be permanently enabled
in software after a power-on reset during MCU initialization.
The internal oscillator is factory calibrated to 24.5 MHz ±2%. An external oscillator drive circuit is also
included, allowing an external crystal, ceramic resonator, capacitor, RC, or CMOS clock source to generate
the system clock. If desired, the system clock source may be switched on-the-fly between the internal and
external oscillator circuits. An external oscillator can be extremely useful in low power applications, allow-
ing the MCU to run from a slow (power saving) external crystal source, while periodically switching to the
fast internal oscillator as needed.
VDD
Power On
Reset
Supply
Monitor
+
'0' /RST
Comparator 0 - Enable (wired-OR)
Px.x
+
-
Px.x C0RSEF
Missing
Clock
Reset
Detector Funnel
(one-
shot) PCA
EN
WDT (Software Reset)
SWRSF
EN Errant
FLASH
Enable
Enable
WDT
MCD
Operation
Internal
Oscillator
System
Clock
XTAL1 External CIP-51
Oscillator
XTAL2 Drive Clock Select Microcontroller System Reset
Core
Extended Interrupt
Handler
28 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Program memory consists of 8 or 16 kB of Flash. This memory may be reprogrammed in-system in 512
byte sectors, and requires no special off-chip programming voltage. See Figure 1.11 for the MCU system
memory map.
RESERVED
0x2000 Same 1024 bytes as from
0x1FFF 0x0000 to 0x03FF, wrapped
on 1 kB boundaries
8 kB Flash
0x0400
(In-System 0x03FF
XRAM - 1024 Bytes
Programmable in 512 (accessable using MOVX
Byte Sectors) 0x0000 instruction)
0x0000
Rev. 1.7 29
C8051F310/1/2/3/4/5/6/7
Silicon Labs' debugging system supports inspection and modification of memory and registers, break-
points, and single stepping. No additional target RAM, program memory, timers, or communications chan-
nels 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 C8051F310DK development kit provides all the hardware and software necessary to develop applica-
tion code and perform in-circuit debugging with the C8051F31x MCUs. The kit includes software with a
developer's studio and debugger, an integrated 8051 assembler, a debug adapter, a target application
board with the associated MCU installed, and the required cables and wall-mount power supply.
The Silicon Labs IDE interface is a vastly superior developing and debugging configuration, compared to
standard MCU emulators that use on-board "ICE Chips" and require the MCU in the application board to
be socketed. Silicon Labs' debug paradigm increases ease of use and preserves the performance of the
precision analog peripherals.
Debug
Adapter
VDD GND
TARGET PCB
C8051F31x
30 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
The Digital Crossbar allows mapping of internal digital system resources to Port I/O pins (See Figure 1.13).
On-chip counter/timers, serial buses, HW interrupts, comparator output, 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.
Priority
Decoder
Highest 2
UART
Priority
P0 P0.0
4 8
SPI I/O
Cells P0.7
2
(Internal Digital Signals)
SMBus
P1 P1.0
Digital 8
CP0 2 I/O
Crossbar Cells
Outputs P1.7
CP1 2
Outputs P2 P2.0
4 8
SYSCLK I/O
Cells P2.7
4
6
PCA
P3 P3.0
5
Lowest 2 I/O
T0, T1 Cells P3.4
Priority
8
P0 (P0.0-P0.7) Notes:
1. P3.1–P3.4 only available on the
8 C8051F310/2/4.
2. P1.6, P1.7, P2.6, P2.7 only
(Port Latches)
(P2.0-P2.3)
P2 4
(P2.4-P2.7)
5
P3 (P3.0-P3.4)
Rev. 1.7 31
C8051F310/1/2/3/4/5/6/7
Each capture/compare module can be configured to operate in one of six modes: Edge-Triggered Capture,
Software Timer, High Speed Output, 8- or 16-bit Pulse Width Modulator, or Frequency Output. Additionally,
Capture/Compare Module 4 offers watchdog timer (WDT) capabilities. Following a system reset, Module 4
is configured and enabled in WDT mode. The PCA Capture/Compare Module I/O and External Clock Input
may be routed to 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
ECI
Crossbar
Port I/O
32 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Window compare registers for the ADC data can be configured to interrupt the controller when ADC data is
either within or outside of a specified range. The ADC can monitor a key voltage continuously in back-
ground mode, but not interrupt the controller unless the converted data is within/outside the specified
range.
Analog Multiplexer
P1.0
Rev. 1.7 33
C8051F310/1/2/3/4/5/6/7
1.8. Comparators
C8051F31x devices include two on-chip voltage comparators that are enabled/disabled and configured via
user software. Port I/O pins may be configured as comparator inputs via a selection mux. Two comparator
outputs may be routed to a Port pin if desired: a latched output and/or an unlatched (asynchronous) output.
Comparator response time is programmable, allowing the user to select between high-speed and low-
power modes. Positive and negative hysteresis are also configurable.
Comparator interrupts may be generated on rising, falling, or both edges. When in IDLE mode, these inter-
rupts may be used as a “wake-up” source. Comparator0 may also be configured as a reset source.
Figure 1.16 shows he Comparator0 block diagram.
CP0EN
CP0OUT
CP0RIF VDD
CPT0CN
CP0FIF
CP0HYP1
CMX0N1 CP0
CPT0MX
CP0HYP0
CMX0N0 Interrupt
CP0HYN1
CP0HYN0
CMX0P1
CMX0P0
P1.0 CP0 CP0
Rising-edge Falling-edge
P1.4
- CLR
Q CLR
Q
P1.1 Crossbar
(SYNCHRONIZER)
CP0RIE
CPT0MD
CP0FIE
CP0MD1
CP0MD0
34 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
*Note: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to
the device. This is a stress rating only and functional operation of the devices at those or any other condi-
tions above those indicated in the operation listings of this specification is not implied. Exposure to maxi-
mum rating conditions for extended periods may affect device reliability.
Rev. 1.7 35
C8051F310/1/2/3/4/5/6/7
36 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 37
C8051F310/1/2/3/4/5/6/7
Other electrical characteristics tables are found in the data sheet section corresponding to the associated
peripherals. For more information on electrical characteristics for a specific peripheral, refer to the page
indicated in Table 3.2.
38 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 39
C8051F310/1/2/3/4/5/6/7
40 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P1.0
P1.1
32
31
30
29
28
27
26
25
P0.1 1 24 P1.2
P0.0 2 23 P1.3
GND 3 22 P1.4
/RST/C2CK 5
Top View 20 P1.6
P3.0/C2D 6 19 P1.7
P3.1 7 18 P2.0
P3.2 8 17 P2.1
10
11
12
13
14
15
16
9
P3.3
P3.4
P2.6
P2.7
P2.5
P2.4
P2.3
P2.2
Rev. 1.7 41
C8051F310/1/2/3/4/5/6/7
42 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P1.0
28
27
26
25
24
23
22
GND
P0.1 1 21 P1.1
P0.0 2 20 P1.2
GND 3 19 P1.3
VDD 4
C8051F311/3/5 18 P1.4
Top View
/RST/C2CK 5 17 P1.5
P3.0/C2D 6 16 P1.6
GND
P2.7 7 15 P1.7
10
11
12
13
14
8
9
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
Rev. 1.7 43
C8051F310/1/2/3/4/5/6/7
11
10
12
13
14
8
9
MM
L MIN TYP MAX
7 15 A 0.80 0.90 1.00
A1 0 0.02 0.05
6 16 A2 0 0.65 1.00
D2
A3 - 0.25 -
5 D2 17 b 0.18 0.23 0.30
b
2 D - 5.00 -
6xe
E2
4 18
E
D2 2.90 3.15 3.35
R
e
E - 5.00 -
3 19 E2 2.90 3.15 3.35
E2
2
e - 0.5 -
2 20
L 0.45 0.55 0.65
N - 28 -
1 DETAIL 1 21
ND - 7 -
NE - 7 -
R 0.09 - -
28
27
26
25
24
23
22
AA - 0.435 -
6xe BB - 0.435 -
D CC - 0.18 -
DD - 0.18 -
Side View
A2
e
A3
A1
DETAIL 1
AA
BB
CC
DD
44 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Top View
0.50 mm
0.20 mm
0.20 mm
0.30 mm
0.85 mm
0.50 mm
0.10 mm
0.50 mm
0.35 mm
0.20 mm
b
Optional
GND
Connection
D2
D
L
E2
e
0.20 mm
0.30 mm
0.50 mm 0.35 mm
0.85 mm 0.10 mm
Rev. 1.7 45
C8051F310/1/2/3/4/5/6/7
Top View
0.50 mm
0.20 mm
0.20 mm
0.30 mm
0.85 mm
0.50 mm
0.10 mm
0.50 mm
0.35 mm
0.20 mm 0.60 mm
0.60 mm
0.70 mm 0.30 mm
0.20 mm
b
0.40 mm
D2
D
L
e
E2
0.20 mm
0.30 mm
0.50 mm 0.35 mm
0.85 mm 0.10 mm
46 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
24
23
22
21
20
19
P0.1 1 18 P1.0
P0.0 2 17 P1.1
GND 3 16 P1.2
C8051F316/7
VDD 4 Top View 15 P1.3
11
12
7
9
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
Rev. 1.7 47
C8051F310/1/2/3/4/5/6/7
10
11
12
7
9
MIN TYP MAX
L
R
6 13
A 0.70 0.75 0.80
b
D2 / 2
5 14
A3 — 0.25 —
e
5xe
D — 4.00 —
D2
D
3 16 D2 2.50 2.60 2.70
E2 / 2 E — 4.00 —
2 17 E2 2.50 2.60 2.70
E2
D/2
e — 0.50 —
1 18 L 0.35 0.40 0.45
Pin #1 ID
N — 24 —
ND — 6 —
19
24
23
22
21
20
NE — 6 —
5xe
R 0.09 — —
E
Side View
A2
e
A3
A1
48 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Top View
0.75 mm
0.35 mm
0.10 mm
0.45 mm
Pin #1
e
Optional
GND
Connection
D2
D
b
E2
0.20 mm
0.30 mm
0.35 mm 0.45 mm
0.75 mm 0.10 mm
Rev. 1.7 49
C8051F310/1/2/3/4/5/6/7
Top View
0.75 mm
0.35 mm
0.10 mm
0.45 mm
Pin #1
0.60 mm 0.45 mm
e
0.80 mm 0.30 mm
0.20 mm
0.35 mm 0.35 mm
D2
D
b
E2
0.20 mm
0.30 mm
0.35 mm 0.45 mm
0.75 mm 0.10 mm
50 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
P1.0
AMX0P ADC0CN
AD0BUSY
AD0WINT
AD0CM2
AD0CM1
AD0CM0
AMX0P4
AMX0P3
AMX0P2
AMX0P1
AMX0P0
AD0INT
AD0TM
AD0EN
P1.6-1.7 available on
C8051F310/1/2/3/4/5 P1.7
P2.0
23-to-1
P2.6-2.7 available on AMUX VDD
P2.7 000 AD0BUSY (W)
C8051F310/1/2/3/4/5 Start
P3.0 001 Timer 0 Overflow
Conversion
P3.1-3.4 010 Timer 2 Overflow
available on 011 Timer 1 Overflow
C8051F310/2 P3.4
100 CNVSTR Input
VDD
ADC0L
101 Timer 3 Overflow
Temp
Sensor (+)
10-Bit
SAR
ADC
ADC0H
(-)
P1.0
SYSCLK
REF
P1.6-1.7 available on
C8051F310/1/2/3/4/5 P1.7
P2.0 AD0WINT
23-to-1 Window
P2.6-2.7 available on AMUX Compare
AMX0N
AD0LJST
AD0SC4
AD0SC3
AD0SC2
AD0SC1
AD0SC0
P2.7 32 Logic
C8051F310/1/2/3/4/5 ADC0LTH ADC0LTL
AMX0N4
AMX0N3
AMX0N2
AMX0N1
AMX0N0
P3.0
P3.1-3.4
available on
C8051F310/2 P3.4 ADC0CF ADC0GTH ADC0GTL
VREF
GND
The conversion code format differs between Single-ended and Differential modes. The registers ADC0H
and ADC0L contain the high and low bytes of the output conversion code from the ADC at the completion
of each conversion. Data can be right-justified or left-justified, depending on the setting of the AD0LJST bit
(ADC0CN.0). When in Single-ended Mode, conversion codes are represented as 10-bit unsigned integers.
Rev. 1.7 51
C8051F310/1/2/3/4/5/6/7
Inputs are measured from ‘0’ to VREF * 1023/1024. Example codes are shown below for both right-justified
and left-justified data. Unused bits in the ADC0H and ADC0L registers are set to ‘0’.
When in Differential Mode, conversion codes are represented as 10-bit signed 2’s complement numbers.
Inputs are measured from -VREF to VREF * 511/512. Example codes are shown below for both right-justi-
fied and left-justified data. For right-justified data, the unused MSBs of ADC0H are a sign-extension of the
data word. For left-justified data, the unused LSBs in the ADC0L register are set to ‘0’.
Important Note About ADC0 Input Configuration: Port pins selected as ADC0 inputs should be config-
ured as analog inputs, and should be skipped by the Digital Crossbar. To configure a Port pin for analog
input, set to ‘0’ the corresponding bit in register PnMDIN (for n = 0,1,2,3). To force the Crossbar to skip a
Port pin, set to ‘1’ the corresponding bit in register PnSKIP (for n = 0,1,2). See Section “13. Port Input/
Output” on page 129 for more Port I/O configuration details.
(mV)
1200
1100
1000
900
VTEMP = 3.35*(TEMPC) + 897 mV
800
700
52 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
The uncalibrated temperature sensor output is extremely linear and suitable for relative temperature mea-
surements (see Table 5.1 for linearity specifications). For absolute temperature measurements, gain and/
or offset calibration is recommended. Typically a 1-point calibration includes the following steps:
Figure 5.3 shows the typical temperature sensor error assuming a 1-point calibration at 25 °C. Note that
parameters which affect ADC measurement, in particular the voltage reference value, will also
affect temperature measurement.
5.00 5.00
4.00 4.00
3.00 3.00
2.00 2.00
Error (degrees C)
1.00 1.00
0.00 0.00
-40.00 -20.00 0.00 40.00 60.00 80.00
20.00
-1.00 -1.00
-2.00 -2.00
-3.00 -3.00
-4.00 -4.00
-5.00 -5.00
Temperature (degrees C)
Rev. 1.7 53
C8051F310/1/2/3/4/5/6/7
Writing a ‘1’ to AD0BUSY provides software control of ADC0 whereby conversions are performed "on-
demand". During conversion, the AD0BUSY bit is set to logic 1 and reset to logic 0 when the conversion is
complete. The falling edge of AD0BUSY triggers an interrupt (when enabled) and sets the ADC0 interrupt
flag (AD0INT). Note: When polling for ADC conversion completions, the ADC0 interrupt flag (AD0INT)
should be used. Converted data is available in the ADC0 data registers, ADC0H:ADC0L, when bit AD0INT
is logic 1. Note that when Timer 2 or Timer 3 overflows are used as the conversion source, Low Byte over-
flows are used if Timer 2/3 is in 8-bit mode; High byte overflows are used if Timer 2/3 is in 16-bit mode. See
Section “17. Timers” on page 187 for timer configuration.
Important Note About Using CNVSTR: The CNVSTR input pin also functions as Port pin P0.6. When the
CNVSTR input is used as the ADC0 conversion source, Port pin P0.6 should be skipped by the Digital
Crossbar. To configure the Crossbar to skip P0.6, set to ‘1’ Bit6 in register P0SKIP. See Section “13. Port
Input/Output” on page 129 for details on Port I/O configuration.
54 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
1 2 3 4 5 6 7 8 9 10 11
SAR Clocks
SAR Clocks
Low Power
AD0TM=1 Track Convert Low Power Mode
or Convert
1 2 3 4 5 6 7 8 9 10 11
SAR Clocks
Track or
AD0TM=0 Convert Track
Convert
Rev. 1.7 55
C8051F310/1/2/3/4/5/6/7
Figure 5.5 shows the equivalent ADC0 input circuits for both Differential and Single-ended modes. Notice
that the equivalent time constant for both input circuits is the same. The required ADC0 settling time for a
given settling accuracy (SA) may be approximated by Equation 5.1. When measuring the Temperature
Sensor output or VDD with respect to GND, RTOTAL reduces to RMUX. See Table 5.1 for ADC0 minimum
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 AMUX0 resistance and any external source resistance.
n is the ADC resolution in bits (10).
Px.x Px.x
RMUX = 5k RMUX = 5k
CSAMPLE = 5pF CSAMPLE = 5pF
CSAMPLE = 5pF
Px.x
RMUX = 5k
MUX Select
56 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 57
C8051F310/1/2/3/4/5/6/7
58 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD0SC4 AD0SC3 AD0SC2 AD0SC1 AD0SC0 AD0LJST - - 11111000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xBC
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:
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 SFR Address:
0xBD
Rev. 1.7 59
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
AD0EN AD0TM AD0INT AD0BUSY AD0WINT AD0CM2 AD0CM1 AD0CM0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xE8
60 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
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:
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 Address:
0xC3
Rev. 1.7 61
C8051F310/1/2/3/4/5/6/7
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:
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 SFR Address:
0xC5
62 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
ADC0H:ADC0L ADC0H:ADC0L
Input Voltage Input Voltage
(Px.x - GND) (Px.x - GND)
AD0WINT
AD0WINT=1
not affected
0x0081 0x0081
VREF x (128/1024) 0x0080 ADC0LTH:ADC0LTL VREF x (128/1024) 0x0080 ADC0GTH:ADC0GTL
0x007F 0x007F
AD0WINT
AD0WINT=1
not affected
0x0041 0x0041
VREF x (64/1024) 0x0040 ADC0GTH:ADC0GTL VREF x (64/1024) 0x0040 ADC0LTH:ADC0LTL
0x003F 0x003F
AD0WINT AD0WINT=1
not affected
0 0x0000 0 0x0000
ADC0H:ADC0L ADC0H:ADC0L
Input Voltage Input Voltage
(Px.x - GND) (Px.x - GND)
AD0WINT
AD0WINT=1
not affected
0x2040 0x2040
VREF x (128/1024) 0x2000 ADC0LTH:ADC0LTL VREF x (128/1024) 0x2000 ADC0GTH:ADC0GTL
0x1FC0 0x1FC0
AD0WINT
AD0WINT=1
not affected
0x1040 0x1040
VREF x (64/1024) 0x1000 ADC0GTH:ADC0GTL VREF x (64/1024) 0x1000 ADC0LTH:ADC0LTL
0x0FC0 0x0FC0
AD0WINT AD0WINT=1
not affected
0 0x0000 0 0x0000
Rev. 1.7 63
C8051F310/1/2/3/4/5/6/7
ADC0H:ADC0L ADC0H:ADC0L
Input Voltage Input Voltage
(Px.x - Px.x) (Px.x - Px.x)
AD0WINT
AD0WINT=1
not affected
0x0041 0x0041
VREF x (64/512) 0x0040 ADC0LTH:ADC0LTL VREF x (64/512) 0x0040 ADC0GTH:ADC0GTL
0x003F 0x003F
AD0WINT
AD0WINT=1
not affected
0x0000 0x0000
VREF x (-1/512) 0xFFFF ADC0GTH:ADC0GTL VREF x (-1/512) 0xFFFF ADC0LTH:ADC0LTL
0xFFFE 0xFFFE
AD0WINT AD0WINT=1
not affected
ADC0H:ADC0L ADC0H:ADC0L
Input Voltage Input Voltage
(Px.x - Px.x) (Px.x - Px.y)
AD0WINT
AD0WINT=1
not affected
0x1040 0x1040
VREF x (64/512) 0x1000 ADC0LTH:ADC0LTL VREF x (64/512) 0x1000 ADC0GTH:ADC0GTL
0x0FC0 0x0FC0
AD0WINT
AD0WINT=1
not affected
0x0000 0x0000
VREF x (-1/512) 0xFFC0 ADC0GTH:ADC0GTL VREF x (-1/512) 0xFFC0 ADC0LTH:ADC0LTL
0xFF80 0xFF80
AD0WINT AD0WINT=1
not affected
64 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 65
C8051F310/1/2/3/4/5/6/7
NOTES:
66 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
The BIASE bit enables the internal voltage bias generator, which is used by the ADC, Temperature Sensor,
and Internal Oscillator. This bit is forced to logic 1 when any of the aforementioned peripherals is enabled.
The bias generator may be enabled manually by writing a ‘1’ to the BIASE bit in register REF0CN; see
SFR Definition 6.1 for REF0CN register details. The electrical specifications for the voltage reference cir-
cuit are given in Table 6.1.
Important Note About the VREF Input: Port pin P0.0 is used as the external VREF input. When using an
external voltage reference, P0.0 should be configured as analog input and skipped by the Digital Crossbar.
To configure P0.0 as analog input, set to ‘0’ Bit0 in register P0MDIN. To configure the Crossbar to skip
P0.0, set to ‘1’ Bit0 in register P0SKIP. Refer to Section “13. Port Input/Output” on page 129 for com-
plete Port I/O configuration details.
The temperature sensor connects to the highest order input of the ADC0 positive input multiplexer (see
Section “5.1. Analog Multiplexer” on page 51 for details). The TEMPE bit in register REF0CN
enables/disables the temperature sensor. While disabled, the temperature sensor defaults to a high imped-
ance state and any ADC0 measurements performed on the sensor result in meaningless data.
REF0CN
TEMPE
REFSL
BIASE
EN To ADC, Internal
Bias Generator
Oscillator
IOSCEN
VDD External
Voltage EN
Reference Temp Sensor To Analog Mux
R1 Circuit
VREF
0
Internal
VREF
(to ADC)
GND
VDD 1
Rev. 1.7 67
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
REFSL TEMPE BIASE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xD1
68 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
7. Comparators
C8051F31x devices include two on-chip programmable voltage comparators: Comparator0 is shown in
Figure 7.1; Comparator1 is shown in Figure 7.2. The two comparators operate identically with the following
exceptions: (1) Their input selections differ as shown in Figure 7.1 and Figure 7.2; (2) Comparator0 can be
used as a reset source.
The Comparator offers programmable response time and hysteresis, an analog input multiplexer, and two
outputs that are optionally available at the Port pins: a synchronous “latched” output (CP0, CP1), or an
asynchronous “raw” output (CP0A, CP1A). The asynchronous CP0A signal is available even when the
system clock is not active. This allows the Comparator to operate and generate an output with the device
in STOP mode. When assigned to a Port pin, the Comparator output may be configured as open drain or
push-pull (see Section “13.2. Port I/O Initialization” on page 133). Comparator0 may also be used as a
reset source (see Section “9.5. Comparator0 Reset” on page 108).
The Comparator0 inputs are selected in the CPT0MX register (SFR Definition 7.2). The CMX0P1-CMX0P0
bits select the Comparator0 positive input; the CMX0N1-CMX0N0 bits select the Comparator0 negative
input. The Comparator1 inputs are selected in the CPT1MX register (SFR Definition 7.5). The CMX1P1-
CMX1P0 bits select the Comparator1 positive input; the CMX1N1-CMX1N0 bits select the Comparator1
negative input.
Important Note About Comparator Inputs: The Port pins selected as comparator inputs should be con-
figured as analog inputs in their associated Port configuration register, and configured to be skipped by the
Crossbar (for details on Port configuration, see Section “13.3. General Purpose Port I/O” on page 135).
CP0EN
CP0OUT
CP0RIF VDD
CPT0CN
CP0FIF
CP0HYP1
CMX0N1 CP0
CPT0MX
CP0HYP0
CMX0N0 Interrupt
CP0HYN1
CP0HYN0
CMX0P1
CMX0P0
P1.0 CP0 CP0
Rising-edge Falling-edge
P1.4
- CLR
Q CLR
Q
P1.1 Crossbar
(SYNCHRONIZER)
CP0RIE
CPT0MD
CP0FIE
CP0MD1
CP0MD0
Rev. 1.7 69
C8051F310/1/2/3/4/5/6/7
The Comparator output can be polled in software, used as an interrupt source, and/or routed to a Port pin.
When routed to a Port pin, the Comparator output is available asynchronous or synchronous to the system
clock; the asynchronous output is available even in STOP mode (with no system clock active). When dis-
abled, the Comparator output (if assigned to a Port I/O pin via the Crossbar) defaults to the logic low state,
and its supply current falls to less than 100 nA. See Section “13.1. Priority Crossbar Decoder” on
page 131 for details on configuring Comparator outputs via the digital Crossbar. Comparator inputs can be
externally driven from –0.25 V to (VDD) + 0.25 V without damage or upset. The complete Comparator elec-
trical specifications are given in Table 7.1.
The Comparator response time may be configured in software via the CPTnMD registers (see SFR Defini-
tion 7.3 and SFR Definition 7.6). Selecting a longer response time reduces the Comparator supply current.
See Table 7.1 for complete timing and current consumption specifications.
CP1EN
CP1OUT
CP1RIF VDD
CPT1CN
CP1FIF
CP1HYP1
CMX1N1 CP1
CPT1MX
CP1HYP0
CMX1N0 Interrupt
CP1HYN1
CP1HYN0
CMX1P1
CMX1P0
P1.2 CP1 CP1
Rising-edge Falling-edge
P1.6
- CL R
Q CL R
Q
P1.3 Crossbar
(SYNCHRONIZER)
CP1RIE
CPT1MD
CP1FIE
CP1MD1
CP1MD0
70 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
CP0+
VIN+ +
CP0 OUT
CP0- _
VIN-
CIRCUIT CONFIGURATION
VOH
OUTPUT
VOL
Negative Hysteresis Maximum
Disabled Negative Hysteresis
The Comparator hysteresis is software-programmable via its Comparator Control register CPTnCN (for
n = 0 or 1). The user can program both the amount of hysteresis voltage (referred to the input voltage) and
the positive and negative-going symmetry of this hysteresis around the threshold voltage.
The Comparator hysteresis is programmed using Bits3-0 in the Comparator Control Register CPTnCN
(shown in SFR Definition 7.1 and SFR Definition 7.4). The amount of negative hysteresis voltage is
determined by the settings of the CPnHYN bits. As shown in Table 7.1, settings of 20, 10 or 5 mV of
negative hysteresis can be programmed, or negative hysteresis can be disabled. In a similar way, the
amount of positive hysteresis is determined by the setting the CPnHYP bits.
Comparator interrupts can be generated on both rising-edge and falling-edge output transitions. (For Inter-
rupt enable and priority control, see Section “8.3. Interrupt Handler” on page 93). The CPnFIF flag is set
to logic 1 upon a Comparator falling-edge interrupt, and the CPnRIF flag is set to logic 1 upon the Compar-
ator rising-edge interrupt. Once set, these bits remain set until cleared by software. The output state of the
Comparator can be obtained at any time by reading the CPnOUT bit. The Comparator is enabled by set-
ting the CPnEN bit to logic 1, and is disabled by clearing this bit to logic 0.
The output state of the Comparator can be obtained at any time by reading the CPnOUT bit. The Compar-
ator is enabled by setting the CPnEN bit to logic 1, and is disabled by clearing this bit to logic 0.
Note that false rising edges and falling edges can be detected when the comparator is first powered-on or
if changes are made to the hysteresis or response time control bits. Therefore, it is recommended that the
rising-edge and falling-edge flags be explicitly cleared to logic 0 a short time after the comparator is
enabled or its mode bits have been changed. This Power Up Time is specified in Table 7.1 on page 78.
Rev. 1.7 71
C8051F310/1/2/3/4/5/6/7
72 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - CMX0N1 CMX0N0 - - CMX0P1 CMX0P0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x9F
Rev. 1.7 73
C8051F310/1/2/3/4/5/6/7
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 Address:
0x9D
74 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 75
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - CMX1N1 CMX1N0 - - CMX1P1 CMX1P0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x9E
76 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
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 SFR Address:
0x9C
Rev. 1.7 77
C8051F310/1/2/3/4/5/6/7
78 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
8. CIP-51 Microcontroller
The MCU system controller core is the CIP-51 microcontroller. The CIP-51 is fully compatible with the
MCS-51™ instruction set; standard 803x/805x assemblers and compilers can be used to develop soft-
ware. The MCU family has a superset of all the peripherals included with a standard 8051. Included are
four 16-bit counter/timers (see description in Section 17), an enhanced full-duplex UART (see description
in Section 15), an Enhanced SPI (see description in Section 16), 256 bytes of internal RAM, 128 byte
Special Function Register (SFR) address space (Section 8.2.6), and 29 Port I/O (see description in Sec-
tion 13). The CIP-51 also includes on-chip debug hardware (see description in Section 20), and interfaces
directly with the analog and digital subsystems providing a complete data acquisition or control-system
solution in a single integrated circuit.
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 8.1 for a block diagram).
The CIP-51 includes the following features:
- Fully Compatible with MCS-51 Instruction - 29 Port I/O
Set - Extended Interrupt Handler
- 25 MIPS Peak Throughput with 25 MHz - Reset Input
Clock - Power Management Modes
- 0 to 25 MHz Clock Frequency - On-chip Debug Logic
- 256 Bytes of Internal RAM - Program and Data Memory Security
DATA BUS
D8
D8
D8
D8
D8
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
Rev. 1.7 79
C8051F310/1/2/3/4/5/6/7
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 maximum system clock at 25 MHz, it has a peak throughput of 25 MIPS. The CIP-51 has
a total of 109 instructions. The table below shows the total number of instructions that require each execu-
tion time.
The on-chip debug support logic facilitates full speed in-circuit debugging, allowing the setting of hardware
breakpoints, 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 registers and mem-
ory. This method of on-chip debugging is completely non-intrusive, requiring no RAM, Stack, timers, or
other on-chip resources. C2 details can be found in Section “20. C2 Interface” on page 223.
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 an editor, evaluation compiler, assembler,
debugger and programmer. The IDE's debugger and programmer interface to the CIP-51 via the C2 inter-
face to provide fast and efficient in-system device programming and debugging. Third party macro assem-
blers 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 8.1 is the
80 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
CIP-51 Instruction Set Summary, which includes the mnemonic, number of bytes, and number of clock
cycles for each instruction.
Rev. 1.7 81
C8051F310/1/2/3/4/5/6/7
82 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 83
C8051F310/1/2/3/4/5/6/7
rel - 8-bit, signed (two’s 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
2 kB 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 8 kB program memory space.
There is one unused opcode (0xA5) that performs the same function as NOP.
All mnemonics copyrighted © Intel Corporation 1980.
84 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
RESERVED
0x2000 Same 1024 bytes as from
0x0000 to 0x03FF, wrapped
0x1FFF
on 1 kB boundaries
8 kB Flash
0x0400
(In-System 0x03FF
XRAM - 1024 Bytes
Programmable in 512 (accessable using MOVX
Byte Sectors) 0x0000 instruction)
0x0000
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 “10. Flash Memory” on page 111 for further details.
Rev. 1.7 85
C8051F310/1/2/3/4/5/6/7
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 SFRs. 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 8.2 illustrates the data memory organization of the CIP-51.
The MCS-51™ assembly language allows an alternate notation for bit addressing of the form XX.B where
XX is the byte address and B is the bit position within the byte. For example, the instruction:
MOV C, 22.3h
moves the Boolean value at 0x13 (bit 3 of the byte at location 0x22) into the Carry flag.
8.2.5. Stack
A programmer's stack can be located anywhere in the 256-byte data memory. The stack area is desig-
nated using the Stack Pointer (SP, 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.
86 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
The SFR registers are accessed anytime the direct addressing mode is used to access memory locations
from 0x80 to 0xFF. SFRs with addresses ending in 0x0 or 0x8 (e.g. P0, TCON, SCON0, IE, etc.) are bit-
addressable as well as byte-addressable. All other SFRs 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 8.3,
for a detailed description of each register.
Rev. 1.7 87
C8051F310/1/2/3/4/5/6/7
88 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
Rev. 1.7 89
C8051F310/1/2/3/4/5/6/7
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
90 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
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
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
Rev. 1.7 91
C8051F310/1/2/3/4/5/6/7
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xE0
92 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xF0
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). 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; // ... followed by another 2-byte opcode
; in assembly:
CLR EA ; clear EA bit
CLR EA ; ... followed by another 2-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)
Rev. 1.7 93
C8051F310/1/2/3/4/5/6/7
instruction, a new interrupt request will be generated immediately and the CPU will re-enter the ISR after
the completion of the next instruction.
94 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
/INT0 and /INT1 are assigned to Port pins as defined in the IT01CF register (see SFR Definition 8.11).
Note that /INT0 and /INT0 Port pin assignments are independent of any Crossbar assignments. /INT0 and
/INT1 will monitor their assigned Port pins without disturbing the peripheral that was assigned the Port pin
via the Crossbar. To assign a Port pin only to /INT0 and/or /INT1, configure the Crossbar to skip the
selected pin(s). This is accomplished by setting the associated bit in register XBR0 (see Section
“13.1. Priority Crossbar Decoder” on page 131 for complete details on configuring the Crossbar).
IE0 (TCON.1) and IE1 (TCON.3) serve as the interrupt-pending flags for the /INT0 and /INT1 external
interrupts, respectively. If an /INT0 or /INT1 external interrupt is configured as edge-sensitive, the corre-
sponding interrupt-pending flag is automatically cleared by the hardware when the CPU vectors to the ISR.
When configured as level sensitive, the interrupt-pending flag remains logic 1 while the input is active as
defined by the corresponding polarity bit (IN0PL or IN1PL); the flag remains logic 0 while the input is inac-
tive. The external interrupt source must hold the input active until the interrupt request is recognized. It
must then deactivate the interrupt request before execution of the ISR completes or another interrupt
request will be generated.
Rev. 1.7 95
C8051F310/1/2/3/4/5/6/7
Bit addressable?
Cleared by HW?
Interrupt Priority Enable Priority
Interrupt Source Pending Flag
Vector Order Flag Control
Always Always
Reset 0x0000 Top None N/A N/A
Enabled Highest
External Interrupt 0 (/INT0) 0x0003 0 IE0 (TCON.1) Y Y EX0 (IE.0) PX0 (IP.0)
Timer 0 Overflow 0x000B 1 TF0 (TCON.5) Y Y ET0 (IE.1) PT0 (IP.1)
External Interrupt 1 (/INT1) 0x0013 2 IE1 (TCON.3) Y Y EX1 (IE.2) PX1 (IP.2)
Timer 1 Overflow 0x001B 3 TF1 (TCON.7) Y Y ET1 (IE.3) PT1 (IP.3)
RI0 (SCON0.0)
UART0 0x0023 4 Y N ES0 (IE.4) PS0 (IP.4)
TI0 (SCON0.1)
TF2H (TMR2CN.7)
Timer 2 Overflow 0x002B 5 Y N ET2 (IE.5) PT2 (IP.5)
TF2L (TMR2CN.6)
SPIF (SPI0CN.7)
WCOL (SPI0CN.6)
ESPI0 PSPI0
SPI0 0x0033 6 MODF (SPI0CN.5) Y N
(IE.6) (IP.6)
RXOVRN
(SPI0CN.4)
ESMB0 PSMB0
SMB0 0x003B 7 SI (SMB0CN.0) Y N
(EIE1.0) (EIP1.0)
RESERVED 0x0043 8 N/A N/A N/A N/A N/A
AD0WINT EWADC0 PWADC0
ADC0 Window Compare 0x004B 9 Y N
(ADC0CN.3) (EIE1.2) (EIP1.2)
ADC0 Conversion AD0INT EADC0 PADC0
0x0053 10 Y N
Complete (ADC0CN.5) (EIE1.3) (EIP1.3)
Programmable Counter CF (PCA0CN.7) EPCA0 PPCA0
0x005B 11 Y N
Array CCFn (PCA0CN.n) (EIE1.4) (EIP1.4)
CP0FIF
(CPT0CN.4) ECP0 PCP0
Comparator0 0x0063 12 N N
CP0RIF (EIE1.5) (EIP1.5)
(CPT0CN.5)
CP1FIF
(CPT1CN.4) ECP1 PCP1
Comparator1 0x006B 13 N N
CP1RIF (EIE1.6) (EIP1.6)
(CPT1CN.5)
TF3H (TMR3CN.7) ET3 PT3
Timer 3 Overflow 0x0073 14 N N
TF3L (TMR3CN.6) (EIE1.7) (EIP1.7)
96 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
EA ESPI0 ET2 ES0 ET1 EX1 ET0 EX0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xA8
Rev. 1.7 97
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- PSPI0 PT2 PS0 PT1 PX1 PT0 PX0 10000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xB8
98 Rev. 1.7
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
ET3 ECP1 ECP0 EPCA0 EADC0 EWADC0 Reserved ESMB0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xE6
Rev. 1.7 99
C8051F310/1/2/3/4/5/6/7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PT3 PCP1 PCP0 PCP0 PADC0 PWADC0 Reserved PSMB0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xF6
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
IN1PL IN1SL2 IN1SL1 IN1SL0 IN0PL IN0SL2 IN0SL1 IN0SL0 00000001
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xE4
Note: Refer to SFR Definition 17.1 for INT0/1 edge- or level-sensitive interrupt selection.
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 placed in low power mode. Digital
peripherals, such as timers or serial buses, draw little power when they are not in use. Turning off the oscil-
lators lowers power consumption considerably; however, a reset is required to restart the MCU.
Idle mode is terminated when an enabled interrupt is asserted or a reset occurs. The assertion of an
enabled interrupt 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 program execution at address 0x0000.
If enabled, the Watchdog Timer (WDT) will eventually cause an internal watchdog reset and thereby termi-
nate 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 pro-
vides the opportunity for additional power savings, allowing the system to remain in the Idle mode indefi-
nitely, waiting for an external stimulus to wake up the system. Refer to Section “9.6. PCA Watchdog
Timer Reset” on page 108 for more information on the use and configuration of the WDT.
Note: Any instruction that sets the IDLE bit should be immediately followed by an instruction that
has 2 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 of the IDLE bit is a single-byte instruction and an interrupt occurs during
the execution phase of the instruction that 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 in STOP mode for longer than the
MCD timeout of 100 µsec.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
GF5 GF4 GF3 GF2 GF1 GF0 STOP IDLE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x87
NOTES:
9. Reset Sources
Reset circuitry allows the controller to be easily placed in a predefined default condition. On entry to this
reset state, the following occur:
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 is not altered.
The Port I/O latches are reset to 0xFF (all logic ones) in open-drain mode. Weak pullups are enabled dur-
ing and after the reset. For VDD Monitor and power-on resets, the RST pin is driven low until the device
exits the reset state.
On exit from the reset state, the program counter (PC) is reset, and the system clock defaults to the inter-
nal oscillator. Refer to Section “12. Oscillators” on page 121 for information on selecting and configuring
the system clock source. The Watchdog Timer is enabled with the system clock divided by 12 as its clock
source (Section “18.3. Watchdog Timer Mode” on page 212 details the use of the Watchdog Timer).
Program execution begins at location 0x0000.
VDD
Power On
Reset
Supply
Monitor
+
'0' /RST
Comparator 0 - Enable (wired-OR)
Px.x
+
-
Px.x C0RSEF
Missing
Clock
Reset
Detector Funnel
(one-
shot) PCA
EN
WDT (Software Reset)
SWRSF
EN Errant
FLASH
Enable
Enable
WDT
MCD
Operation
System
Clock
CIP-51
Microcontroller System Reset
Core
Extended Interrupt
Handler
Note: The maximum VDD ramp time is 1 ms; slower ramp times may cause the device to be released from
reset before VDD reaches the VRST level.
On exit from a power-on reset, the PORSF flag (RSTSRC.1) is set by hardware to logic 1. When PORSF is
set, 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 content of internal data mem-
ory should be assumed to be undefined after a power-on reset. The VDD monitor is disabled following a
power-on reset.
volts
VDD
2.70 VRST
2.55
2.0
D
VD
1.0
/RST
Logic HIGH
TPORDelay
Logic LOW
VDD
Power-On Monitor
Reset Reset
any other reset source. For example, if the VDD monitor is enabled and a software reset is performed, the
VDD monitor will still be enabled after the reset.
Important Note: The VDD monitor must be enabled before it is selected as a reset source. Selecting the
VDD monitor as a reset source before it is enabled and stabilized may cause a system reset. The proce-
dure for configuring the VDD monitor as a reset source is shown below:
See Figure 9.2 for VDD monitor timing; note that the reset delay is not incurred after a VDD monitor reset.
See Table 9.1 for complete electrical characteristics of the VDD monitor.
• A Flash write or erase is attempted above user code space. This occurs when PSWE is set to ‘1’ and a
MOVX write operation targets an address above address 0x3DFF for C8051F310/1 or 0x1FFF for
C8051F312/3/4/5.
• A Flash read is attempted above user code space. This occurs when a MOVC operation targets an
address above address 0x3DFF for C8051F310/1 or 0x1FFF for C8051F312/3/4/5.
• A Program read is attempted above user code space. This occurs when user code attempts to branch
to an address above 0x3DFF for C8051F310/1 or 0x1FFF for C8051F312/3/4/5.
• A Flash read, write or erase attempt is restricted due to a Flash security setting (see Section
“10.3. Security Options” on page 113).
The FERROR bit (RSTSRC.6) is set following a Flash error reset. The state of the RST pin is unaffected by
this reset.
Note: For bits that act as both reset source enables (on a write) and reset indicator flags (on a read),
read-modify-write instructions read and modify the source enable only. This applies to bits:
C0RSEF, SWRSF, MCDRSF, PORSF.
To ensure the integrity of Flash contents, it is strongly recommended that the on-chip VDD Monitor
be enabled in any system that includes code that writes and/or erases Flash memory from soft-
ware.
A write to Flash memory can clear bits to logic 0 but cannot set them; only an erase operation can set bits
to logic 1 in Flash. A byte location to be programmed should be erased before a new value is written.
The Flash memory is organized in 512-byte pages. The erase operation applies to an entire page (setting
all bytes in the page to 0xFF). To erase an entire 512-byte page, perform the following steps:
Steps 5–7 must be repeated for each byte to be written. After Flash writes are complete, PSWE should be
cleared so that MOVX instructions do not target program memory.
A Security Lock Byte located at the last byte of Flash user space offers protection of the Flash program
memory from access (reads, writes, or erases) by unprotected code or the C2 interface. The Flash security
mechanism allows the user to lock n 512-byte Flash pages, starting at page 0 (addresses 0x0000 to
0x01FF), where n is the 1’s complement number represented by the Security Lock Byte. Note that the
page containing the Flash Security Lock Byte is unlocked when no other Flash pages are locked
(all bits of the Lock Byte are ‘1’) and locked when any other Flash pages are locked (any bit of the
Lock Byte is ‘0’). See the example below.
C8051F310/1/6/7 C8051F312/3/4/5
Reserved Reserved
0x3E00 0x2000
Lock Byte 0x3DFF Lock Byte 0x1FFF
Locked when any
other FLASH pages 0x3DFE 0x1FFE
are locked
0x3C00 0x1E00
FLASH memory
organized in 512-byte
Unlocked FLASH Pages Unlocked FLASH Pages pages
Access limit set
according to the
FLASH security lock
byte
0x0000 0x0000
C2 Device Erase - Erases all Flash pages including the page containing the Lock Byte.
Flash Error Reset - Not permitted; Causes Flash Error Device Reset (FERROR bit in RSTSRC is '1' after
reset).
- All prohibited operations that are performed via the C2 interface are ignored (do not cause device reset).
- Locking any Flash page also locks the page containing the Lock Byte.
- Once written to, the Lock Byte cannot be modified except by performing a C2 Device Erase.
- If user code writes to the Lock Byte, the Lock does not take effect until the next device reset.
The following guidelines are recommended for any system that contains routines which write or erase
Flash from code.
Additional Flash recommendations and example code can be found in AN201, "Writing to Flash from Firm-
ware", available from the Silicon Laboratories web site.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - - - - PSEE PSWE 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x8F
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:
0xB7
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
FOSE Reserved Reserved Reserved Reserved Reserved Reserved Reserved 10000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xB6
NOTES:
For a 16-bit MOVX operation (@DPTR), the upper 6-bits of the 16-bit external data memory address word
are "don't cares.” As a result, the 1024 byte RAM is mapped modulo style over the entire 64 k external
data memory address range. For example, the XRAM byte at address 0x0000 is shadowed at addresses
0x0400, 0x0800, 0x0C00, 0x1000, etc. This is a useful feature when performing a linear memory fill, as the
address pointer doesn't have to be reset when reaching the RAM block boundary.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
PGSEL 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0xAA
For Example: If EMI0CN = 0x01, addresses 0x0100 through 0x01FF will be accessed.
NOTES:
12. Oscillators
C8051F31x 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 12.1. The system clock can be sourced by the external oscillator circuit, the internal oscil-
lator, or a scaled version of the internal oscillator. The internal oscillator's electrical specifications are given
in Table 12.1 on page 123.
IOSCEN
CLKSL0
IFRDY
IFCN1
IFCN0
Option 3
XTAL2
Option 4 EN
XTAL2 Programmable n
Internal Clock
Generator
SYSCLK
Option 2
Option 1
VDD XTAL1
Input
10MΩ OSC
Circuit
XTAL2
XTAL2
XOSCMD2
XOSCMD1
XOSCMD0
XTLVLD
XFCN2
XFCN1
XFCN0
OSCXCN
Electrical specifications for the precision internal oscillator are given in Table 12.1 on page 123. 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. The divide value defaults to 8 following a reset.
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:
0xB3
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
Reserved Reserved Reserved Reserved Reserved Reserved Reserved CLKSL0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xA9
Important Note on External Oscillator Usage: Port pins must be configured when using the external
oscillator circuit. When the external oscillator drive circuit is enabled in crystal/resonator mode, Port pins
P0.2 and P0.3 are used as XTAL1 and XTAL2 respectively. When the external oscillator drive circuit is
enabled in capacitor, RC, or CMOS clock mode, Port pin P0.3 is used as XTAL2. The Port I/O Crossbar
should be configured to skip the Port pins used by the oscillator circuit; see Section “13.1. Priority Cross-
bar Decoder” on page 131 for Crossbar configuration. Additionally, when using the external oscillator cir-
cuit in crystal/resonator, capacitor, or RC mode, the associated Port pins should be configured as analog
inputs. In CMOS clock mode, the associated pin should be configured as a digital input. See Section
“13.2. Port I/O Initialization” on page 133 for details on Port input mode selection.
When the crystal oscillator is first enabled, the oscillator amplitude detection circuit requires a settling time
to achieve proper bias. Introducing a delay of 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 rec-
ommended procedure is:
Step 1. Force the XTAL1 and XTAL2 pins low by writing 0s to the port latch.
Step 2. Configure XTAL1 and XTAL2 as analog inputs.
Step 3. Enable the external oscillator.
Step 4. Wait at least 1 ms.
Step 5. Poll for XTLVLD => '1'.
Step 6. Switch the system clock to the external oscillator.
Note: Tuning-fork crystals may require additional settling time before XTLVLD returns a valid result.
The capacitors shown in the external crystal configuration provide the load capacitance required by the
crystal for correct oscillation. These capacitors are "in series" as seen by the crystal and "in parallel" with
the stray capacitance of the XTAL1 and XTAL2 pins.
Note: The load capacitance depends upon the crystal and the manufacturer. Please refer to the crystal
data sheet when completing these calculations.
For example, a tuning-fork crystal of 32.768 kHz with a recommended load capacitance of 12.5 pF should
use the configuration shown in Figure 12.1, Option 1. The total value of the capacitors and the stray capac-
itance of the XTAL pins should equal 25 pF. With a stray capacitance of 3 pF per pin, the 22 pF capacitors
yield an equivalent capacitance of 12.5 pF across the crystal, as shown in Figure 12.2.
22 pF
XTAL1
32.768 kHz 10 MΩ
XTAL2
22 pF
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.
Referring to the table in SFR Definition 12.4, the required XFCN setting is 010b.
f = KF / ( C x VDD ) = KF / ( 50 x 3 ) MHz
f = KF / 150 MHz
If a frequency of roughly 150 kHz is desired, select the K Factor from the table in SFR Definition 12.4 as
KF = 22:
NOTES:
The Crossbar assigns the selected internal digital resources to the I/O pins based on the Priority Decoder
(Figure 13.3 and Figure 13.4). The registers XBR0 and XBR1, defined in SFR Definition 13.1 and SFR
Definition 13.2, are used to select internal digital functions.
All Port I/Os are 5 V tolerant (refer to Figure 13.2 for the Port cell circuit). The Port I/O cells are configured
as either push-pull or open-drain in the Port Output Mode registers (PnMDOUT, where n = 0,1,2,3). Com-
plete Electrical Specifications for Port I/O are given in Table 13.1 on page 143.
Priority
Decoder
Highest 2
UART
Priority
P0 P0.0
4 8
SPI I/O
Cells P0.7
2
(Internal Digital Signals)
SMBus
P1 P1.0
Digital 8
CP0 2 I/O
Crossbar Cells
Outputs P1.7
CP1 2
Outputs P2 P2.0
4 8
SYSCLK I/O
Cells P2.7
4
6
PCA
P3 P3.0
5
Lowest 2 I/O
T0, T1 Cells P3.4
Priority
Notes:
8 1. P3.1-P3.4 only available on the
P0 C8051F310/2/4
(P0.0-P0.7)
2. P1.6,P1.7,P2.6,P2.7 only available
on the C8051F310/1/2/3/4/5
8
(Port Latches)
P1 (P1.0-P1.7)
(P2.0-P2.3)
P2 4
(P2.4-P2.7)
5
P3 (P3.0-P3.4)
/WEAK-PULLUP
/PORT-OUTENABLE
(WEAK)
PORT
PAD
PORT-OUTPUT
GND
Analog Select
ANALOG INPUT
PORT-INPUT
Important Note on Crossbar Configuration: If a Port pin is claimed by a peripheral without use of the
Crossbar, its corresponding PnSKIP bit should be set. This applies to P0.0 if VREF is used, P0.3 and/or
P0.2 if the external oscillator circuit is enabled, P0.6 if the ADC is configured to use the external conversion
start signal (CNVSTR), and any selected ADC or Comparator inputs. The Crossbar skips selected pins as
if they were already assigned, and moves to the next unassigned pin. Figure 13.3 shows the Crossbar
Decoder priority with no Port pins skipped (P0SKIP, P1SKIP, P2SKIP = 0x00); Figure 13.4 shows the
Crossbar Decoder priority with the XTAL1 (P0.2) and XTAL2 (P0.3) pins skipped (P0SKIP = 0x0C to skip
P0.2 and P0.3 for XTAL use).
P0 P1 P2
CNVSTR
XTAL1
XTAL2
VREF
SF Signals
PIN I/O 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
TX0
RX0
SCK
MISO
MOSI
NSS*
SDA
SCL
CP0
CP0A Signals Unavailable
CP1
CP1A
SYSCLK
CEX0
CEX1
CEX2
CEX3
CEX4
ECI
T0
T1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
P0SKIP[0:7] P1SKIP[0:7] P2SKIP[0:3]
P0 P1 P2
CNVSTR
XTAL1
XTAL2
VREF
SF Signals
PIN I/O 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
TX0
RX0
SCK
MISO
MOSI
NSS*
SDA
SCL
CP0
CP0A
Signals Unavailable
CP1
CP1A
SYSCLK
CEX0
CEX1
CEX2
CEX3
CEX4
ECI
T0
T1
0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
P0SKIP[0:7] P1SKIP[0:7] P2SKIP[0:3]
Registers XBR0 and XBR1 are used to assign the digital I/O resources to the physical I/O Port pins. Note
that when the SMBus is selected, the Crossbar assigns both pins associated with the SMBus (SDA and
SCL); when the UART is selected, the Crossbar assigns both pins associated with the UART (TX and RX).
UART0 pin assignments are fixed for bootloading purposes: UART TX0 is always assigned to P0.4; UART
RX0 is always assigned to P0.5. Standard Port I/Os appear contiguously after the prioritized functions
have been assigned.
Important Note: The SPI can be operated in either 3-wire or 4-wire modes, pending the state of the
NSSMD1-NSSMD0 bits in register SPI0CN. According to the SPI mode, the NSS signal may or may not be
routed to a Port pin.
Step 1. Select the input mode (analog or digital) for all Port pins, using the Port Input Mode
register (PnMDIN).
Step 2. Select the output mode (open-drain or push-pull) for all Port pins, using the Port Output
Mode register (PnMDOUT).
Step 3. Select any pins to be skipped by the I/O Crossbar using the Port Skip registers (PnSKIP).
Step 4. Assign Port pins to desired peripherals.
Step 5. Enable the Crossbar (XBARE = ‘1’).
All Port pins must be configured as either analog or digital inputs. Any pins to be used as Comparator or
ADC inputs should be configured as an analog inputs. When a pin is configured as an analog input, its
weak pullup, digital driver, and digital receiver are disabled. This process saves power and reduces noise
on the analog input. Pins configured as digital inputs may still be used by analog peripherals; however this
practice is not recommended.
Additionally, all analog input pins should be configured to be skipped by the Crossbar (accomplished by
setting the associated bits in PnSKIP). Port input mode is set in the PnMDIN register, where a ‘1’ indicates
a digital input, and a ‘0’ indicates an analog input. All pins default to digital inputs on reset. See SFR Defini-
tion 13.4 for the PnMDIN register details.
The output driver characteristics of the I/O pins are defined using the Port Output Mode registers (PnMD-
OUT). Each Port Output driver can be configured as either open drain or push-pull. This selection is
required even for the digital resources selected in the XBRn registers, and is not automatic. The only
exception to this is the SMBus (SDA, SCL) pins, which are configured as open-drain regardless of the
PnMDOUT settings. When the WEAKPUD bit in XBR1 is ‘0’, a weak pullup is enabled for all Port I/O con-
figured as open-drain. WEAKPUD does not affect the push-pull Port I/O. Furthermore, the weak pullup is
turned off on an output that is driving a ‘0’ to avoid unnecessary power dissipation.
Registers XBR0 and XBR1 must be loaded with the appropriate values to select the digital I/O functions
required by the design. Setting the XBARE bit in XBR1 to ‘1’ enables the Crossbar. Until the Crossbar is
enabled, the external pins remain as standard Port I/O (in input mode), regardless of the XBRn Register
settings. For given XBRn Register settings, one can determine the I/O pin-out using the Priority Decode
Table; as an alternative, the Configuration Wizard utility of the Silicon Labs IDE software will determine the
Port I/O pin-assignments based on the XBRn Register settings.
The Crossbar must be enabled to use Port pins as standard Port I/O in output mode. Port output
drivers are disabled while the Crossbar is disabled.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CP1AE CP1E CP0AE CP0E SYSCKE SMB0E SPI0E URT0E 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xE1
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
WEAKPUD XBARE T1E T0E ECIE PCA0ME 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xE2
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0x80
Bits7–0: P0.[7:0]
Write - Output appears on I/O pins per Crossbar Registers.
0: Logic Low Output.
1: Logic High Output (high impedance if corresponding P0MDOUT.n bit = 0).
Read - Always reads ‘1’ if selected as analog input in register P0MDIN. Directly reads Port
pin when configured as digital input.
0: P0.n pin is logic low.
1: P0.n pin is logic high.
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:
0xF1
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
Bits7–0: Output Configuration Bits for P0.7–P0.0 (respectively): ignored if corresponding bit in regis-
ter P0MDIN is logic 0.
0: Corresponding P0.n Output is open-drain.
1: Corresponding P0.n Output is push-pull.
Note: When SDA and SCL appear on any of the Port I/O, each are open-drain regardless of the value of
P0MDOUT.
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:
0xD4
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0x90
Bits7–0: P1.[7:0]
Write - Output appears on I/O pins per Crossbar Registers.
0: Logic Low Output.
1: Logic High Output (high impedance if corresponding P1MDOUT.n bit = 0).
Read - Always reads ‘1’ if selected as analog input in register P1MDIN. Directly reads Port
pin when configured as digital input.
0: P1.n pin is logic low.
1: P1.n pin is logic high.
Note: Only P1.0–P1.5 are associated with Port pins on the C8051F316/7 devices.
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:
0xF2
Note: Only P1.0–P1.5 are associated with Port pins on the C8051F316/7 devices.
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
Bits7–0: Output Configuration Bits for P1.7-P1.0 (respectively): ignored if corresponding bit in regis-
ter P1MDIN is logic 0.
0: Corresponding P1.n Output is open-drain.
1: Corresponding P1.n Output is push-pull.
Note: Only P1.0–P1.5 are associated with Port pins on the C8051F316/7 devices.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
‘F310/1/2/3/4/5:
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 00000000
‘F316/7:
11000000
SFR Address:
0xD5
Note: Only P1.0–P1.5 are associated with Port pins on the C8051F316/7 devices. Hence, in C8051F316/7
devices, user code writing to this SFR should always set P1SKIP[7:6] = 11b so that those two pins are
skipped by the crossbar decoder.
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xA0
Bits7–0: P2.[7:0]
Write - Output appears on I/O pins per Crossbar Registers.
0: Logic Low Output.
1: Logic High Output (high impedance if corresponding P2MDOUT.n bit = 0).
Read - Always reads ‘1’ if selected as analog input in register P2MDIN. Directly reads Port
pin when configured as digital input.
0: P2.n pin is logic low.
1: P2.n pin is logic high.
Note: Only P2.0–P2.5 are associated with Port pins on the C8051F316/7 devices.
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:
0xF3
Note: Only P2.0–P2.5 are associated with Port pins on the C8051F316/7 devices.
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
Bits7–0: Output Configuration Bits for P2.7–P2.0 (respectively): ignored if corresponding bit in regis-
ter P2MDIN is logic 0.
0: Corresponding P2.n Output is open-drain.
1: Corresponding P2.n Output is push-pull.
Note: Only P2.0–P2.5 are associated with Port pins on the C8051F316/7 devices.
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:
0xD6
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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xB0
Bits7–0: P3.[7:0]
Write - Output appears on I/O pins.
0: Logic Low Output.
1: Logic High Output (high impedance if corresponding P3MDOUT.n bit = 0).
Read - Always reads ‘1’ if selected as analog input in register P3MDIN. Directly reads Port
pin when configured as digital input.
0: P3.n pin is logic low.
1: P3.n pin is logic high.
Note: Only P3.0–P3.4 are associated with Port pins on C8051F310/2/4 devices; Only P3.0 is associated with a
Port pin on C8051F311/3/5/6/7 devices.
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:
0xF4
Note: Only P3.0–P3.4 are associated with Port pins on C8051F310/2/4 devices; Only P3.0 is associated with a
Port pin on C8051F311/3/5/6/7 devices.
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
Note: Only P3.0–P3.4 are associated with Port pins on C8051F310/2/4 devices; Only P3.0 is associated with a
Port pin on C8051F311/3/5/6/7 devices.
NOTES:
14. SMBus
The SMBus I/O interface is a two-wire, bi-directional serial bus. The SMBus is compliant with the System
Management Bus Specification, version 1.1, and compatible with the I2C serial bus. Reads and writes to
the interface by the system controller are byte oriented with the SMBus interface autonomously controlling
the serial transfer of the data. Data can be transferred at up to 1/10th of the system clock as a master or
slave (this can be faster than allowed by the SMBus specification, depending on the system clock used). A
method of extending the clock-low duration is available to accommodate devices with different speed
capabilities on the same bus.
The SMBus interface may operate as a master and/or slave, and may function on a bus with multiple mas-
ters. The SMBus provides control of SDA (serial data), SCL (serial clock) generation and synchronization,
arbitration logic, and START/STOP control and generation. Three SFRs are associated with the SMBus:
SMB0CF configures the SMBus; SMB0CN controls the status of the SMBus; and SMB0DAT is the data
register, used for both transmitting and receiving SMBus data and slave addresses.
SMB0CN SMB0CF
MT S S A A A S E I B E S S S S
A X T T CRC I N N U XMMMM
SMAOK B K S H S T B B B B
T O R L M Y H T F CC
E D QO B OOT S S
R E S L E E 1 0
T D
00 T0 Overflow
01 T1 Overflow
10 TMR2H Overflow
11 TMR2L Overflow
SCL
SMBUS CONTROL LOGIC FILTER
Arbitration
Interrupt SCL Synchronization SCL
Request N C
SCL Generation (Master Mode) Control R
SDA Control
Data Path SDA O
IRQ Generation
Control Control S
S Port I/O
B
A
R
SMB0DAT
SDA
7 6 5 4 3 2 1 0 FILTER
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 14.3). If the receiving device does not ACK, the transmitting device will read a NACK (not acknowl-
edge), which is a high SDA during a high SCL.
The direction bit (R/W) occupies the least-significant bit position of the address byte. 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 14.3 illustrates a typical
SMBus transaction.
SCL
SDA
SLA6 SLA5-0 R/W D7 D6-0
14.3.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 “14.3.4. SCL High (SMBus Free) Timeout”
on page 148). In the event that two or more devices attempt to begin a transfer at the same time, an arbi-
tration scheme is employed to force one master to give up the bus. The master devices continue transmit-
ting 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 lose the arbitration. The win-
ning master continues its transmission without interruption; the losing master becomes a slave and
receives the rest of the transfer if addressed. This arbitration scheme is non-destructive: one device
always wins, and no data is lost.
When the SMBTOE bit in SMB0CF is set, Timer 3 is used to detect SCL low timeouts. Timer 3 is forced to
reload when SCL is high, and allowed to count when SCL is low. With Timer 3 enabled and configured to
overflow after 25 ms (and SMBTOE set), the Timer 3 interrupt service routine can be used to reset (disable
and re-enable) the SMBus in the event of an SCL low timeout.
SMBus interrupts are generated for each data byte or slave address that is transferred. When transmitting,
this interrupt is generated after the ACK cycle so that software may read the received ACK value; when
receiving data, this interrupt is generated before the ACK cycle so that software may define the outgoing
ACK value. See Section “14.5. SMBus Transfer Modes” on page 157 for more details on transmission
sequences.
Interrupts are also generated to indicate the beginning of a transfer when a master (START generated), or
the end of a transfer when a slave (STOP detected). Software should read the SMB0CN (SMBus Control
register) to find the cause of the SMBus interrupt. The SMB0CN register is described in Section
“14.4.2. SMB0CN Control Register” on page 153; Table 14.4 provides a quick SMB0CN decoding refer-
ence.
These options are selected in the SMB0CF register, as described in Section “14.4.1. SMBus Configura-
tion Register” on page 150.
The SMBCS1-0 bits select the SMBus clock source, which is used only when operating as a master or
when the Free Timeout detection is enabled. When operating as a master, overflows from the selected
source determine the absolute minimum SCL low and high times as defined in Equation 14.1. Note that the
selected clock source may be shared by other peripherals so long as the timer is left running at all times.
For example, Timer 1 overflows may generate the SMBus and UART baud rates simultaneously. Timer
configuration is covered in Section “17. Timers” on page 187.
1
T HighMin = T LowMin = ----------------------------------------------
f ClockSourceOverflow
The selected clock source should be configured to establish the minimum SCL High and Low times as per
Equation 14.1. When the interface is operating as a master (and SCL is not driven or extended by any
other devices on the bus), the typical SMBus bit rate is approximated by Equation 14.2.
Figure 14.4 shows the typical SCL generation described by Equation 14.2. Notice that THIGH is typically
twice as large as TLOW. The actual SCL output may vary due to other devices on the bus (SCL may be
extended low by slower slave devices, or driven low by contending master devices). The bit rate when
operating as a master will never exceed the limits defined by equation Equation 14.1.
Timer Source
Overflows
SCL
Setting the EXTHOLD bit extends the minimum setup and hold times for the SDA line. The minimum SDA
setup time defines the absolute minimum time that SDA is stable before SCL transitions from low-to-high.
The minimum SDA hold time defines the absolute minimum time that the current SDA value remains stable
after SCL transitions from high-to-low. EXTHOLD should be set so that the minimum setup and hold times
meet the SMBus Specification requirements of 250 ns and 300 ns, respectively. Table 14.2 shows the min-
imum setup and hold times for the two EXTHOLD settings. Setup and hold time extensions are typically
necessary when SYSCLK is above 10 MHz.
With the SMBTOE bit set, Timer 3 should be configured to overflow after 25 ms in order to detect SCL low
timeouts (see Section “14.3.3. SCL Low Timeout” on page 148). The SMBus interface will force Timer 3
to reload while SCL is high, and allow Timer 3 to count when SCL is low. The Timer 3 interrupt service rou-
tine should be used to reset SMBus communication by disabling and re-enabling the SMBus.
SMBus Free Timeout detection can be enabled by setting the SMBFTE bit. When this bit is set, the bus will
be considered free if SDA and SCL remain high for more than 10 SMBus clock source periods (see
Figure 14.4). When a Free Timeout is detected, the interface will respond as if a STOP was detected (an
interrupt will be generated, and STO will be set).
STA and STO indicate that a START and/or STOP has been detected or generated since the last SMBus
interrupt. STA and STO are also used to generate START and STOP conditions when operating as a mas-
ter. Writing a ‘1’ to STA will cause the SMBus interface to enter Master Mode and generate a START when
the bus becomes free (STA is not cleared by hardware after the START is generated). Writing a ‘1’ to STO
while in Master Mode will cause the interface to generate a STOP and end the current transfer after the
next ACK cycle. If STO and STA are both set (while in Master Mode), a STOP followed by a START will be
generated.
As a receiver, writing the ACK bit defines the outgoing ACK value; as a transmitter, reading the ACK bit
indicates the value received on the last ACK cycle. ACKRQ is set each time a byte is received, indicating
that an outgoing ACK value is needed. When ACKRQ is set, software should write the desired outgoing
value to the ACK bit before clearing SI. A NACK will be generated if software does not write the ACK bit
before clearing SI. SDA will reflect the defined ACK value immediately following a write to the ACK bit;
however SCL will remain low until SI is cleared. If a received slave address is not acknowledged, further
slave events will be ignored until the next START is detected.
The ARBLOST bit indicates that the interface has lost an arbitration. This may occur anytime the interface
is transmitting (master or slave). A lost arbitration while operating as a slave indicates a bus error condi-
tion. ARBLOST is cleared by hardware each time SI is cleared.
The SI bit (SMBus Interrupt Flag) is set at the beginning and end of each transfer, after each byte frame, or
when an arbitration is lost; see Table 14.3 for more details.
Important Note About the SI Bit: The SMBus interface is stalled while SI is set; thus SCL is held low, and
the bus is stalled until software clears SI.
Table 14.3 lists all sources for hardware changes to the SMB0CN bits. Refer to Table 14.4 for SMBus sta-
tus decoding using the SMB0CN register.
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. SMB0DAT always contains the last data byte present on the bus. In the event of lost arbi-
tration, the transition from master transmitter to slave receiver is made with the correct data or address 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
Interrupt
Interrupt
ARBLOST
ACK
ACK
STO
STA
A master START was Load slave address + R/W into
1110 0 0 X 0 0 X
generated. SMB0DAT.
A master data or address byte Set STA to restart transfer. 1 0 X
0 0 0 was transmitted; NACK
Abort transfer. 0 1 X
Master Transmitter
received.
Load next data byte into
0 0 X
SMB0DAT.
End transfer with STOP. 0 1 X
1100
A master data or address byte End transfer with STOP and start
1 1 X
0 0 1 was transmitted; ACK another transfer.
received. Send repeated START. 1 0 X
Switch to Master Receiver Mode
(clear SI without writing new data 0 0 X
to SMB0DAT).
Acknowledge received byte; Read
0 0 1
SMB0DAT.
Send NACK to indicate last byte,
0 1 0
and send STOP.
Send NACK to indicate last byte,
and send STOP followed by 1 1 0
Master Receiver
START.
Send ACK followed by repeated
A master data byte was 1 0 1
1000 1 0 X START.
received; ACK requested.
Send NACK to indicate last byte,
1 0 0
and send repeated START.
Send ACK and switch to Master
Transmitter Mode (write to 0 0 1
SMB0DAT before clearing SI).
Send NACK and switch to Master
Transmitter Mode (write to 0 0 0
SMB0DAT before clearing SI).
ARBLOST
Current SMbus State Typical Response Options
ACKRQ
Vector
Status
ACK
ACK
STO
STA
A slave byte was transmitted; No action required (expecting
0 0 0 0 0 X
NACK received. STOP condition).
Slave Transmitter
0010 0 1 X
ing a repeated START. Reschedule failed transfer. 1 0 X
Lost arbitration while attempt- No action required (transfer com-
1 1 X 0 0 0
ing a STOP. plete/aborted).
A STOP was detected while No action required (transfer com-
0001 0 0 X 0 0 X
an addressed slave receiver. plete).
Lost arbitration due to a Abort transfer. 0 0 X
0 1 X
detected STOP. Reschedule failed transfer. 1 0 X
Acknowledge received byte; Read
0 0 1
A slave byte was received; SMB0DAT.
1 0 X
ACK requested. Do not acknowledge received
0000 0 0 0
byte.
Lost arbitration while transmit- Abort failed transfer. 0 0 0
1 1 X
ting a data byte as master. Reschedule failed transfer. 1 0 0
15. UART0
UART0 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 “15.1. Enhanced Baud Rate Generation” on page 164). Received data buffering allows
UART0 to start reception of a second incoming data byte before software has finished reading the previous
data byte.
UART0 has two associated SFRs: Serial Control Register 0 (SCON0) and Serial Data Buffer 0 (SBUF0).
The single SBUF0 location provides access to both transmit and receive registers. Writes to SBUF0
always access the Transmit register. Reads of SBUF0 always access the buffered Receive register;
it is not possible to read data from the Transmit register.
With UART0 interrupts enabled, an interrupt is generated each time a transmit is completed (TI0 is set in
SCON0), or a data byte has been received (RI0 is set in SCON0). The UART0 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 UART0 interrupt (transmit complete or receive
complete).
SFR Bus
Write to
SBUF
TB8
SET
SBUF
D Q (TX Shift)
TX
CLR
Crossbar
Zero Detector
SCON
TI
UART Baud Serial
SMODE
RB8
TB8
Interrupt
RI
TI
RI
Rx IRQ
Rx Clock
Rx Control
Load
Start
Shift 0x1FF RB8 SBUF
Load SBUF
SBUF
(RX Latch)
Read
SBUF
SFR Bus RX
Crossbar
Timer 1 UART
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 “17.1.3. Mode 2: 8-bit
Counter/Timer with Auto-Reload” on page 189). The Timer 1 reload value should be set so that over-
flows will occur at two times the desired UART baud rate frequency. Note that Timer 1 may be clocked by
one of six sources: SYSCLK, SYSCLK / 4, SYSCLK / 12, SYSCLK / 48, the external oscillator clock / 8, or
an external input T1. For any given Timer 1 clock source, the UART0 baud rate is determined by
Equation 15.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 SBUF0 register. The TI0 Transmit Inter-
rupt Flag (SCON0.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 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 MCE0 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 SBUF0 receive register and the following overrun data bits
are lost.
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 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 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 ‘1’. After the stop bit
is received, the data byte will be loaded into the SBUF0 receive register if the following conditions are met:
(1) RI0 must be logic 0, and (2) if MCE0 is logic 1, the 9th bit must be logic 1 (when MCE0 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
SBUF0, the ninth bit is stored in RB80, and the RI0 flag is set to ‘1’. If the above conditions are not met,
SBUF0 and RB80 will not be loaded and the RI0 flag will not be set to ‘1’. A UART0 interrupt will occur if
enabled when either TI0 or RI0 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 MCE0 bit (SCON0.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 1 (RB80 = 1) signifying an address
byte has been received. In the UART interrupt handler, software will compare the received address with
the slave's own assigned 8-bit address. If the addresses match, the slave will clear its MCE0 bit to enable
interrupts on the reception of the following data byte(s). Slaves that weren't addressed leave their MCE0
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 resets its MCE0 bit to ignore all transmis-
sions 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
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
SFR Address: 0x99
X = Don’t care
*Note: SCA1–SCA0 and T1M bit definitions can be found in Section 17.1.
SFR Bus
RXOVRN
NSSMD1
NSSMD0
SLVSEL
SPIBSY
MSTEN
CKPHA
RXBMT
CKPOL
TXBMT
NSSIN
WCOL
SPIEN
MODF
SRMT
SCR7
SCR6
SCR5
SCR4
SCR3
SCR2
SCR1
SCR0
SYSCLK
Clock Divide SPIF
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
• 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.
• 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 mas-
ter devices can be used on the same SPI bus.
• NSSMD[1:0] = 1x: 4-Wire Master Mode: SPI0 operates in 4-wire mode, and NSS is enabled as an out-
put. 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 16.2, Figure 16.3, and Figure 16.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 “13. Port Input/Output” on page 129 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
NSSMD1 (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 16.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 16.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 16.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 16.3. 3-Wire Single Master and Slave Mode Connection Diagram
MISO Slave
MOSI Device
SCK
NSS
Figure 16.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 16.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 16.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 16.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 16.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: 0xA2
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: 0xA3
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:
17. Timers
Each MCU includes four counter/timers: two are 16-bit counter/timers compatible with those found in the
standard 8051, and two are 16-bit auto-reload timer for use with the ADC, SMBus, 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 2 and Timer 3 offer 16-bit and split 8-bit timer functionality with auto-reload.
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 from which
Timer 0 and/or Timer 1 may be clocked (See SFR Definition 17.3 for pre-scaled clock selection).
Timer 0/1 may then be configured to use this pre-scaled clock signal or the system clock. Timer 2 and
Timer 3 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 (T0 or T1). Events with a fre-
quency of up to one-fourth the system clock's frequency can be counted. The input signal need not be peri-
odic, but it should be held at a given 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. 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 interrupts are
enabled.
Setting the TR0 bit (TCON.4) enables the timer when either GATE0 (TMOD.3) is logic 0 or the input signal
/INT0 is active as defined by bit IN0PL in register IT01CF (see SFR Definition 8.11. “IT01CF: INT0/INT1
Configuration” on page 101). Setting GATE0 to ‘1’ allows the timer to be controlled by the external input
signal /INT0 (see Section “8.3.5. Interrupt Register Descriptions” on page 97), facilitating pulse width
measurements.
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; the /INT1 polarity is defined by bit IN1PL in register IT01CF (see
SFR Definition 8.11. “IT01CF: INT0/INT1 Configuration” on page 101).
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
IN0PL XOR
/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 active as defined by bit IN0PL in register IT01CF (see Section “8.3.2. External Interrupts” on page 95
for details on the external input signals /INT0 and /INT1).
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)
IN0PL XOR
/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 T T T TS S G C T T G C T T
3 3 2 2 1 0C C A / 1 1 A / 0 0
MMMMMM A A T T M M T T MM
E 1 1 0 E 0 1 0
HLH L 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
IN0PL XOR
/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
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0x88
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
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
T3MH T3ML T2MH T2ML T1M T0M SCA1 SCA0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x8E
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
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
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
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
17.2. Timer 2
Timer 2 is a 16-bit timer formed by two 8-bit SFRs: TMR2L (low byte) and TMR2H (high byte). Timer 2 may
operate in 16-bit auto-reload mode or (split) 8-bit auto-reload mode. The T2SPLIT bit (TMR2CN.3) defines
the Timer 2 operation mode.
Timer 2 may be clocked by the system clock, the system clock divided by 12, or the external oscillator
source divided by 8. The external clock mode is ideal for real-time clock (RTC) functionality, where the
internal oscillator drives the system clock while Timer 2 (and/or the PCA) is clocked by an external preci-
sion oscillator. Note that the external oscillator source divided by 8 is synchronized with the system clock.
CKCON
T T T T T T S S
3 3 2 2 1 0 C C
T2XCLK MMMMMM A A
H L H L 1 0
To ADC,
SYSCLK / 12 0 To SMBus
TMR2L SMBus
Overflow
0
TR2 TCLK
External Clock / 8 TMR2L TMR2H TF2H Interrupt
1 TF2L
TMR2CN
TF2LEN
SYSCLK 1
T2SPLIT
TR2
T2XCLK
TMR2RLL TMR2RLH
Reload
Each 8-bit timer may be configured to use SYSCLK, SYSCLK divided by 12, or the external oscillator clock
source divided by 8. The Timer 2 Clock Select bits (T2MH and T2ML in CKCON) select either SYSCLK or
the clock defined by the Timer 2 External Clock Select bit (T2XCLK in TMR2CN), as follows:
Note: External clock divided by 8 is synchronized with the system clock, and the external clock must be
less than or equal to the system clock to operate in this mode.
The TF2H bit is set when TMR2H overflows from 0xFF to 0x00; the TF2L bit is set when TMR2L overflows
from 0xFF to 0x00. When Timer 2 interrupts are enabled (IE.5), an interrupt is generated each time
TMR2H overflows. If Timer 2 interrupts are enabled and TF2LEN (TMR2CN.5) is set, an interrupt is gener-
ated each time either TMR2L or TMR2H overflows. When TF2LEN is enabled, software must check the
TF2H and TF2L flags to determine the source of the Timer 2 interrupt. The TF2H and TF2L interrupt flags
are not cleared by hardware and must be manually cleared by software.
CKCON
T T T T T T S S
T2XCLK
3 3 2 2 1 0 C C
MMMMMMA A Reload
H L H L 1 0 TMR2RLH To SMBus
SYSCLK / 12 0
0
External Clock / 8 1 TCLK
TR2 TMR2H TF2H Interrupt
TF2L
1 TF2LEN
TMR2CN
T2SPLIT
Reload TR2
TMR2RLL
SYSCLK T2XCLK
1
TCLK To ADC,
TMR2L
SMBus
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
TF2H TF2L TF2LEN - T2SPLIT TR2 - T2XCLK 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xC8
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:
0xCA
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:
0xCB
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:
0xCC
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:
0xCD
17.3. Timer 3
Timer 3 is a 16-bit timer formed by two 8-bit SFRs: TMR3L (low byte) and TMR3H (high byte). Timer 3 may
operate in 16-bit auto-reload mode or (split) 8-bit auto-reload mode. The T3SPLIT bit (TMR3CN.3) defines
the Timer 3 operation mode.
Timer 3 may be clocked by the system clock, the system clock divided by 12, or the external oscillator
source divided by 8. The external clock mode is ideal for real-time clock (RTC) functionality, where the
internal oscillator drives the system clock while Timer 3 (and/or the PCA) is clocked by an external preci-
sion oscillator. Note that the external oscillator source divided by 8 is synchronized with the system clock.
CKCON
T T T T T T S S
3 3 2 2 1 0 C C
T3XCLK MMMMMM A A
H L H L 1 0
SYSCLK / 12 0 To ADC
0
TR3 TCLK
External Clock / 8 TMR3L TMR3H TF3H Interrupt
1 TF3L
TMR3CN
TF3LEN
SYSCLK 1
T3SPLIT
TR3
T3XCLK
TMR3RLL TMR3RLH
Reload
Each 8-bit timer may be configured to use SYSCLK, SYSCLK divided by 12, or the external oscillator clock
source divided by 8. The Timer 3 Clock Select bits (T3MH and T3ML in CKCON) select either SYSCLK or
the clock defined by the Timer 3 External Clock Select bit (T3XCLK in TMR3CN), as follows:
Note: External clock divided by 8 is synchronized with the system clock, and the external clock must be
less than or equal to the system clock to operate in this mode.
The TF3H bit is set when TMR3H overflows from 0xFF to 0x00; the TF3L bit is set when TMR3L overflows
from 0xFF to 0x00. When Timer 3 interrupts are enabled, an interrupt is generated each time TMR3H over-
flows. If Timer 3 interrupts are enabled and TF3LEN (TMR3CN.5) is set, an interrupt is generated each
time either TMR3L or TMR3H overflows. When TF3LEN is enabled, software must check the TF3H and
TF3L flags to determine the source of the Timer 3 interrupt. The TF3H and TF3L interrupt flags are not
cleared by hardware and must be manually cleared by software.
CKCON
T T T T T T S S
T3XCLK
3 3 2 2 1 0 C C
MMMMMM A A Reload
H L H L 1 0 TMR3RLH
SYSCLK / 12 0
0
External Clock / 8 1 TCLK
TR3 TMR3H TF3H Interrupt
TF3L
1 TF3LEN
TMR3CN
T3SPLIT
Reload TR3
TMR3RLL
SYSCLK T3XCLK
1
TCLK TMR3L To ADC
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
TF3H TF3L TF3LEN - T3SPLIT TR3 - T3XCLK 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0x91
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:
0x92
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:
0x93
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:
0x94
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:
0x95
Important Note: The PCA Module 4 may be used as a watchdog timer (WDT), and is enabled in this mode
following a system reset. Access to certain PCA registers is restricted while WDT mode is enabled. See
Section 18.3 for details.
SYSCLK/12
SYSCLK/4
Timer 0 Overflow PCA
16-Bit Counter/Timer
ECI CLOCK
MUX
SYSCLK
External Clock/8
CEX1
CEX2
CEX3
CEX4
ECI
Crossbar
Port I/O
IDLE
PCA0MD PCA0CN
CWW C CCE CC C C C CC
I D D P PPC FR C C C CC
D T L S SSF F F F F F
L E C 2 1 0 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
Table 18.2 summarizes the bit settings in the PCA0CPMn registers used to select the PCA 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 and the EPCA0 bit to logic 1. See
Figure 18.3 for details on the PCA interrupt configuration.
(for n = 0 to 4)
PCA0CPMn PCA0CN PCA0MD
P E CCMT P E CC CCCCC C WW CCCE
WC A A AOWC FR CCCCC I DD PPPC
MOPP TGMC FFF FF DT L SSSF
1 MP N n n n F 4 3 2 1 0 LEC 2 1 0
6 n n n n K
n
PCA Counter/ 0
Timer Overflow 1
ECCF0
0 EPCA0 EA
PCA Module 0
(CCF0) 1 0 0 Interrupt
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
PCA Interrupt
PCA0CPMn
P ECCMT P E PCA0CN
WC A A AOWC CC CCCCC
MOPP TGMC FR CCCCC
1 MPN n n n F FF FFF
6 n n n n 4 3 2 1 0
n
x 0 x 0 0 x
(to CCFn)
PCA0CPLn PCA0CPHn
0
1
CEXn Capture
Port I/O Crossbar
0
1
PCA
Timebase
PCA0L PCA0H
Note: The CEXn input signal must remain 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
Write to
PCA0CPHn ENB PCA Interrupt
1
PCA0CPMn
P ECCMT P E PCA0CN
WC A A AOWC CC CCCCC
MOPP TGMC PCA0CPLn PCA0CPHn FR CCCCC
1 MP N n n n F FFFFF
6 n n n n 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
x 0 0 0 x
PCA Interrupt
PCA0CN
CC CCCCC
PCA0CPLn PCA0CPHn FR CCCCC
FFFFF
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
The lower byte of the capture/compare module is compared to the PCA 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. Fre-
quency Output Mode is enabled by setting the ECOMn, TOGn, and PWMn bits in the PCA0CPMn register.
Write to
PCA0CPLn 0
ENB
Reset
PCA0CPMn
Write to P ECCMT P E
PCA0CPHn ENB WC A A A OWC
PCA0CPLn 8-bit Adder PCA0CPHn
1 MOPP TGMC
1 MP N n n n F
Adder
6 nnn n Enable
n TOGn
x 0 0 0 x 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’.
Using Equation 18.2, the largest duty cycle is 100% (PCA0CPHn = 0), and the smallest duty cycle is
0.39% (PCA0CPHn = 0xFF). A 0% duty cycle may be generated by clearing the ECOMn bit to ‘0’.
Write to
PCA0CPLn 0
ENB PCA0CPHn
Reset
Write to
PCA0CPHn ENB
1
PCA0CPMn
P ECCMT P E
WC A A A OWC
PCA0CPLn
MOPP TGMC
1 MP N n n n F
6 n n n n
n
0 0 0 x 0 x
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’.
Using Equation 18.3, the largest duty cycle is 100% (PCA0CPn = 0), and the smallest duty cycle is
0.0015% (PCA0CPn = 0xFFFF). A 0% duty cycle may be generated by clearing the ECOMn bit to ‘0’.
Write to
PCA0CPLn 0
ENB
Reset
Write to
PCA0CPHn ENB
1
PCA0CPMn
P ECCMT P E
WC A A AOWC
PCA0CPHn PCA0CPLn
MOPP TGMC
1 MPN n n n F
6 n n n n
n
1 0 0 x 0 x
R CLR
Q
PCA Timebase
PCA0H PCA0L
Overflow
With the WDTE bit set in the PCA0MD register, Module 4 operates as a watchdog timer (WDT). The Mod-
ule 4 high byte is compared to the PCA counter high byte; the Module 4 low byte holds the offset to be
used when WDT updates are performed. The Watchdog Timer is enabled on reset. Writes to some
PCA registers are restricted while the Watchdog Timer is enabled.
While the WDT is enabled, writes to the CR bit will not change the PCA counter state; the counter will run
until the WDT is disabled. The PCA counter run control (CR) will read zero if the WDT is enabled but user
software has not enabled the PCA counter. If a match occurs between PCA0CPH4 and PCA0H while the
WDT is enabled, a reset will be generated. To prevent a WDT reset, the WDT may be updated with a write
of any value to PCA0CPH4. Upon a PCA0CPH4 write, PCA0H plus the offset held in PCA0CPL4 is loaded
into PCA0CPH4 (See Figure 18.10).
PCA0MD
CWW CCCE
I DD PPPC PCA0CPH4
DT L SSSF
L E C 2 1 0
K
8-bit Match
Reset
Enable Comparator
PCA0L Overflow
PCA0CPL4 8-bit Adder PCA0H
Adder
Write to Enable
PCA0CPH4
Note that the 8-bit offset held in PCA0CPH4 is compared to the upper byte of the 16-bit PCA counter. This
offset value is the number of PCA0L overflows before a reset. Up to 256 PCA clocks may pass before the
first PCA0L overflow occurs, depending on the value of the PCA0L when the update is performed. The
total offset is then given (in PCA clocks) by Equation 18.4, where PCA0L is the value of the PCA0L register
at the time of the update.
The WDT reset is generated when PCA0L overflows while there is a match between PCA0CPH4 and
PCA0H. Software may force a WDT reset by writing a ‘1’ to the CCF4 flag (PCA0CN.4) while the WDT is
enabled.
18.3.2. Watchdog Timer Usage
To configure the WDT, perform the following tasks:
The PCA clock source and Idle mode select cannot be changed while the WDT is enabled. The watchdog
timer is enabled by setting the WDTE or WDLCK bits in the PCA0MD register. When WDLCK is set, the
WDT cannot be disabled until the next system reset. If WDLCK is not set, the WDT is disabled by clearing
the WDTE bit.
The WDT is enabled following any reset. The PCA0 counter clock defaults to the system clock divided by
12, PCA0L defaults to 0x00, and PCA0CPL4 defaults to 0x00. Using Equation 18.4, this results in a WDT
timeout interval of 256 system clock cycles. Table 18.3 lists some example timeout intervals for typical sys-
tem clocks.
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CF CR CCF4 CCF3 CCF2 CCF1 CCF0 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
(bit addressable) 0xD8
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
CIDL WDTE WDLCK CPS2 CPS1 CPS0 ECF 01000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xD9
Note: When the WDTE bit is set to ‘1’, the PCA0MD register cannot be modified. To change the contents
of the PCA0MD register, the Watchdog Timer must first be disabled.
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 Address:
0xDA, 0xDB, 0xDC,
0xDD, 0xDE
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
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
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:
0xFB, 0xE9, 0xEB,
0xED, 0xFD
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:
0xFC, 0xEA,
0xEC,0xEE, 0xFE
NOTES:
C8051F310 CYG
T2ABGFAC F311
^ indicates REV A
0227 EP ABGFA
^ indicates REV A
On “REV B” and later devices, GPIO pins are tri-stated with weak pullups enabled during and after the
assertion phase of any reset.
On “REV B” and later devices, a VDD Monitor reset will pull the RST pin low for the duration of the brown-
out condition.
This behavior is not present on “REV B” and later devices. Software written for “REV A” devices will run on
“REV B” and later devices without modification.
20. C2 Interface
C8051F31x devices include an on-chip Silicon Labs 2-Wire (C2) debug interface to allow Flash program-
ming and in-system debugging with the production part installed in the end application. The C2 interface
uses a clock signal (C2CK) and a bi-directional C2 data signal (C2D) to transfer information between the
device and a host system. See the C2 Interface Specification for details on the C2 protocol.
Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Bits7–0: The C2ADD register is accessed via the C2 interface to select the target Data register for
C2 Data Read and Data Write commands.
Address Description
0x00 Selects the Device ID register for Data Read instructions
0x01 Selects the Revision ID register for Data Read instructions
Selects the C2 Flash Programming Control register for Data
0x02
Read/Write instructions
Selects the C2 Flash Programming Data register for Data
0xB4
Read/Write instructions
Reset Value
00001000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
This read-only register returns the 8-bit device ID: 0x08 (C8051F310/1/2/3/4/5/6/7).
Reset Value
Variable
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Reset Value
00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
Code Command
0x06 Flash Block Read
0x07 Flash Block Write
0x08 Flash Page Erase
0x03 Device Erase
C8051Fxxx
Output (c)
C2 Interface Master
1. The user input (b) cannot change state while the target device is halted.
2. The /RST pin on the target device is used as an input only.
NOTES:
CONTACT INFORMATION
Silicon Laboratories Inc.
4635 Boston Lane
Austin, TX 78735
Tel: 1+(512) 416-8500
Fax: 1+(512) 416-9669
Toll Free: 1+(877) 444-3032
Email: [email protected]
Internet: www.silabs.com
The information in this document is believed to be accurate in all respects at the time of publication but is subject to change
without notice. Silicon Laboratories assumes no responsibility for errors and omissions, and disclaims responsibility for any
consequences resulting from the use of information included herein. Additionally, Silicon Laboratories assumes no responsi-
bility for the functioning of undescribed features or parameters. Silicon Laboratories reserves the right to make changes with-
out further notice. Silicon Laboratories makes no warranty, representation or guarantee regarding the suitability of its products
for any particular purpose, nor does Silicon Laboratories assume any liability arising out of the application or use of any prod-
uct or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages.
Silicon Laboratories products are not designed, intended, or authorized for use in applications intended to support or sustain
life, or for any other application in which the failure of the Silicon Laboratories product could create a situation where personal
injury or death may occur. Should Buyer purchase or use Silicon Laboratories products for any such unintended or unautho-
rized application, Buyer shall indemnify and hold Silicon Laboratories harmless against all claims and damages.
Silicon Laboratories and Silicon Labs are trademarks of Silicon Laboratories Inc.
Other products or brandnames mentioned herein are trademarks or registered trademarks of their respective holders.