C8051F50x 51x-1397908
C8051F50x 51x-1397908
C8051F50x 51x-1397908
2 Rev. 1.4
C8051F50x/F51x
Table of Contents
1. System Overview ..................................................................................................... 16
2. Ordering Information ............................................................................................... 20
3. Pin Definitions.......................................................................................................... 23
4. Package Specifications ........................................................................................... 31
4.1. QFP-48 Package Specifications........................................................................ 31
4.2. QFN-48 Package Specifications........................................................................ 33
4.3. QFN-40 Package Specifications........................................................................ 35
4.4. QFP-32 Package Specifications........................................................................ 37
4.5. QFN-32 Package Specifications........................................................................ 39
5. Electrical Characteristics ........................................................................................ 41
5.1. Absolute Maximum Specifications..................................................................... 41
5.2. Electrical Characteristics ................................................................................... 42
6. 12-Bit ADC (ADC0) ................................................................................................... 53
6.1. Modes of Operation ........................................................................................... 54
6.1.1. Starting a Conversion................................................................................ 54
6.1.2. Tracking Modes......................................................................................... 54
6.1.3. Timing ....................................................................................................... 55
6.1.4. Burst Mode................................................................................................ 56
6.2. Output Code Formatting .................................................................................... 58
6.2.1. Settling Time Requirements...................................................................... 58
6.3. Selectable Gain ................................................................................................. 59
6.3.1. Calculating the Gain Value........................................................................ 59
6.3.2. Setting the Gain Value .............................................................................. 61
6.4. Programmable Window Detector....................................................................... 67
6.4.1. Window Detector In Single-Ended Mode .................................................. 69
6.5. ADC0 Analog Multiplexer .................................................................................. 71
7. Temperature Sensor ................................................................................................ 73
8. Voltage Reference.................................................................................................... 74
9. Comparators............................................................................................................. 76
9.1. Comparator Multiplexer ..................................................................................... 82
10. Voltage Regulator (REG0) ..................................................................................... 85
11. CIP-51 Microcontroller........................................................................................... 87
11.1. Performance .................................................................................................... 87
11.2. Instruction Set.................................................................................................. 89
11.2.1. Instruction and CPU Timing .................................................................... 89
11.3. CIP-51 Register Descriptions .......................................................................... 93
11.4. Serial Number Special Function Registers (SFRs) ......................................... 97
12. Memory Organization ............................................................................................ 98
12.1. Program Memory............................................................................................. 99
12.1.1. MOVX Instruction and Program Memory ................................................ 99
12.2. Data Memory ................................................................................................... 99
12.2.1. Internal RAM ........................................................................................... 99
12.2.1.1. General Purpose Registers .......................................................... 100
12.2.1.2. Bit Addressable Locations ............................................................ 100
Rev. 1.4 3
C8051F50x/F51x
4 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 5
C8051F50x/F51x
6 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 7
C8051F50x/F51x
List of Figures
Figure 1.1. C8051F500/1/4/5 Block Diagram .......................................................... 17
Figure 1.2. C8051F508/9-F510/1 Block Diagram .................................................... 18
Figure 1.3. C8051F502/3/6/7 Block Diagram .......................................................... 19
Figure 3.1. QFP-48 Pinout Diagram (Top View) ...................................................... 26
Figure 3.2. QFN-48 Pinout Diagram (Top View) ..................................................... 27
Figure 3.3. QFN-40 Pinout Diagram (Top View) ..................................................... 28
Figure 3.4. QFP-32 Pinout Diagram (Top View) ...................................................... 29
Figure 3.5. QFN-32 Pinout Diagram (Top View) ..................................................... 30
Figure 4.1. QFP-48 Package Drawing ..................................................................... 31
Figure 4.2. QFP-48 Landing Diagram ..................................................................... 32
Figure 4.3. QFN-48 Package Drawing .................................................................... 33
Figure 4.4. QFN-48 Landing Diagram ..................................................................... 34
Figure 4.5. Typical QFN-40 Package Drawing ........................................................ 35
Figure 4.6. QFN-40 Landing Diagram ..................................................................... 36
Figure 4.7. QFP-32 Package Drawing ..................................................................... 37
Figure 4.8. QFP-32 Package Drawing ..................................................................... 38
Figure 4.9. QFN-32 Package Drawing .................................................................... 39
Figure 4.10. QFN-32 Package Drawing .................................................................. 40
Figure 5.1. Minimum VDD Monitor Threshold vs. System Clock Frequency ........... 45
Figure 6.1. ADC0 Functional Block Diagram ........................................................... 53
Figure 6.2. ADC0 Tracking Modes .......................................................................... 55
Figure 6.3. 12-Bit ADC Tracking Mode Example ..................................................... 56
Figure 6.4. 12-Bit ADC Burst Mode Example With Repeat Count Set to 4 ............. 57
Figure 6.5. ADC0 Equivalent Input Circuit ............................................................... 59
Figure 6.6. ADC Window Compare Example: Right-Justified Data ......................... 70
Figure 6.7. ADC Window Compare Example: Left-Justified Data ........................... 70
Figure 6.8. ADC0 Multiplexer Block Diagram .......................................................... 71
Figure 7.1. Temperature Sensor Transfer Function ................................................ 73
Figure 8.1. Voltage Reference Functional Block Diagram ....................................... 74
Figure 9.1. Comparator Functional Block Diagram ................................................. 76
Figure 9.2. Comparator Hysteresis Plot .................................................................. 77
Figure 9.3. Comparator Input Multiplexer Block Diagram ........................................ 82
Figure 10.1. External Capacitors for Voltage Regulator Input/Output—
Regulator Enabled ............................................................................................. 85
Figure 10.2. External Capacitors for Voltage Regulator Input/Output—
Regulator Disabled ............................................................................................. 86
Figure 11.1. CIP-51 Block Diagram ......................................................................... 88
Figure 12.1. C8051F50x/F51x Memory Map ........................................................... 98
Figure 12.2. Flash Program Memory Map ............................................................... 99
Figure 13.1. SFR Page Stack ................................................................................ 102
Figure 13.2. SFR Page Stack While Using SFR Page 0x0 To Access SPI0DAT . 103
Figure 13.3. SFR Page Stack After CAN0 Interrupt Occurs .................................. 104
Figure 13.4. SFR Page Stack Upon PCA Interrupt Occurring During a CAN0 ISR 105
8 Rev. 1.4
C8051F50x/F51x
Figure 13.5. SFR Page Stack Upon Return From PCA Interrupt .......................... 106
Figure 13.6. SFR Page Stack Upon Return From CAN0 Interrupt ........................ 107
Figure 15.1. Flash Program Memory Map ............................................................. 132
Figure 17.1. Reset Sources ................................................................................... 142
Figure 17.2. Power-On and VDD Monitor Reset Timing ....................................... 143
Figure 18.1. Multiplexed Configuration Example ................................................... 154
Figure 18.2. Non-multiplexed Configuration Example ........................................... 155
Figure 18.3. EMIF Operating Modes ..................................................................... 156
Figure 18.4. Non-multiplexed 16-bit MOVX Timing ............................................... 159
Figure 18.5. Non-multiplexed 8-bit MOVX without Bank Select Timing ................ 160
Figure 18.6. Non-multiplexed 8-bit MOVX with Bank Select Timing ..................... 161
Figure 18.7. Multiplexed 16-bit MOVX Timing ....................................................... 162
Figure 18.8. Multiplexed 8-bit MOVX without Bank Select Timing ........................ 163
Figure 18.9. Multiplexed 8-bit MOVX with Bank Select Timing ............................. 164
Figure 19.1. Oscillator Options .............................................................................. 166
Figure 19.2. Example Clock Multiplier Output ....................................................... 171
Figure 19.3. External 32.768 kHz Quartz Crystal Oscillator Connection Diagram 176
Figure 20.1. Port I/O Functional Block Diagram .................................................... 178
Figure 20.2. Port I/O Cell Block Diagram .............................................................. 179
Figure 20.3. Peripheral Availability on Port I/O Pins .............................................. 182
Figure 20.4. Crossbar Priority Decoder in Example Configuration ........................ 183
Figure 21.1. LIN Block Diagram ............................................................................ 202
Figure 22.1. Typical CAN Bus Configuration ......................................................... 219
Figure 22.2. CAN Controller Diagram .................................................................... 220
Figure 22.3. Four segments of a CAN Bit .............................................................. 222
Figure 23.1. SMBus Block Diagram ...................................................................... 227
Figure 23.2. Typical SMBus Configuration ............................................................ 228
Figure 23.3. SMBus Transaction ........................................................................... 229
Figure 23.4. Typical SMBus SCL Generation ........................................................ 231
Figure 23.5. Typical Master Write Sequence ........................................................ 238
Figure 23.6. Typical Master Read Sequence ........................................................ 239
Figure 23.7. Typical Slave Write Sequence .......................................................... 240
Figure 23.8. Typical Slave Read Sequence .......................................................... 241
Figure 24.1. UART0 Block Diagram ...................................................................... 244
Figure 24.2. UART0 Timing Without Parity or Extra Bit ......................................... 246
Figure 24.3. UART0 Timing With Parity ................................................................ 246
Figure 24.4. UART0 Timing With Extra Bit ............................................................ 246
Figure 24.5. Typical UART Interconnect Diagram ................................................. 247
Figure 24.6. UART Multi-Processor Mode Interconnect Diagram ......................... 248
Figure 25.1. SPI Block Diagram ............................................................................ 253
Figure 25.2. Multiple-Master Mode Connection Diagram ...................................... 256
Figure 25.3. 3-Wire Single Master and 3-Wire Single Slave Mode Connection Diagram
256
Figure 25.4. 4-Wire Single Master Mode and 4-Wire Slave Mode Connection Diagram
256
Rev. 1.4 9
C8051F50x/F51x
10 Rev. 1.4
C8051F50x/F51x
List of Tables
Table 2.1. Product Selection Guide ......................................................................... 21
Table 2.2. Product Selection Guide (Not Recommended for New Designs) ........... 22
Table 3.1. Pin Definitions for the C8051F50x/F51x ................................................. 23
Table 4.1. QFP-48 Package Dimensions ................................................................ 31
Table 4.2. QFP-48 Landing Diagram Dimensions ................................................... 32
Table 4.3. QFN-48 Package Dimensions ................................................................ 33
Table 4.4. QFN-48 Landing Diagram Dimensions ................................................... 34
Table 4.5. QFN-40 Package Dimensions ................................................................ 35
Table 4.6. QFN-40 Landing Diagram Dimensions ................................................... 36
Table 4.7. QFP-32 Package Dimensions ................................................................ 37
Table 4.8. QFP-32 Landing Diagram Dimensions ................................................... 38
Table 4.9. QFN-32 Package Dimensions ................................................................ 39
Table 4.10. QFN-32 Landing Diagram Dimensions ................................................. 40
Table 5.1. Absolute Maximum Ratings .................................................................... 41
Table 5.2. Global Electrical Characteristics ............................................................. 42
Table 5.3. Port I/O DC Electrical Characteristics ..................................................... 46
Table 5.4. Reset Electrical Characteristics .............................................................. 47
Table 5.5. Flash Electrical Characteristics .............................................................. 47
Table 5.6. Internal High-Frequency Oscillator Electrical Characteristics ................. 48
Table 5.7. Clock Multiplier Electrical Specifications ................................................ 49
Table 5.8. Voltage Regulator Electrical Characteristics .......................................... 49
Table 5.9. ADC0 Electrical Characteristics .............................................................. 50
Table 5.10. Temperature Sensor Electrical Characteristics .................................... 51
Table 5.11. Voltage Reference Electrical Characteristics ....................................... 51
Table 5.12. Comparator 0 and Comparator 1 Electrical Characteristics ................. 52
Table 11.1. CIP-51 Instruction Set Summary (Prefetch-Enabled) ........................... 90
Table 13.1. Special Function Register (SFR) Memory Map for Pages 0x0 and 0xF ...
112
Table 13.2. Special Function Register (SFR) Memory Map for Page 0xC ............ 113
Table 13.3. Special Function Registers ................................................................. 114
Table 14.1. Interrupt Summary .............................................................................. 120
Table 15.1. Flash Security Summary .................................................................... 133
Table 18.1. EMIF Pinout (C8051F500/1/4/5) ......................................................... 150
Table 18.2. EMIF Pinout (C8051F508/9-F510/1) .................................................. 151
Table 18.3. AC Parameters for External Memory Interface ................................... 165
Table 20.1. Port I/O Assignment for Analog Functions ......................................... 180
Table 20.2. Port I/O Assignment for Digital Functions ........................................... 180
Table 20.3. Port I/O Assignment for External Digital Event Capture Functions .... 181
Table 21.1. Baud Rate Calculation Variable Ranges ............................................ 203
Rev. 1.4 11
C8051F50x/F51x
12 Rev. 1.4
C8051F50x/F51x
List of Registers
SFR Definition 6.4. ADC0CF: ADC0 Configuration ...................................................... 64
SFR Definition 6.5. ADC0H: ADC0 Data Word MSB .................................................... 65
SFR Definition 6.6. ADC0L: ADC0 Data Word LSB ...................................................... 65
SFR Definition 6.7. ADC0CN: ADC0 Control ................................................................ 66
SFR Definition 6.8. ADC0TK: ADC0 Tracking Mode Select ......................................... 67
SFR Definition 6.9. ADC0GTH: ADC0 Greater-Than Data High Byte .......................... 68
SFR Definition 6.10. ADC0GTL: ADC0 Greater-Than Data Low Byte .......................... 68
SFR Definition 6.11. ADC0LTH: ADC0 Less-Than Data High Byte .............................. 69
SFR Definition 6.12. ADC0LTL: ADC0 Less-Than Data Low Byte ............................... 69
SFR Definition 6.13. ADC0MX: ADC0 Channel Select ................................................. 72
SFR Definition 8.1. REF0CN: Reference Control ......................................................... 75
SFR Definition 9.1. CPT0CN: Comparator0 Control ..................................................... 78
SFR Definition 9.2. CPT0MD: Comparator0 Mode Selection ....................................... 79
SFR Definition 9.3. CPT1CN: Comparator1 Control ..................................................... 80
SFR Definition 9.4. CPT1MD: Comparator1 Mode Selection ....................................... 81
SFR Definition 9.5. CPT0MX: Comparator0 MUX Selection ........................................ 83
SFR Definition 9.6. CPT1MX: Comparator1 MUX Selection ........................................ 84
SFR Definition 10.1. REG0CN: Regulator Control ........................................................ 86
SFR Definition 11.1. DPL: Data Pointer Low Byte ........................................................ 94
SFR Definition 11.2. DPH: Data Pointer High Byte ....................................................... 94
SFR Definition 11.3. SP: Stack Pointer ......................................................................... 95
SFR Definition 11.4. ACC: Accumulator ....................................................................... 95
SFR Definition 11.5. B: B Register ................................................................................ 95
SFR Definition 11.6. PSW: Program Status Word ........................................................ 96
SFR Definition 11.7. SNn: Serial Number n .................................................................. 97
SFR Definition 13.1. SFR0CN: SFR Page Control ..................................................... 108
SFR Definition 13.2. SFRPAGE: SFR Page ............................................................... 109
SFR Definition 13.3. SFRNEXT: SFR Next ................................................................ 110
SFR Definition 13.4. SFRLAST: SFR Last .................................................................. 111
SFR Definition 14.1. IE: Interrupt Enable .................................................................... 122
SFR Definition 14.2. IP: Interrupt Priority .................................................................... 123
SFR Definition 14.3. EIE1: Extended Interrupt Enable 1 ............................................ 124
SFR Definition 14.4. EIP1: Extended Interrupt Priority 1 ............................................ 125
SFR Definition 14.5. EIE2: Extended Interrupt Enable 2 ............................................ 126
SFR Definition 14.6. EIP2: Extended Interrupt Priority Enabled 2 .............................. 127
SFR Definition 14.7. IT01CF: INT0/INT1 Configuration .............................................. 129
SFR Definition 15.1. PSCTL: Program Store R/W Control ......................................... 135
SFR Definition 15.2. FLKEY: Flash Lock and Key ...................................................... 136
SFR Definition 15.3. FLSCL: Flash Scale ................................................................... 137
SFR Definition 15.4. CCH0CN: Cache Control ........................................................... 138
SFR Definition 15.5. ONESHOT: Flash Oneshot Period ............................................ 138
SFR Definition 16.1. PCON: Power Control ................................................................ 141
SFR Definition 17.1. VDM0CN: VDD Monitor Control ................................................ 145
Rev. 1.4 13
C8051F50x/F51x
14 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 15
C8051F50x/F51x
1. System Overview
C8051F50x/F51x devices are fully integrated mixed-signal System-on-a-Chip MCUs. Highlighted features
are listed below. Refer to Table 2.1 for specific product feature selection and part ordering numbers.
High-speed pipelined 8051-compatible microcontroller core (up to 50 MIPS)
In-system, full-speed, non-intrusive debug interface (on-chip)
Controller Area Network (CAN 2.0B) Controller with 32 message objects, each with its own indentifier
mask (C8051F500/2/4/6/8-F510)
LIN 2.1 peripheral (fully backwards compatible, master and slave modes) (C8051F500/2/4/6/8-F510)
True 12-bit 200 ksps 32-channel single-ended ADC with analog multiplexer
Precision programmable 24 MHz internal oscillator that is within ±0.5% across the temperature range
and for VDD voltages greater than or equal to the on-chip voltage regulator minimum output at the low
setting. The oscillator is within +1.0% for VDD voltages below this minimum output setting.
On-chip Clock Multiplier to reach up to 50 MHz
64 kB (C8051F500/1/2/3/8/9) or 32 kB (C8051F504/5/6/7-F510/1) of on-chip Flash memory
4352 bytes of on-chip RAM
SMBus/I2C, Enhanced UART, and Enhanced SPI serial interfaces implemented in hardware
Four general-purpose 16-bit timers
External Data Memory Interface (C8051F500/1/4/5 and C8051F508/9-F510/1) with 64 kB address
space
Programmable Counter/Timer Array (PCA) with six capture/compare modules and Watchdog Timer
function
On-chip Voltage Regulator
On-chip Power-On Reset, VDD Monitor, and Temperature Sensor
On-chip Voltage Comparator
40, 33, or 25 Port I/O (5 V push-pull)
With on-chip Voltage Regulator, Power-On Reset, VDD monitor, Watchdog Timer, and clock oscillator, the
C8051F50x/F51x devices are truly stand-alone System-on-a-Chip solutions. The Flash memory can be
reprogrammed even in-circuit, providing non-volatile data storage, and also allowing field upgrades of the
8051 firmware. User software 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 debugging with-
out occupying package pins.
The devices are specified for 1.8 V to 5.25 V operation over the automotive temperature range (–40 to
+125 °C). The Port I/O and RST pins can interface to 5 V logic by setting the VIO pin to 5 V. The
C8051F500/1/4/5 devices are available in 48-pin QFP and QFN packages, the C8051F508/9-F510/1 are
available in 40-pin QFN packages, and the C8051F502/3/6/7 devices are available in 32-pin QFP and
QFN packages. All package options are lead-free and RoHS compliant. See Table 2.1 for ordering infor-
mation. Block diagrams are included in Figure 1.1, Figure 1.2, and Figure 1.3.
16 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 17
C8051F50x/F51x
18 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 19
C8051F50x/F51x
2. Ordering Information
The following features are common to all devices in this family:
50 MHz system clock and 50 MIPS throughput (peak)
4352 bytes of RAM (256 internal bytes and 4096 XRAM bytes)
SMBus/I2C, Enhanced SPI, Enhanced UART
Four Timers
Six Programmable Counter Array channels
Internal 24 MHz oscillator
Internal Voltage Regulator
12-bit, 200 ksps ADC
Internal Voltage Reference and Temperature Sensor
Two Analog Comparators
Table 2.1 shows the feature that differentiate the devices in this family.
20 Rev. 1.4
C8051F50x/F51x
Package
LIN2.0
C8051F500-IQ 64 40 QFP-48
C8051F500-IM 64 40 QFN-48
C8051F501-IQ 64 — — 40 QFP-48
C8051F501-IM 64 — — 40 QFN-48
C8051F502-IQ 64 25 — QFP-32
C8051F502-IM 64 25 — QFN-32
C8051F502-AM 64 25 — QFN-32
C8051F503-IQ 64 — — 25 — QFP-32
C8051F503-IM 64 — — 25 — QFN-32
C8051F506-IQ 32 25 — QFP-32
C8051F506-IM 32 25 — QFN-32
C8051F507-IQ 32 — — 25 — QFP-32
C8051F507-IM 32 — — 25 — QFN-32
C8051F507-AM 32 — — 25 — QFN-32
C8051F508-IM 64 33 QFN-40
C8051F511-IM 32 — — 33 QFN-40
Note: The suffix of the part number indicates the device rating and the package. All devices are RoHS compliant.
The -AM and -AQ devices receive full automotive quality production status, including AEC-Q100 qualifica-
tion, registration with International Material Data System (IMDS) and Part Production Approval Process
(PPAP) documentation. PPAP documentation is available at www.silabs.com with a registered and NDA
approved user account. The -AM and -AQ devices enable high volume automotive OEM applications with
their enhanced testing and processing. Please contact Silicon Labs sales for more information regarding –
AM and -AQ devices for your automotive project.
Rev. 1.4 21
C8051F50x/F51x
Table 2.2. Product Selection Guide (Not Recommended for New Designs)
Package
LIN2.0
C8051F505-IQ 32 — — 40 QFP-48
Package
LIN2.0
C8051F500-AQ 64 40 QFP-48
C8051F500-AM 64 40 QFN-48
C8051F501-AQ 64 — — 40 QFP-48
C8051F501-AM 64 — — 40 QFN-48
C8051F502-AQ 64 25 — QFP-32
C8051F503-AQ 64 — — 25 — QFP-32
C8051F503-AM 64 — — 25 — QFN-32
C8051F504-IQ 32 40 QFP-48
C8051F504-IM 32 40 QFN-48
C8051F504-AQ 32 40 QFP-48
C8051F504-AM 32 40 QFN-48
C8051F505-IM 32 — — 40 QFN-48
C8051F505-AQ 32 — — 40 QFP-48
C8051F505-AM 32 — — 40 QFN-48
22 Rev. 1.4
C8051F50x/F51x
Package
LIN2.0
C8051F506-AQ 32 25 — QFP-32
C8051F506-AM 32 25 — QFN-32
C8051F507-AQ 32 — — 25 — QFP-32
C8051F508-AM 64 33 QFN-40
C8051F509-IM 64 — — 33 QFN-40
C8051F509-AM 64 — — 33 QFN-40
C8051F510-IM 32 33 QFN-40
C8051F510-AM 32 33 QFN-40
C8051F511-AM 32 — — 33 QFN-40
Rev. 1.4 23
C8051F50x/F51x
3. Pin Definitions
Table 3.1. Pin Definitions for the C8051F50x/F51x
Rev. 1.4 23
C8051F50x/F51x
24 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 25
C8051F50x/F51x
26 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 27
C8051F50x/F51x
28 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 29
C8051F50x/F51x
30 Rev. 1.4
C8051F50x/F51x
4. Package Specifications
4.1. QFP-48 Package Specifications
Rev. 1.4 31
C8051F50x/F51x
Stencil Design
4. A stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure
good solder paste release.
5. The stencil thickness should be 0.125mm (5 mils).
6. The ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads.
Card Assembly
7. A No-Clean, Type-3 solder paste is recommended.
8. Recommended card reflow profile is per the JEDEC/IPC J-STD-020 specification for Small Body
Components.
32 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 33
C8051F50x/F51x
Stencil Design
6. A stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure
good solder paste release.
7. The stencil thickness should be 0.125 mm (5 mils).
8. The ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads.
9. A 3x3 array of 1.20 mm x 1.10 mm openings on a 1.40 mm pitch should be used for the center pad.
Card Assembly
10. A No-Clean, Type-3 solder paste is recommended.
11. Recommended card reflow profile is per the JEDEC/IPC J-STD-020 specification for Small Body
Components.
34 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 35
C8051F50x/F51x
Stencil Design
6. A stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure
good solder paste release.
7. The stencil thickness should be 0.125 mm (5 mils).
8. The ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads.
9. A 4x4 array of 0.80 mm square openings on a 1.05 mm pitch should be used for the center ground pad.
Card Assembly
10. A No-Clean, Type-3 solder paste is recommended.
11. Recommended card reflow profile is per the JEDEC/IPC J-STD-020 specification for Small Body
Components.
36 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 37
C8051F50x/F51x
Stencil Design
4. A stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure
good solder paste release.
5. The stencil thickness should be 0.125 mm (5 mils).
6. The ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads.
Card Assembly
7. A No-Clean, Type-3 solder paste is recommended.
8. Recommended card reflow profile is per the JEDEC/IPC J-STD-020 specification for Small Body
Components.
38 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 39
C8051F50x/F51x
Stencil Design
4. A stainless steel, laser-cut and electro-polished stencil with trapezoidal walls should be used to assure
good solder paste release.
5. The stencil thickness should be 0.125mm (5 mils).
6. The ratio of stencil aperture to land pad size should be 1:1 for all perimeter pads.
7. A 3x3 array of 1.0 mm openings on a 1.20 mm pitch should be used for the center ground pad.
Card Assembly
8. A No-Clean, Type-3 solder paste is recommended.
9. The recommended card reflow profile is per the JEDEC/IPC J-STD-020 specification for Small Body
Components.
40 Rev. 1.4
C8051F50x/F51x
5. Electrical Characteristics
5.1. Absolute Maximum Specifications
Voltage on any Port I/O Pin or RST with Respect to –0.3 — VIO + 0.3 V
GND
Note: Stresses outside of the range of the “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 conditions
above those indicated in the operation listings of this specification is not implied. Exposure to maximum rating
conditions for extended periods may affect device reliability.
Rev. 1.4 41
C8051F50x/F51x
Notes:
1. Given in Table 5.4 on page 47.
2. VIO should not be lower than the VDD voltage.
3. SYSCLK must be at least 32 kHz to enable debugging.
4. Based on device characterization data; Not production tested. Does not include oscillator supply current.
5. IDD can be estimated for frequencies < 12.5 MHz by simply multiplying the frequency of interest by the
frequency sensitivity number for that range. When using these numbers to estimate IDD for >12.5 MHz, the
estimate should be the current at 50 MHz minus the difference in current indicated by the frequency
sensitivity number. For example: VDD = 2.6 V; F = 20 MHz, IDD = 26 mA - (50 MHz -
20 MHz) * 0.48 mA/MHz = 11.6 mA.
6. Idle IDD can be estimated for frequencies < 1 MHz by simply multiplying the frequency of interest by the
frequency sensitivity number for that range. When using these numbers to estimate Idle IDD for >1 MHz, the
estimate should be the current at 50 MHz minus the difference in current indicated by the frequency
sensitivity number.
For example: VDD = 2.6 V; F = 5 MHz, Idle IDD = 21 mA – (50 MHz – 5 MHz) x 0.41 mA/MHz = 2.6 mA.
42 Rev. 1.4
C8051F50x/F51x
Notes:
1. Given in Table 5.4 on page 47.
2. VIO should not be lower than the VDD voltage.
3. SYSCLK must be at least 32 kHz to enable debugging.
4. Based on device characterization data; Not production tested. Does not include oscillator supply current.
5. IDD can be estimated for frequencies < 12.5 MHz by simply multiplying the frequency of interest by the
frequency sensitivity number for that range. When using these numbers to estimate IDD for >12.5 MHz, the
estimate should be the current at 50 MHz minus the difference in current indicated by the frequency
sensitivity number. For example: VDD = 2.6 V; F = 20 MHz, IDD = 26 mA - (50 MHz -
20 MHz) * 0.48 mA/MHz = 11.6 mA.
6. Idle IDD can be estimated for frequencies < 1 MHz by simply multiplying the frequency of interest by the
frequency sensitivity number for that range. When using these numbers to estimate Idle IDD for >1 MHz, the
estimate should be the current at 50 MHz minus the difference in current indicated by the frequency
sensitivity number.
For example: VDD = 2.6 V; F = 5 MHz, Idle IDD = 21 mA – (50 MHz – 5 MHz) x 0.41 mA/MHz = 2.6 mA.
Rev. 1.4 43
C8051F50x/F51x
44 Rev. 1.4
C8051F50x/F51x
Figure 5.1. Minimum VDD Monitor Threshold vs. System Clock Frequency
Note: With system clock frequencies greater than 25 MHz, the VDD monitor level should be set to the high threshold
(VDMLVL = 1b in SFR VDM0CN) to prevent undefined CPU operation. The high threshold should only be used
with an external regulator powering VDD directly. See Figure 10.2 on page 86 for the recommended power
supply connections.
Rev. 1.4 45
C8051F50x/F51x
46 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 47
C8051F50x/F51x
48 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 49
C8051F50x/F51x
50 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 51
C8051F50x/F51x
52 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 53
C8051F50x/F51x
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 overflows are used as the conversion source, Low Byte overflows are
used if Timer2 is in 8-bit mode; High byte overflows are used if Timer 2 is in 16-bit mode. See Section
“26. Timers” on page 266 for timer configuration.
Important Note About Using CNVSTR: The CNVSTR input pin also functions as Port pin P0.1. When the
CNVSTR input is used as the ADC0 conversion source, Port pin P0.1 should be skipped by the Digital
Crossbar. To configure the Crossbar to skip P0.1, set to 1 Bit1 in register P0SKIP. See Section “20. Port
Input/Output” on page 178 for details on Port I/O configuration.
6.1.2. Tracking Modes
Each ADC0 conversion must be preceded by a minimum tracking time for the converted result to be accu-
rate. ADC0 has three tracking modes: Pre-Tracking, Post-Tracking, and Dual-Tracking. Pre-Tracking
Mode provides the minimum delay between the convert start signal and end of conversion by tracking con-
tinuously before the convert start signal. This mode requires software management in order to meet mini-
mum tracking requirements. In Post-Tracking Mode, a programmable tracking time starts after the convert
start signal and is managed by hardware. Dual-Tracking Mode maximizes tracking time by tracking before
and after the convert start signal. Figure 6.2 shows examples of the three tracking modes.
Pre-Tracking Mode is selected when AD0TM is set to 10b. Conversions are started immediately following
the convert start signal. ADC0 is tracking continuously when not performing a conversion. Software must
allow at least the minimum tracking time between each end of conversion and the next convert start signal.
The minimum tracking time must also be met prior to the first convert start signal after ADC0 is enabled.
54 Rev. 1.4
C8051F50x/F51x
Post-Tracking Mode is selected when AD0TM is set to 01b. A programmable tracking time based on
AD0TK is started immediately following the convert start signal. Conversions are started after the pro-
grammed tracking time ends. After a conversion is complete, ADC0 does not track the input. Rather, the
sampling capacitor remains disconnected from the input making the input pin high-impedance until the
next convert start signal.
Dual-Tracking Mode is selected when AD0TM is set to 11b. A programmable tracking time based on
AD0TK is started immediately following the convert start signal. Conversions are started after the pro-
grammed tracking time ends. After a conversion is complete, ADC0 tracks continuously until the next con-
version is started.
Depending on the output connected to the ADC input, additional tracking time, more than is specified in
Table 5.9, may be required after changing MUX settings. See the settling time requirements described in
Section “6.2.1. Settling Time Requirements” on page 58.
6.1.3. Timing
ADC0 has a maximum conversion speed specified in Table 5.9. ADC0 is clocked from the ADC0 Subsys-
tem Clock (FCLK). The source of FCLK is selected based on the BURSTEN bit. When BURSTEN is
logic 0, FCLK is derived from the current system clock. When BURSTEN is logic 1, FCLK is derived from
the Burst Mode Oscillator, an independent clock source with a maximum frequency of 25 MHz.
When ADC0 is performing a conversion, it requires a clock source that is typically slower than FCLK. The
ADC0 SAR conversion clock (SAR clock) is a divided version of FCLK. The divide ratio can be configured
using the AD0SC bits in the ADC0CF register. The maximum SAR clock frequency is listed in Table 5.9.
ADC0 can be in one of three states at any given time: tracking, converting, or idle. Tracking time depends
on the tracking mode selected. For Pre-Tracking Mode, tracking is managed by software and ADC0 starts
conversions immediately following the convert start signal. For Post-Tracking and Dual-Tracking Modes,
the tracking time after the convert start signal is equal to the value determined by the AD0TK bits plus 2
FCLK cycles. Tracking is immediately followed by a conversion. The ADC0 conversion time is always 13
SAR clock cycles plus an additional 2 FCLK cycles to start and complete a conversion. Figure 6.3 shows
timing diagrams for a conversion in Pre-Tracking Mode and tracking plus conversion in Post-Tracking or
Dual-Tracking Mode. In this example, repeat count is set to one.
Rev. 1.4 55
C8051F50x/F51x
56 Rev. 1.4
C8051F50x/F51x
been accumulated. Similarly, the Window Comparator will not compare the result to the greater-than and
less-than registers until “repeat count” conversions have been accumulated.
Note: When using Burst Mode, care must be taken to issue a convert start signal no faster than once
every four SYSCLK periods. This includes external convert start signals.
Figure 6.4. 12-Bit ADC Burst Mode Example With Repeat Count Set to 4
Rev. 1.4 57
C8051F50x/F51x
n
2
t = ln -------- R TOTAL C SAMPLE
SA
Equation 6.1. ADC0 Settling Time Requirements
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the AMUX0 resistance and any external source resistance.
n is the ADC resolution in bits (10).
58 Rev. 1.4
C8051F50x/F51x
GAIN 1
gain = --------------- + GAINADD ------
4096 64
Equation 6.2. Equivalent Gain from the ADC0GNH and ADC0GNL Registers
Where:
GAIN is the 12-bit word of ADC0GNH[7:0] and ADC0GNL[7:4]
GAINADD is the value of the GAINADD bit (ADC0GNA.0)
gain is the equivalent gain value from 0 to 1.016
Rev. 1.4 59
C8051F50x/F51x
For example, if ADC0GNH = 0xFC, ADC0GNL = 0x00, and GAINADD = 1, GAIN = 0xFC0 = 4032, and the
resulting equation is as follows:
4032 1
GAIN = ------------- + 1 ------ = 0.984 + 0.016 = 1.0
4096 64
The table below equates values in the ADC0GNH, ADC0GNL, and ADC0GNA registers to the equivalent
gain using this equation.
ADC0GNH Value ADC0GNL Value GAINADD Value GAIN Value Equivalent Gain
0xFC (default) 0x00 (default) 1 (default) 4032 + 64 1.0 (default)
0x7C 0x00 1 1984 + 64 0.5
0xBC 0x00 1 3008 + 64 0.75
0x3C 0x00 1 960 + 64 0.25
0xFF 0xF0 0 4095 + 0 ~1.0
0xFF 0xF0 1 4096 + 64 1.016
For any desired gain value, the GAIN registers can be calculated by the following:
1
GAIN = gain – GAINADD ------ 4096
64
Equation 6.3. Calculating the ADC0GNH and ADC0GNL Values from the Desired Gain
Where:
GAIN is the 12-bit word of ADC0GNH[7:0] and ADC0GNL[7:4]
GAINADD is the value of the GAINADD bit (ADC0GNA.0)
gain is the equivalent gain value from 0 to 1.016
When calculating the value of GAIN to load into the ADC0GNH and ADC0GNL registers, the GAINADD bit
can be turned on or off to reach a value closer to the desired gain value.
For example, the initial example in this section requires a gain of 0.44 to convert 5 V full scale to 2.2 V full
scale. Using Equation 6.3:
1
GAIN = 0.44 – GAINADD ------ 4096
64
The actual gain from setting GAINADD to 1 and ADC0GNH and ADC0GNL to 0x6CA is 0.4399. A similar
gain can be achieved if GAINADD is set to 0 with a different value for ADC0GNH and ADC0GNL.
60 Rev. 1.4
C8051F50x/F51x
Notes:
1. An ADC conversion should not be performed while the GAINEN bit is set.
2. Even with gain enabled, the maximum input voltage must be less than VREGIN and the maximum
voltage of the signal after gain must be less than or equal to VREF.
In code, changing the value to 0.44 gain from the previous example looks like:
// in ‘C’:
ADC0CF |= 0x01; // GAINEN = 1
ADC0H = 0x04; // Load the ADC0GNH address
ADC0L = 0x6C; // Load the upper byte of 0x6CA to ADC0GNH
ADC0H = 0x07; // Load the ADC0GNL address
ADC0L = 0xA0; // Load the lower nibble of 0x6CA to ADC0GNL
ADC0H = 0x08; // Load the ADC0GNA address
ADC0L = 0x01; // Set the GAINADD bit
ADC0CF &= ~0x01; // GAINEN = 0
; in assembly
ORL ADC0CF,#01H ; GAINEN = 1
MOV ADC0H,#04H ; Load the ADC0GNH address
MOV ADC0L,#06CH ; Load the upper byte of 0x6CA to ADC0GNH
MOV ADC0H,#07H ; Load the ADC0GNL address
MOV ADC0L,#0A0H ; Load the lower nibble of 0x6CA to ADC0GNL
MOV ADC0H,#08H ; Load the ADC0GNA address
MOV ADC0L,#01H ; Set the GAINADD bit
ANL ADC0CF,#0FEH ; GAINEN = 0
Rev. 1.4 61
C8051F50x/F51x
Gain Register Definition 6.1. ADC0GNH: ADC0 Selectable Gain High Byte
Bit 7 6 5 4 3 2 1 0
Name GAINH[7:0]
Type W
Reset 1 1 1 1 1 1 0 0
Gain Register Definition 6.2. ADC0GNL: ADC0 Selectable Gain Low Byte
Bit 7 6 5 4 3 2 1 0
Type W W W W W
Reset 0 0 0 0 0 0 0 0
This register is only accessed indirectly through the ADC0H and ADC0L register.
3:0 Reserved Must Write 0000b
Note: This register is accessed indirectly; See Section 6.3.2 for details for writing this register.
62 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Type W W W W W W W W
Reset 0 0 0 0 0 0 0 1
Rev. 1.4 63
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 1 1 1 1 1 0 0 0
FCLK - – 1
AD0SC = --------------------
CLK SAR
Note: Round up the result of the calculation for AD0SC
2:1 A0RPT[1:0] ADC0 Repeat Count
Controls the number of conversions taken and accumulated between ADC0 End of
Conversion (ADCINT) and ADC0 Window Comparator (ADCWINT) interrupts. A con-
vert start is required for each conversion unless Burst Mode is enabled. In Burst
Mode, a single convert start can initiate multiple self-timed conversions. Results in
both modes are accumulated in the ADC0H:ADC0L register. When AD0RPT1–0 are
set to a value other than '00', the AD0LJST bit in the ADC0CN register must be
set to '0' (right justified).
00: 1 conversion is performed.
01: 4 conversions are performed and accumulated.
10: 8 conversions are performed and accumulated.
11: 16 conversions are performed and accumulated.
0 GAINEN Gain Enable Bit.
Controls the gain programming. Refer to Section “6.3. Selectable Gain” on page 59
for information about using this bit.
64 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name ADC0H[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name ADC0L[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Rev. 1.4 65
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
66 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 1 1 1 1 1 1 1 1
Rev. 1.4 67
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name ADC0GTH[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name ADC0GTL[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
68 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name ADC0LTH[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name ADC0LTL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Rev. 1.4 69
C8051F50x/F51x
70 Rev. 1.4
C8051F50x/F51x
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. To force the Crossbar to skip a Port pin, set to 1
the corresponding bit in register PnSKIP. See Section “20. Port Input/Output” on page 178 for more Port
I/O configuration details.
Rev. 1.4 71
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name ADC0MX[5:0]
Type R R R/W
Reset 0 0 1 1 1 1 1 1
SFR Address = 0xBB; SFR Page = 0x00;
Bit Name Function
7:6 Unused Read = 00b; Write = Don’t Care.
5:0 AMX0P[5:0] AMUX0 Positive Input Selection.
000000: P0.0
000001: P0.1
000010: P0.2
000011: P0.3
000100: P0.4
000101: P0.5
000110: P0.6
000111: P0.7
001000: P1.0
001001: P1.1
001010: P1.2
001011: P1.3
001100: P1.4
001101: P1.5
001110: P1.6
001111: P1.7
010000: P2.0
010001: P2.1
010010: P2.2
010011: P2.3
010100: P2.4
010101: P2.5
010110: P2.6
010111: P2.7
011000: P3.0
011001: P3.1 (Only available on 48-pin and 40-pin package devices)
011010: P3.2 (Only available on 48-pin and 40-pin package devices)
011011: P3.3 (Only available on 48-pin and 40-pin package devices)
011100: P3.4 (Only available on 48-pin and 40-pin package devices)
011101: P3.5 (Only available on 48-pin and 40-pin package devices)
011110: P3.6 (Only available on 48-pin and 40-pin package devices)
011111: P3.7 (Only available on 48-pin and 40-pin package devices)
100000–101111: Reserved
110000: Temp Sensor
110001: VDD
110010–111111: GND
72 Rev. 1.4
C8051F50x/F51x
7. Temperature Sensor
An on-chip temperature sensor is included on the C8051F50x/F51x devices which can be directly
accessed via the ADC multiplexer in single-ended configuration. To use the ADC to measure the tempera-
ture sensor, the ADC multiplexer channel should be configured to connect to the temperature sensor. The
temperature sensor transfer function is shown in Figure 7.1. The output voltage (VTEMP) is the positive
ADC input is selected by bits AD0MX[4:0] in register ADC0MX. The TEMPE bit in register REF0CN
enables/disables the temperature sensor, as described in SFR Definition 8.1. While disabled, the tempera-
ture sensor defaults to a high impedance state and any ADC measurements performed on the sensor will
result in meaningless data. Refer to Table 5.10 for the slope and offset parameters of the temperature sen-
sor.
Rev. 1.4 73
C8051F50x/F51x
8. Voltage Reference
The Voltage reference multiplexer on the C8051F50x/F51x devices is configurable to use an externally
connected voltage reference, the on-chip reference voltage generator routed to the VREF pin, or the VDD
power supply voltage (see Figure 8.1). The REFSL bit in the Reference Control register (REF0CN, SFR
Definition 8.1) selects the reference source for the ADC. For an external source or the on-chip reference,
REFSL should be set to 0 to select the VREF pin. To use VDD as the reference source, REFSL should be
set to 1.
The BIASE bit enables the internal voltage bias generator, which is used by the ADC, Temperature Sen-
sor, and internal oscillator. This bias is automatically enabled when any peripheral which requires it is
enabled, and it does not need to be enabled manually. The bias generator may be enabled manually by
writing a 1 to the BIASE bit in register REF0CN. The electrical specifications for the voltage reference cir-
cuit are given in Table 5.11.
The on-chip voltage reference circuit consists of a temperature stable bandgap voltage reference genera-
tor and a gain-of-two output buffer amplifier. The output voltage is selectable between 1.5 V and 2.25 V.
The on-chip voltage reference can be driven on the VREF pin by setting the REFBE bit in register REF0CN
to a 1. The maximum load seen by the VREF pin must be less than 200 μA to GND. Bypass capacitors of
0.1 μF and 4.7 μF are recommended from the VREF pin to GND. If the on-chip reference is not used, the
REFBE bit should be cleared to 0. Electrical specifications for the on-chip voltage reference are given in
Table 5.11.
Important Note about the VREF Pin: When using either an external voltage reference or the on-chip ref-
erence circuitry, the VREF pin should be configured as an analog pin and skipped by the Digital Crossbar.
Refer to Section “20. Port Input/Output” on page 178 for the location of the VREF pin, as well as details of
how to configure the pin in analog mode and to be skipped by the crossbar.
74 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Rev. 1.4 75
C8051F50x/F51x
9. Comparators
The C8051F50x/F51x devices include two on-chip programmable voltage Comparators. A block diagram
of the comparators is shown in Figure 9.1, where “n” is the comparator number (0 or 1). The two Compar-
ators operate identically except that Comparator0 can also be used a reset source. For input selection
details, refer to SFR Definition 9.5 and SFR Definition 9.6.
Each 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 signal is available even when the system
clock is not active. This allows the Comparators to operate and generate an output with the device in
STOP mode. When assigned to a Port pin, the Comparator outputs may be configured as open drain or
push-pull (see Section “20.4. Port I/O Initialization” on page 183). Comparator0 may also be used as a
reset source (see Section “17.5. Comparator0 Reset” on page 146).
The Comparator0 inputs are selected in the CPT0MX register (SFR Definition 9.5). 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 9.6). 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 “20.1. Port I/O Modes of Operation” on page 179).
76 Rev. 1.4
C8051F50x/F51x
Comparator outputs can be polled in software, used as an interrupt source, and/or routed to a Port pin.
When routed to a Port pin, Comparator outputs are 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 the power supply to the comparator is turned off. See Section “20.3. Priority Crossbar Decoder” on
page 181 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 5.12.
The Comparator response time may be configured in software via the CPTnMD registers (see SFR Defini-
tion 9.2). Selecting a longer response time reduces the Comparator supply current. See Table 5.12 on
page 52 for complete timing and supply current requirements.
Rev. 1.4 77
C8051F50x/F51x
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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
78 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 1 0
Rev. 1.4 79
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
80 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 1 0
Rev. 1.4 81
C8051F50x/F51x
82 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 1 1 1 0 1 1 1
Rev. 1.4 83
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 1 1 1 0 1 1 1
84 Rev. 1.4
C8051F50x/F51x
The input (VREGIN) and output (VDD) of the voltage regulator should both be bypassed with a large capaci-
tor (4.7 μF + 0.1 μF) to ground as shown in Figure 10.1 below. This capacitor will eliminate power spikes
and provide any immediate power required by the microcontroller. The settling time associated with the
voltage regulator is shown in Table X.
If the internal voltage regulator is not used, the VREGIN input should be tied to VDD, as shown in
Figure 10.2.
Rev. 1.4 85
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 1 0 1 0 0 0 0
86 Rev. 1.4
C8051F50x/F51x
11.1. 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.
Rev. 1.4 87
C8051F50x/F51x
With the CIP-51's maximum system clock at 50 MHz, it has a peak throughput of 50 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.
88 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 89
C8051F50x/F51x
90 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 91
C8051F50x/F51x
92 Rev. 1.4
C8051F50x/F51x
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).
#data—8-bit constant
#data16—16-bit constant
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 64 kB program memory space.
There is one unused opcode (0xA5) that performs the same function as NOP.
All mnemonics copyrighted © Intel Corporation 1980.
Rev. 1.4 93
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name DPL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name DPH[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
94 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name SP[7:0]
Type R/W
Reset 0 0 0 0 0 1 1 1
Bit 7 6 5 4 3 2 1 0
Name ACC[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name B[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Rev. 1.4 95
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
96 Rev. 1.4
C8051F50x/F51x
Bit 7 6 5 4 3 2 1 0
Name SERNUMn[7:0]
Type R/W
SFR Addresses: SN0 = 0xF9; SN1 = 0xFA; SN2 = 0xFB; SN3 = 0xFC; SFR Page = 0x0F;
Bit Name Function
7:0 SERNUMn[7:0] Serial Number Bits.
The four serial number registers form a 32-bit serial number, with SN3 as the
most significant byte and SN0 as the least significant byte.
Rev. 1.4 97
C8051F50x/F51x
98 Rev. 1.4
C8051F50x/F51x
Rev. 1.4 99
C8051F50x/F51x
byte-wide registers. The next 16 bytes, locations 0x20 through 0x2F, may either be addressed as bytes or
as 128 bit locations accessible with the direct addressing mode.
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 12.1 illustrates the data memory organization of the
C8051F50x/F51x.
12.2.1.1. General Purpose Registers
The lower 32 bytes of data memory, locations 0x00 through 0x1F, may be addressed as four banks of gen-
eral-purpose registers. Each bank consists of eight byte-wide registers designated R0 through R7. Only
one of these banks may be enabled at a time. Two bits in the program status word, RS0 (PSW.3) and RS1
(PSW.4), select the active register bank (see description of the PSW in SFR Definition 11.6). This allows
fast context switching when entering subroutines and interrupt service routines. Indirect addressing modes
use registers R0 and R1 as index registers.
12.2.1.2. Bit Addressable Locations
In addition to direct access to data memory organized as bytes, the sixteen data memory locations at 0x20
through 0x2F are also accessible as 128 individually addressable bits. Each bit has a bit address from
0x00 to 0x7F. Bit 0 of the byte at 0x20 has bit address 0x00 while bit7 of the byte at 0x20 has bit address
0x07. Bit 7 of the byte at 0x2F has bit address 0x7F. A bit access is distinguished from a full byte access by
the type of instruction used (bit source or destination operands as opposed to a byte source or destina-
tion).
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.
12.2.1.3. 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) 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 regis-
ter (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.
Automatic hardware switching of the SFR Page on interrupts may be enabled or disabled as desired using
the SFR Automatic Page Control Enable Bit located in the SFR Page Control Register (SFR0CN). This
function defaults to “enabled” upon reset. In this way, the autoswitching function will be enabled unless dis-
abled in software.
A summary of the SFR locations (address and SFR page) are provided in Table 13.3 in the form of an SFR
memory map. Each memory location in the map has an SFR page row, denoting the page in which that
SFR resides. Certain SFRs are accessible from ALL SFR pages, and are denoted by the “(ALL PAGES)”
designation. For example, the Port I/O registers P0, P1, P2, and P3 all have the “(ALL PAGES)” designa-
tion, indicating these SFRs are accessible from all SFR pages regardless of the SFRPAGE register value.
13.3. SFR Page Stack Example
The following is an example that shows the operation of the SFR Page Stack during interrupts. In this
example, the SFR Control register is left in the default enabled state (i.e., SFRPGEN = 1), and the CIP-51
is executing in-line code that is writing values to SPI Data Register (SFR “SPI0DAT”, located at address
0xA3 on SFR Page 0x00). The device is also using the CAN peripheral (CAN0) and the Programmable
Counter Array (PCA0) peripheral to generate a PWM output. The PCA is timing a critical control function in
its interrupt service round so its associated ISR that is set to low priority. At this point, the SFR page is set
to access the SPI0DAT SFR (SFRPAGE = 0x00). See Figure 13.2.
Figure 13.2. SFR Page Stack While Using SFR Page 0x0 To Access SPI0DAT
While CIP-51 executes in-line code (writing values to SPI0DAT in this example), the CAN0 Interrupt
occurs. The CIP-51 vectors to the CAN0 ISR and pushes the current SFR Page value (SFR Page 0x00)
into SFRNEXT in the SFR Page Stack. The SFR page needed to access CAN’s SFRs is then automati-
cally placed in the SFRPAGE register (SFR Page 0x0C). SFRPAGE is considered the “top” of the SFR
Page Stack. Software can now access the CAN0 SFRs. Software may switch to any SFR Page by writing
a new value to the SFRPAGE register at any time during the CAN0 ISR to access SFRs that are not on
SFR Page 0x0C. See Figure 13.3.
While in the CAN0 ISR, a PCA interrupt occurs. Recall the PCA interrupt is configured as a high priority
interrupt, while the CAN0 interrupt is configured as a low priority interrupt. Thus, the CIP-51 will now vector
to the high priority PCA ISR. Upon doing so, the CIP-51 will automatically place the SFR page needed to
access the PCA’s special function registers into the SFRPAGE register, SFR Page 0x00. The value that
was in the SFRPAGE register before the PCA interrupt (SFR Page 0x0C for CAN0) is pushed down the
stack into SFRNEXT. Likewise, the value that was in the SFRNEXT register before the PCA interrupt (in
this case SFR Page 0x00 for SPI0DAT) is pushed down to the SFRLAST register, the “bottom” of the
stack. Note that a value stored in SFRLAST (via a previous software write to the SFRLAST register) will be
overwritten. See Figure 13.4.
Figure 13.4. SFR Page Stack Upon PCA Interrupt Occurring During a CAN0 ISR
On exit from the PCA interrupt service routine, the CIP-51 will return to the CAN0 ISR. On execution of the
RETI instruction, SFR Page 0x00 used to access the PCA registers will be automatically popped off of the
SFR Page Stack, and the contents of the SFRNEXT register will be moved to the SFRPAGE register. Soft-
ware in the CAN0 ISR can continue to access SFRs as it did prior to the PCA interrupt. Likewise, the con-
tents of SFRLAST are moved to the SFRNEXT register. Recall this was the SFR Page value 0x00 being
used to access SPI0DAT before the CAN0 interrupt occurred. See Figure 13.5.
Figure 13.5. SFR Page Stack Upon Return From PCA Interrupt
On the execution of the RETI instruction in the CAN0 ISR, the value in SFRPAGE register is overwritten
with the contents of SFRNEXT. The CIP-51 may now access the SPI0DAT register as it did prior to the
interrupts occurring. See Figure 13.6.
Figure 13.6. SFR Page Stack Upon Return From CAN0 Interrupt
In the example above, all three bytes in the SFR Page Stack are accessible via the SFRPAGE, SFRNEXT,
and SFRLAST special function registers. If the stack is altered while servicing an interrupt, it is possible to
return to a different SFR Page upon interrupt exit than selected prior to the interrupt call. Direct access to
the SFR Page stack can be useful to enable real-time operating systems to control and manage context
switching between multiple tasks.
Push operations on the SFR Page Stack only occur on interrupt service, and pop operations only occur on
interrupt exit (execution on the RETI instruction). The automatic switching of the SFRPAGE and operation
of the SFR Page Stack as described above can be disabled in software by clearing the SFR Automatic
Page Enable Bit (SFRPGEN) in the SFR Page Control Register (SFR0CN). See SFR Definition 13.1.
Bit 7 6 5 4 3 2 1 0
Name SFRPGEN
Type R R R R R R R R/W
Reset 0 0 0 0 0 0 0 1
Bit 7 6 5 4 3 2 1 0
Name SFRPAGE[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name SFRNEXT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name SFRLAST[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Table 13.1. Special Function Register (SFR) Memory Map for Pages 0x0 and 0xF
0(8) 1(9) 2(A) 3(B) 4(C) 5(D) 6(E) 7(F)
Address
Page
Table 13.2. Special Function Register (SFR) Memory Map for Page 0xC
0(8) 1(9) 2(A) 3(B) 4(C) 5(D) 6(E) 7(F)
F8 CAN0IF2DA2L CAN0IF2DA2H CAN0IF2DB1L CAN0IF2DB1H CAN0IF2DB2L CAN0IF2DB2H
Note: The CAN registers are not explicitly defined in this datasheet. See Table 22.2 on page 224 for the list of all
available CAN registers.
14. Interrupts
The C8051F50x/F51x devices include an extended interrupt system supporting a total of 18 interrupt
sources with two priority levels. The allocation of interrupt sources between on-chip peripherals and exter-
nal inputs pins varies according to the specific version of the device. Each interrupt source has one or
more associated interrupt-pending flag(s) located in an SFR. When a peripheral or external source meets
a valid interrupt condition, the associated interrupt-pending flag is set to logic 1.
If interrupts are enabled for the source, an interrupt request is generated when the interrupt-pending flag is
set. As soon as execution of the current instruction is complete, the CPU generates an LCALL to a prede-
termined address to begin execution of an interrupt service routine (ISR). Each ISR must end with an RETI
instruction, which returns program execution to the next instruction that would have been executed if the
interrupt request had not occurred. If interrupts are not enabled, the interrupt-pending flag is ignored by the
hardware and program execution continues as normal. (The interrupt-pending flag is set to logic 1 regard-
less of the interrupt's enable/disable state.)
Each interrupt source can be individually enabled or disabled through the use of an associated interrupt
enable bit in an SFR (IE, EIE1, or EIE2). However, interrupts must first be globally enabled by setting the
EA bit (IE.7) to logic 1 before the individual interrupt enables are recognized. Setting the EA bit to logic 0
disables all interrupt sources regardless of the individual interrupt-enable settings.
Note: Any instruction that clears a bit to disable an interrupt should be immediately followed by an instruction that has
two or more opcode bytes. Using EA (global interrupt enable) as an example:
// in 'C':
EA = 0; // clear EA bit.
EA = 0; // this is a dummy instruction with two-byte opcode.
; in assembly:
CLR EA ; clear EA bit.
CLR EA ; this is a dummy instruction with two-byte opcode.
For example, if an interrupt is posted during the execution phase of a "CLR EA" opcode (or any instruction
which clears a bit to disable an interrupt source), and the instruction is followed by a single-cycle instruc-
tion, the interrupt may be taken. However, a read of the enable bit will return a 0 inside the interrupt service
routine. When the bit-clearing opcode is followed by a multi-cycle instruction, the interrupt will not be taken.
Some interrupt-pending flags are automatically cleared by the hardware when the CPU vectors to the ISR.
However, most are not cleared by the hardware and must be cleared by software before returning from the
ISR. If an interrupt-pending flag remains set after the CPU completes the return-from-interrupt (RETI)
instruction, a new interrupt request will be generated immediately and the CPU will re-enter the ISR after
the completion of the next instruction.
14.1. MCU Interrupt Sources and Vectors
The C8051F50x/F51x MCUs support 18 interrupt sources. Software can simulate an interrupt by setting
any interrupt-pending flag to logic 1. If interrupts are enabled for the flag, an interrupt request will be gener-
ated and the CPU will vector to the ISR address associated with the interrupt-pending flag. MCU interrupt
sources, associated vector addresses, priority order and control bits are summarized in Table 14.1. Refer
to the datasheet section associated with a particular on-chip peripheral for information regarding valid
interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s).
Bit addressable?
Cleared by HW?
Vector Order Flag Control
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 1 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
INT0 and INT1 are assigned to Port pins as defined in the IT01CF register (see SFR Definition 14.7). 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 “20.3. Priority Crossbar
Decoder” on page 181 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 inter-
rupts, respectively. If an INT0 or INT1 external interrupt is configured as edge-sensitive, the corresponding
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 inactive. 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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
The level of Flash security depends on the Flash access method. The three Flash access methods that
can be restricted are reads, writes, and erases from the C2 debug interface, user firmware executing on
unlocked pages, and user firmware executing on locked pages. Table 15.1 summarizes the Flash security
features of the C8051F50x/F51x devices.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name FLKEY[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 1 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name PERIOD[3:0]
Reset 0 0 0 0 1 1 1 1
; in assembly:
ORL PCON, #01h ; set IDLE bit
MOV PCON, PCON ; ... followed by a 3-cycle dummy instruction
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 “17.6. PCA Watchdog
Timer Reset” on page 146 for more information on the use and configuration of the WDT.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Important Note: If the VDD monitor is being turned on from a disabled state, it should be enabled before it
is selected as a reset source. Selecting the VDD monitor as a reset source before it is enabled and stabi-
lized may cause a system reset. In some applications, this reset may be undesirable. If this is not desirable
in the application, a delay should be introduced between enabling the monitor and selecting it as a reset
source. The procedure for enabling the VDD monitor and configuring it as a reset source from a disabled
state is as follows:
1. Enable the VDD monitor (VDMEN bit in VDM0CN = 1).
2. If necessary, wait for the VDD monitor to stabilize (see Table 5.4 for the VDD Monitor turn-on time).
Note: This delay should be omitted if software contains routines that erase or write Flash
memory.
3. Select the VDD monitor as a reset source (PORSF bit in RSTSRC = 1).
See Figure 17.2 for VDD monitor timing; note that the power-on-reset delay is not incurred after a VDD
monitor reset. See Table 5.4 for complete electrical characteristics of the VDD monitor.
See “Figure 5.1. Minimum VDD Monitor Threshold vs. System Clock Frequency” on page 45 for VDD mon-
itor threshold level requirements.
Note: The output of the internal voltage regulator is calibrated by the MCU immediately after any reset event. The
output of the un-calibrated internal regulator could be below the high threshold setting of the VDD Monitor. If
this is the case and the VDD Monitor is set to the high threshold setting and if the MCU receives a non-power
on reset (POR), the MCU will remain in reset until a POR occurs (i.e., VDD Monitor will keep the device in
reset). A POR will force the VDD Monitor to the low threshold setting which is guaranteed to be below the un-
calibrated output of the internal regulator. The device will then exit reset and resume normal operation. It is for
this reason Silicon Labs strongly recommends that the VDD Monitor is always left in the low threshold setting
(i.e., default value upon POR).
When programming the Flash in-system, the VDD Monitor must be set to the high threshold setting. For the
highest system reliability, the time the VDD Monitor is set to the high threshold setting should be minimized
(e.g. setting the VDD Monitor to the high threshold setting just before the Flash write operation and then
changing it back to the low threshold setting immediately after the Flash write operation).
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
The above example uses the 16-bit immediate MOV instruction to set the contents of DPTR. Alternately,
the DPTR can be accessed through the SFR registers DPH, which contains the upper 8-bits of DPTR, and
DPL, which contains the lower 8-bits of DPTR.
18.1.2. 8-Bit MOVX Example
The 8-bit form of the MOVX instruction uses the contents of the EMI0CN SFR to determine the upper 8-
bits of the effective address to be accessed and the contents of R0 or R1 to determine the lower 8-bits of
the effective address to be accessed. The following series of instructions read the contents of the byte at
address 0x1234 into the accumulator A.
MOV EMI0CN, #12h ; load high byte of address into EMI0CN
MOV R0, #34h ; load low byte of address into R0 (or R1)
MOVX a, @R0 ; load contents of 0x1234 into accumulator A
RD P1.6 RD P1.6
WR P1.7 WR P1.7
A8 P3.0 A1 P3.1
A9 P3.1 A2 P3.2
— — A9 P2.1
— — A10 P2.2
— — A11 P2.3
— — A12 P2.4
— — A13 P2.5
— — A14 P2.6
— — A15 P2.7
RD P1.6
WR P1.7
ALE P1.5
D0/A0 P3.0
D1/A1 P3.1
D2/A2 P3.2
D3/A3 P3.3
D4/A4 P3.4
D5/A5 P3.5
D6/A6 P3.6
D7/A7 P3.7
A8 P2.0
A9 P2.1
A10 P2.2
A11 P2.3
A12 P2.4
A13 P2.5
A14 P2.6
A15 P2.7
Bit 7 6 5 4 3 2 1 0
Name PGSEL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name EMD2 EMD[1:0] EALE[1:0]
Type R/W
Reset 0 0 0 0 0 0 1 1
Bit 7 6 5 4 3 2 1 0
Name EAS[1:0] EWR[3:0] EAH[1:0]
Reset 1 1 1 1 1 1 1 1
*Note: TSYSCLK is equal to one period of the device system clock (SYSCLK).
Bit 7 6 5 4 3 2 1 0
Name CLKSL[1:0]
Type R R R R R R R/W
Reset 0 0 0 0 0 0 0 0
Important Note: If the selected system clock is greater than 25 MHz, please be aware of the following:
Flash Scale Timing must be configured for the faster system clock. See SFR Definition 15.3 for more
details.
VDD and VDDA voltage must be 2 V or higher.
It is recommended to enable the VDD monitor as a reset source and configure it for the high threshold.
See SFR Definition 17.1 for details on configuring the VDD monitor. If the VDD monitor is configured to
the high threshold, the VDD and VDDA voltage must be greater than the VDD monitor high threshold.
See Table 5.4 for VDD monitor threshold specifications.
Bit 7 6 5 4 3 2 1 0
Reset 1 1 0 1 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name OSCICRS[6:0]
Type R R/W
Bit 7 6 5 4 3 2 1 0
OSCIFIN[5:0]
Type R R R/W
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Figure 19.3. External 32.768 kHz Quartz Crystal Oscillator Connection Diagram
3
f = 1.23 10 R C
f = KF / (C x VDD)
Since the frequency of roughly 75 kHz is desired, select the K Factor from the table in SFR Definition 19.6
(OSCXCN) as KF = 7.7:
20.2.3. Assigning Port I/O Pins to External Digital Event Capture Functions
External digital event capture functions can be used to trigger an interrupt or wake the device from a low
power mode when a transition occurs on a digital I/O pin. The digital event capture functions do not require
dedicated pins and will function on both GPIO pins (PnSKIP = 1) and pins in use by the Crossbar (PnSKIP
= 0). External digital event capture functions cannot be used on pins configured for analog I/O. Table 20.3
shows all available external digital event capture functions.
Table 20.3. Port I/O Assignment for External Digital Event Capture Functions
Digital Function Potentially Assignable Port Pins SFR(s) used for
Assignment
External Interrupt 0 P1.0–P1.7 IT01CF
External Interrupt 1 P1.0–P1.7 IT01CF
Port Match P0.0–P3.7* P0MASK, P0MAT
P1MASK, P1MAT
P2MASK, P2MAT
P3MASK, P3MAT
*Note: P3.1–P3.7 are only available on the 48-pin packages.
Registers XBR0, XBR1, and XBR2 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); and similarly when the UART, CAN or LIN are selected, the Crossbar assigns both pins
associated with the peripheral (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. CAN0 pin assignments are
fixed to P0.6 for CAN_TX and P0.7 for CAN_RX. Standard Port I/Os appear contiguously after the priori-
tized functions have been assigned.
Important Note: The SPI can be operated in either 3-wire or 4-wire modes, pending the state of the NSS-
MD1–NSSMD0 bits in register SPI0CN. According to the SPI mode, the NSS signal may or may not be
routed to a Port pin.
As an example configuration, if CAN0, SPI0 in 4-wire mode, and PCA0 Modules 0, 1, and 2 are enabled on
the crossbar with P0.1, P0.2, and P0.5 skipped, the registers should be set as follows: XBR0 = 0x06
(CAN0 and SPI0 enabled), XBR1 = 0x0C (PCA0 modules 0, 1, and 2 enabled), XBR2 = 0x40 (Crossbar
enabled), and P0SKIP = 0x26 (P0.1, P0.2, and P0.5 skipped). The resulting crossbar would look as shown
in Figure 20.4.
a digital input, and a 0 indicates an analog input. All pins default to digital inputs on reset. See SFR Defini-
tion 20.13 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 XBR2 is 0, a weak pullup is enabled for all Port I/O config-
ured 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, XBR1, and XBR2 must be loaded with the appropriate values to select the digital I/O
functions required by the design. Setting the XBARE bit in XBR2 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 deter-
mine 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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P0MASK[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P0MAT[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P1MASK[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P1MAT[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P2MASK[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P2MAT[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P3MASK[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P3MAT[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
20.6. Special Function Registers for Accessing and Configuring Port I/O
All Port I/O are accessed through corresponding special function registers (SFRs) that are both byte
addressable and bit addressable, except for P4 which is only byte addressable. When writing to a Port, the
value written to the SFR is latched to maintain the output data value at each pin. When reading, the logic
levels of the Port's input pins are returned regardless of the XBRn settings (i.e., even when the pin is
assigned to another signal by the Crossbar, the Port register can always read its corresponding Port I/O
pin). The exception to this is the execution of the read-modify-write instructions that target a Port Latch
register as the destination. The read-modify-write instructions when operating on a Port SFR are the fol-
lowing: ANL, ORL, XRL, JBC, CPL, INC, DEC, DJNZ and MOV, CLR or SETB, when the destination is an
individual bit in a Port SFR. For these instructions, the value of the latch register (not the pin) is read, mod-
ified, and written back to the SFR.
Ports 0–3 have a corresponding PnSKIP register which allows its individual Port pins to be assigned to dig-
ital functions or skipped by the Crossbar. All Port pins used for analog functions, GPIO, or dedicated digital
functions such as the EMIF should have their PnSKIP bit set to 1.
The Port input mode of the I/O pins is defined using the Port Input Mode registers (PnMDIN). Each Port
cell can be configured for analog or digital I/O. This selection is required even for the digital resources
selected in the XBRn registers, and is not automatic. The only exception to this is P4, which can only be
used for digital I/O.
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.
Bit 7 6 5 4 3 2 1 0
Name P0[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P0MDIN[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P0MDOUT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P0SKIP[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P1[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P1MDIN[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P1MDOUT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P1SKIP[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P2[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P2MDIN[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P2MDOUT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P2SKIP[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P3[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P3MDIN[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P3MDOUT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P3SKIP[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name P4[7:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name P4MDOUT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
SYSCLK
baud_rate = --------------------------------------------------------------------------------------------------------------------
-
prescaler + 1
2 divider multiplier + 1
The prescaler, divider and multiplier factors are part of the LIN0DIV and LIN0MUL registers and can
assume values in the following range:
Important Note: The minimum system clock (SYSCLK) to operate the LIN controller is 8 MHz.
Use the following equations to calculate the values for the variables for the baud-rate equation:
20000
multiplier = ----------------------------- – 1
baud_rate
SYSCLK 1
prescaler = ln ------------------------------------------------------------------------------------------------- -------
-–1
multiplier + 1 baud_rate 200 ln2
SYSCLK
divider = --------------------------------------------------------------------------------------------------------------------------------------
2 prescaler + 1 multiplier + 1 baud_rate
In all of these equations, the results must be rounded down to the nearest integer.
The following example shows the steps for calculating the baud rate values for a Master node running at
24 MHz and communicating at 19200 bits/sec. First, calculate the multiplier:
20000
multiplier = ---------------- – 1 = 0.0417 0
19200
Next, calculate the prescaler:
24000000 1
prescaler = ln ----------------------------------------------------------- -------
- – 1 = 1.644 1
0 + 1 19200 200 ln2
Finally, calculate the divider:
24000000
divider = ----------------------------------------------------------------------- = 312.5 312
1 + 1
2 0 + 1 19200
These values lead to the following baud rate:
24000000
baud_rate = ---------------------------------------------------------------- 19230.77
1 + 1
2 0 + 1 312
The following code programs the interface in Master mode, using the Enhanced Checksum and enables
the interface to operate at 19230 bits/sec using a 24 MHz system clock.
LIN0CF = 0x80; // Activate the interface
LIN0CF |= 0x40; // Set the node as a Master
Table 21.2 includes the configuration values required for the typical system clocks and baud rates:
Pres.
Pres.
Pres.
Pres.
Mult.
Mult.
Mult.
Mult.
Mult.
Div.
Div.
Div.
Div.
Div.
(MHz)
25 0 1 312 0 1 325 1 1 325 3 1 325 19 1 312
24.5 0 1 306 0 1 319 1 1 319 3 1 319 19 1 306
24 0 1 300 0 1 312 1 1 312 3 1 312 19 1 300
22.1184 0 1 276 0 1 288 1 1 288 3 1 288 19 1 276
16 0 1 200 0 1 208 1 1 208 3 1 208 19 1 200
12.25 0 0 306 0 0 319 1 0 319 3 0 319 19 0 306
12 0 0 300 0 0 312 1 0 312 3 0 312 19 0 300
11.0592 0 0 276 0 0 288 1 0 288 3 0 288 19 0 276
8 0 0 200 0 0 208 1 0 208 3 0 208 19 0 200
SYSCLK 1
prescaler = ln ------------------------- -------
-–1
4000000 ln2
SYSCLK
divider = ----------------------------------------------------------------------
prescaler + 1
2 20000
The following example calculates the values of these variables for a 24 MHz system clock:
24000000 1
prescaler = ln -------------------------- -------
- – 1 = 1.585 1
4000000 ln2
24000000
divider = --------------------------------------------- = 300
1 + 1
2 20000
Table 21.3 presents some typical values of system clock and baud rate along with their factors.
1. Check the DONE bit (LIN0ST.0) and the ERROR bit (LIN0ST.2).
2. If performing a master receive operation and the transfer was successful, read the received data from
the data buffer.
3. If the transfer was not successful, check the error register to determine the kind of error. Further error
handling has to be done by the application.
4. Set the RSTINT (LIN0CTRL.3) and RSTERR bits (LIN0CTRL.2) to reset the interrupt request and the
error flags.
21.4. LIN Slave Mode Operation
When the device is configured for slave mode operation, it must wait for a command from a master node.
Access from the firmware to the data buffer and ID registers of the LIN controller is only possible when a
data request is pending (DTREQ bit (LIN0ST.4) is 1) and also when the LIN bus is not active (ACTIVE bit
(LIN0ST.7) is set to 0).
The LIN controller in slave mode detects the header of the message frame sent by the LIN master. If slave
synchronization is enabled (autobaud), the slave synchronizes its internal bit time to the master bit time.
The LIN controller configured for slave mode will generated an interrupt in one of three situations:
1. After the reception of the IDENTIFIER FIELD
2. When an error is detected
3. When the message transfer is completed.
The application should perform the following steps when an interrupt is detected:
1. Check the status of the DTREQ bit (LIN0ST.4). This bit is set when the IDENTIFIER FIELD has been
received.
2. If DTREQ (LIN0ST.4) is set, read the identifier from LIN0ID and process it. If DTREQ (LIN0ST.4) is not
set, continue to step 7.
3. Set the TXRX bit (LIN0CTRL.5) to 1 if the current frame is a transmit operation for the slave and set to
0 if the current frame is a receive operation for the slave.
4. Load the data length into LIN0SIZE.
5. For a slave transmit operation, load the data to transmit into the data buffer.
6. Set the DTACK bit (LIN0CTRL.4). Continue to step 10.
7. If DTREQ (LIN0ST.4) is not set, check the DONE bit (LIN0ST.0). The transmission was successful if the
DONE bit is set.
8. If the transmission was successful and the current frame was a receive operation for the slave, load the
received data bytes from the data buffer.
9. If the transmission was not successful, check LIN0ERR to determine the nature of the error. Further
error handling has to be done by the application.
10.Set the RSTINT (LIN0CTRL.3) and RSTERR bits (LIN0CTRL.2) to reset the interrupt request and the
error flags.
In addition to these steps, the application should be aware of the following:
1. If the current frame is a transmit operation for the slave, steps 1 through 5 must be completed during
the IN-FRAME RESPONSE SPACE. If it is not completed in time, a timeout will be detected by the
master.
2. If the current frame is a receive operation for the slave, steps 1 through 5 have to be finished until the
reception of the first byte after the IDENTIFIER FIELD. Otherwise, the internal receive buffer of the LIN
controller will be overwritten and a timeout error will be detected in the LIN controller.
3. The LIN controller does not directly support LIN Version 1.3 Extended Frames. If the application detects
an unknown identifier (e.g. extended identifier), it has to write a 1 to the STOP bit (LIN0CTRL.7) instead
of setting the DTACK (LIN0CTRL.4) bit. At that time, steps 2 through 5 can then be skipped. In this
situation, the LIN controller stops the processing of LIN communication until the next SYNC BREAK is
received.
4. Changing the configuration of the checksum during a transaction will cause the interface to reset and
the transaction to be lost. To prevent this, the checksum should not be configured while a transaction is
in progress. The same applies to changes in the LIN interface mode from slave mode to master mode
and from master mode to slave mode.
21.5. Sleep Mode and Wake-Up
To reduce the system’s power consumption, the LIN Protocol Specification defines a Sleep Mode. The
message used to broadcast a Sleep Mode request must be transmitted by the LIN master application in
the same way as a normal transmit message. The LIN slave application must decode the Sleep Mode
Frame from the Identifier and data bytes. After that, it has to put the LIN slave node into the Sleep Mode by
setting the SLEEP bit (LIN0CTRL.6).
If the SLEEP bit (LIN0CTRL.6) of the LIN slave application is not set and there is no bus activity for four
seconds (specified bus idle timeout), the IDLTOUT bit (LIN0ST.6) is set and an interrupt request is gener-
ated. After that the application may assume that the LIN bus is in Sleep Mode and set the SLEEP bit
(LIN0CTRL.6).
Sending a wake-up signal from the master or any slave node terminates the Sleep Mode of the LIN bus.
To send a wake-up signal, the application has to set the WUPREQ bit (LIN0CTRL.1). After successful
transmission of the wake-up signal, the DONE bit (LIN0ST.0) of the master node is set and an interrupt
request is generated. The LIN slave does not generate an interrupt request after successful transmission
of the wake-up signal but it generates an interrupt request if the master does not respond to the wake-up
signal within 150 milliseconds. In that case, the ERROR bit (LIN0ST.2) and TOUT bit (LIN0ERR.2) are set.
The application then has to decide whether or not to transmit another wake-up signal.
All LIN nodes that detect a wake-up signal will set the WAKEUP (LIN0ST.1) and DONE bits (LIN0ST.0) and
generate an interrupt request. After that, the application has to clear the SLEEP bit (LIN0CTRL.6) in the
LIN slave.
21.6. Error Detection and Handling
The LIN controller generates an interrupt request and stops the processing of the current frame if it detects
an error. The application has to check the type of error by processing LIN0ERR. After that, it has to reset
the error register and the ERROR bit (LIN0ST.2) by writing a 1 to the RSTERR bit (LIN0CTRL.2). Starting
a new message with the LIN controller selected as master or sending a Wakeup signal with the LIN con-
troller selected as a master or slave is possible only if the ERROR bit (LIN0ST.2) is set to 0.
Bit 7 6 5 4 3 2 1 0
Name LIN0ADR[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name LIN0DAT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 1 1 0 0 0 0 0
Name Address Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
LIN0CTRL 0x08 STOP(s) SLEEP(s) TXRX DTACK(s) RSTINT RSTERR WUPREQ STREQ(m)
LIN0ST 0x09 ACTIVE IDLTOUT ABORT(s) DTREQ(s) LININT ERROR WAKEUP DONE
Note: These registers are used in both master and slave mode. The register bits marked with (m) are accessible only in
Master mode while the register bits marked with (s) are accessible only in slave mode. All other registers are
accessible in both modes.
Bit 7 6 5 4 3 2 1 0
Name DATAn[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Indirect Address: LIN0DT1 = 0x00, LIN0DT2 = 0x01, LIN0DT3 = 0x02, LIN0DT4 = 0x03, LIN0DT5 = 0x04,
LIN0DT6 = 0x05, LIN0DT7 = 0x06, LIN0DT8 = 0x07
Bit Name Function
7:0 DATAn[7:0] LIN Data Byte n.
Serial Data Byte that is received or transmitted across the LIN interface.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Type R R R R R R R R
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Type R R R R R R R R
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name DIVLSB[3:0]
Type R/W
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Reset 1 1 1 1 1 1 1 1
Bit 7 6 5 4 3 2 1 0
Name ID[5:0]
Type R R R/W
Reset 0 0 0 0 0 0 0 0
If the LINSIZE bits (LIN0SIZE[3:0]) are 1111b, bits ID[5:4] are used to determine the
data size and are interpreted as follows:
00: 2 bytes
01: 2 bytes
10: 4 bytes
11: 8 bytes
The CAN controller clock must be less than or equal to 25 MHz. If the CIP-51 system clock is above
25 MHz, the divider in the CAN0CFG register must be set to divide the CAN controller clock down to an
appropriate speed.
22.1.2. CAN Register Access
The CAN controller clock divider selected in the CAN0CFG SFR affects how the CAN registers can be
accessed. If the divider is set to 1, then a CAN SFR can immediately be read after it is written. If the divider
is set to a value other than 1, then a read of a CAN SFR that has just been written must be delayed by a
certain number of cycles. This delay can be performed using a NOP or some other instruction that does
not attempt to read the register. This access limitation applies to read and read-modify-write instructions
that occur immediately after a write. The full list of affected instructions is ANL, ORL, MOV, XCH, and XRL.
For example, with the CAN0CFG divider set to 1, the CAN0CN SFR can be accessed as follows:
MOV CAN0CN, #041 ; Enable access to Bit Timing Register
MOV R7, CAN0CN ; Copy CAN0CN to R7
With the CAN0CFG divider set to /2, the same example code requires an additional NOP:
MOV CAN0CN, #041 ; Enable access to Bit Timing Register
NOP ; Wait for write to complete
MOV R7, CAN0CN ; Copy CAN0CN to R7
The number of delay cycles required is dependent on the divider setting. With a divider of 2, the read must
wait for 1 system clock cycle. With a divider of 4, the read must wait 3 system clock cycles, and with the
divider set to 8, the read must wait 7 system clock cycles. The delay only needs to be applied when read-
ing the same register that was written. The application can write and read other CAN SFRs without any
delay.
22.1.3. Example Timing Calculation for 1 Mbit/Sec Communication
This example shows how to configure the CAN controller timing parameters for a 1 Mbit/Sec bit rate. Table
18.1 shows timing-related system parameters needed for the calculation.
Each bit transmitted on a CAN network has 4 segments (Sync_Seg, Prop_Seg, Phase_Seg1, and
Phase_Seg2), as shown in Figure 18.3. The sum of these segments determines the CAN bit time (1/bit
rate). In this example, the desired bit rate is 1 Mbit/sec; therefore, the desired bit time is 1000 ns.
The length of the 4 bit segments must be adjusted so that their sum is as close as possible to the desired
bit time. Since each segment must be an integer multiple of the time quantum (tq), the closest achievable
bit time is 24 tq (1000.008 ns), yielding a bit rate of 0.999992 Mbit/sec. The Sync_Seg is a constant 1 tq.
The Prop_Seg must be greater than or equal to the propagation delay of 400 ns and so the choice is 10 tq
(416.67 ns).
The remaining time quanta (13 tq) in the bit time are divided between Phase_Seg1 and Phase_Seg2 as
shown in. Based on this equation, Phase_Seg1 = 6 tq and Phase_Seg2 = 7 tq.
Bit 7 6 5 4 3 2 1 0
Type R R R R R R R/W
Reset 0 0 0 0 0 0 0 0
23. 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/20th 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. A block diagram of the SMBus peripheral and
the associated SFRs is shown in Figure 23.1.
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 23.3 illustrates a typical
SMBus transaction.
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.
23.3.5. SCL High (SMBus Free) Timeout
The SMBus specification stipulates that if the SCL and SDA lines remain high for more that 50 μs, the bus
is designated as free. When the SMBFTE bit in SMB0CF is set, the bus will be considered free if SCL and
SDA remain high for more than 10 SMBus clock source periods (as defined by the timer configured for the
SMBus clock source). If the SMBus is waiting to generate a Master START, the START will be generated
following this timeout. Note that a clock source is required for free timeout detection, even in a slave-only
implementation.
23.4. Using the SMBus
The SMBus can operate in both Master and Slave modes. The interface provides timing and shifting con-
trol for serial transfers; higher level protocol is determined by user software. The SMBus interface provides
the following application-independent features:
SMBus interrupts are generated for each data byte or slave address that is transferred. The point at which
the interrupt is generated depends on whether the hardware is acting as a data transmitter or receiver.
When a transmitter (i.e. sending address/data, receiving an ACK), this interrupt is generated after the ACK
cycle so that software may read the received ACK value; when receiving data (i.e. receiving address/data,
sending an ACK), this interrupt is generated before the ACK cycle so that software may define the outgo-
ing ACK value. See Section 23.5 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 23.4.2;
Table 23.4 provides a quick SMB0CN decoding reference.
23.4.1. SMBus Configuration Register
The SMBus Configuration register (SMB0CF) is used to enable the SMBus Master and/or Slave modes,
select the SMBus clock source, and select the SMBus timing and timeout options. When the ENSMB bit is
set, the SMBus is enabled for all master and slave events. Slave events may be disabled by setting the
INH bit. With slave events inhibited, the SMBus interface will still monitor the SCL and SDA pins; however,
the interface will NACK all received addresses and will not generate any slave interrupts. When the INH bit
is set, all slave events will be inhibited following the next START (interrupts will continue for the duration of
the current transfer).
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 23.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 “26. Timers” on page 266.
1
T HighMin = T LowMin = -------------------------------------------------
-
f ClockSourceOverflow
Equation 23.1. Minimum SCL High and Low Times
The selected clock source should be configured to establish the minimum SCL High and Low times as per
Equation 23.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 23.2.
f ClockSourceOverflow
BitRate = -------------------------------------------------
-
3
Equation 23.2. Typical SMBus Bit Rate
Figure 23.4 shows the typical SCL generation described by Equation 23.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 23.1.
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 23.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 “23.3.4. SCL Low Timeout” on page 229). 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 routine
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 23.4).
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name SMB0DAT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Vector Expected
Write
Next Status
ARBLOST
ACKRQ
Status
Vector
Mode
ACK
ACK
STO
STA
1110 0 0 X A master START was gener- Load slave address + R/W into 0 0 X 1100
ated. SMB0DAT.
1100 0 0 0 A master data or address byte Set STA to restart transfer. 1 0 X 1110
was transmitted; NACK Abort transfer. 0 1 X —
received.
0 0 1 A master data or address byte Load next data byte into 0 0 X 1100
was transmitted; ACK SMB0DAT.
received. End transfer with STOP. 0 1 X —
Master Transmitter
Vector Expected
Write
Next Status
ARBLOST
ACKRQ
Status
Vector
Mode
ACK
ACK
STO
STA
0100 0 0 0 A slave byte was transmitted; No action required (expecting 0 0 X 0001
NACK received. STOP condition).
0 0 1 A slave byte was transmitted; Load SMB0DAT with next data 0 0 X 0100
ACK received. byte to transmit.
Slave Transmitter
Figure 25.3. 3-Wire Single Master and 3-Wire Single Slave Mode Connection Diagram
Figure 25.4. 4-Wire Single Master Mode and 4-Wire Slave Mode Connection Diagram
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 1 1 1
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 1 1 0
Bit 7 6 5 4 3 2 1 0
Name SCR[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name SPI0DAT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
24. UART0
UART0 is an asynchronous, full duplex serial port offering a variety of data formatting options. A dedicated
baud rate generator with a 16-bit timer and selectable prescaler is included, which can generate a wide
range of baud rates (details in Section “24.1. Baud Rate Generator” on page 244). A received data FIFO
allows UART0 to receive up to three data bytes before data is lost and an overflow occurs.
UART0 has six associated SFRs. Three are used for the Baud Rate Generator (SBCON0, SBRLH0, and
SBRLL0), two are used for data formatting, control, and status functions (SCON0, SMOD0), and one is
used to send and receive data (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). If additional bytes are available in the Receive FIFO, the RI0 bit cannot be cleared by software.
SYSCLK
Baud Rate = ------------------------------------------------------------------------------ x 1--- x ------------------------
1
-
65536 – (SBRLH0:SBRLL0) 2 Prescaler
Table 24.1. Baud Rate Generator Settings for Standard Baud Rates
Target Baud Actual Baud Baud Rate Oscillator SB0PS[1:0] Reload Value in
Rate (bps) Rate (bps) Error Divide (Prescaler Bits) SBRLH0:SBRLL0
Factor
230400 230769 0.16% 208 11 0xFF98
115200 115385 0.16% 416 11 0xFF30
SYSCLK = 48
If the extra bit function is enabled (XBE0 = 1) and the parity function is disabled (PE0 = 0), the extra bit for
the oldest byte in the FIFO can be read from the RBX0 bit (SCON0.2). If the extra bit function is not
enabled, the value of the stop bit for the oldest FIFO byte will be presented in RBX0. When the parity func-
tion is enabled (PE0 = 1), hardware will check the received parity bit against the selected parity type
(selected with S0PT[1:0]) when receiving data. If a byte with parity error is received, the PERR0 flag will be
set to 1. This flag must be cleared by software. Note: when parity is enabled, the extra bit function is not
available.
24.3.3. Multiprocessor Communications
UART0 supports multiprocessor communication between a master processor and one or more slave pro-
cessors by special use of the extra data bit. When a master processor wants to transmit to one or more
slaves, it first sends an address byte to select the target(s). An address byte differs from a data byte in that
its extra bit is logic 1; in a data byte, the extra bit is always set to logic 0.
Setting the MCE0 bit (SMOD0.7) of a slave processor configures its UART such that when a stop bit is
received, the UART will generate an interrupt only if the extra bit is logic 1 (RBX0 = 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 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 trans-
missions 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).
Bit 7 6 5 4 3 2 1 0
Name OVR0 PERR0 THRE0 REN0 TBX0 RBX0 TI0 RI0
Type R/W R/W R R/W R/W R/W R/W R/W
Reset 0 0 1 0 0 0 0 0
SFR Address = 0x98; Bit-Addressable; SFR Page = 0x00
Bit Name Function
7 OVR0 Receive FIFO Overrun Flag.
0: Receive FIFO Overrun has not occurred
1: Receive FIFO Overrun has occurred; A received character has been discarded due
to a full FIFO.
6 PERR0 Parity Error Flag.
When parity is enabled, this bit indicates that a parity error has occurred. It is set to 1
when the parity of the oldest byte in the FIFO does not match the selected Parity Type.
0: Parity error has not occurred
1: Parity error has occurred.
This bit must be cleared by software.
5 THRE0 Transmit Holding Register Empty Flag.
0: Transmit Holding Register not Empty—do not write to SBUF0.
1: Transmit Holding Register Empty—it is safe to write to SBUF0.
4 REN0 Receive Enable.
This bit enables/disables the UART receiver. When disabled, bytes can still be read
from the receive FIFO.
0: UART1 reception disabled.
1: UART1 reception enabled.
3 TBX0 Extra Transmission Bit.
The logic level of this bit will be assigned to the extra transmission bit when XBE0 is set
to 1. This bit is not used when Parity is enabled.
2 RBX0 Extra Receive Bit.
RBX0 is assigned the value of the extra bit when XBE1 is set to 1. If XBE1 is cleared to
0, RBX1 will be assigned the logic level of the first stop bit. This bit is not valid when
Parity is enabled.
1 TI0 Transmit Interrupt Flag.
Set to a 1 by hardware after data has been transmitted, at the beginning of the STOP
bit. When the UART0 interrupt is enabled, setting this bit causes the CPU to vector to
the UART0 interrupt service routine. This bit must be cleared manually by software.
0 RI0 Receive Interrupt Flag.
Set to 1 by hardware when a byte of data has been received by UART0 (set at the
STOP bit sampling time). When the UART0 interrupt is enabled, setting this bit to 1
causes the CPU to vector to the UART0 interrupt service routine. This bit must be
cleared manually by software. Note that RI0 will remain set to ‘1’ as long as there is
data still in the UART FIFO. After the last byte has been shifted from the FIFO to
SBUF0, RI0 can be cleared.
Bit 7 6 5 4 3 2 1 0
Name MCE0 S0PT[1:0] PE0 S0DL[1:0] XBE0 SBL0
Type R/W R/W R R/W R/W R/W R/W R/W
Reset 0 0 0 0 1 1 0 0
SFR Address = 0xA9; SFR Page = 0x00
Bit Name Function
7 MCE0 Multiprocessor Communication Enable.
0: RI0 will be activated if stop bit(s) are 1.
1: RI0 will be activated if stop bit(s) and extra bit are 1. Extra bit must be enabled using
XBE0.
6:5 S0PT[1:0] Parity Type Select Bits.
00: Odd Parity
01: Even Parity
10: Mark Parity
11: Space Parity.
4 PE0 Parity Enable.
This bit enables hardware parity generation and checking. The parity type is selected
by bits S0PT[1:0] when parity is enabled.
0: Hardware parity is disabled.
1: Hardware parity is enabled.
3:2 S0DL[1:0] Data Length.
00: 5-bit data
01: 6-bit data
10: 7-bit data
11: 8-bit data
1 XBE0 Extra Bit Enable.
When enabled, the value of TBX0 will be appended to the data field
0: Extra Bit is disabled.
1: Extra Bit is enabled.
0 SBL0 Stop Bit Length.
0: Short—stop bit is active for one bit time
1: Long—stop bit is active for two bit times (data length = 6, 7, or 8 bits), or 1.5 bit times
(data length = 5 bits).
Bit 7 6 5 4 3 2 1 0
Name SBUF0[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
SFR Definition 24.5. SBRLH0: UART0 Baud Rate Generator Reload High Byte
Bit 7 6 5 4 3 2 1 0
Name SBRLH0[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
SFR Definition 24.6. SBRLL0: UART0 Baud Rate Generator Reload Low Byte
Bit 7 6 5 4 3 2 1 0
Name SBRLL0[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
26. 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 26.1 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 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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TL0[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TL1[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TH0[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TH1[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
26.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.
26.2.1. 16-bit Timer with Auto-Reload
When T2SPLIT (TMR2CN.3) is zero, Timer 2 operates as a 16-bit timer with auto-reload. Timer 2 can be
clocked by SYSCLK, SYSCLK divided by 12, or the external oscillator clock source divided by 8. As the
16-bit timer register increments and overflows from 0xFFFF to 0x0000, the 16-bit value in the Timer 2
reload registers (TMR2RLH and TMR2RLL) is loaded into the Timer 2 register as shown in Figure 26.4,
and the Timer 2 High Byte Overflow Flag (TMR2CN.7) is set. If Timer 2 interrupts are enabled (if IE.5 is
set), an interrupt will be generated on each Timer 2 overflow. Additionally, if Timer 2 interrupts are enabled
and the TF2LEN bit is set (TMR2CN.5), an interrupt will be generated each time the lower 8 bits (TMR2L)
overflow from 0xFF to 0x00.
T2MH T2XCLK TMR2H Clock Source T2ML T2XCLK TMR2L Clock Source
0 0 SYSCLK/12 0 0 SYSCLK/12
0 1 External Clock/8 0 1 External Clock/8
1 X SYSCLK 1 X SYSCLK
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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR2RLL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR2RLH[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR2L[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR2H[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
26.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.
26.3.1. 16-bit Timer with Auto-Reload
When T3SPLIT (TMR3CN.3) is zero, Timer 3 operates as a 16-bit timer with auto-reload. Timer 3 can be
clocked by SYSCLK, SYSCLK divided by 12, or the external oscillator clock source divided by 8. As the
16-bit timer register increments and overflows from 0xFFFF to 0x0000, the 16-bit value in the Timer 3
reload registers (TMR3RLH and TMR3RLL) is loaded into the Timer 3 register as shown in Figure 26.7,
and the Timer 3 High Byte Overflow Flag (TMR3CN.7) is set. If Timer 3 interrupts are enabled, an interrupt
will be generated on each Timer 3 overflow. Additionally, if Timer 3 interrupts are enabled and the TF3LEN
bit is set (TMR3CN.5), an interrupt will be generated each time the lower 8 bits (TMR3L) overflow from
0xFF to 0x00.
T3MH T3XCLK TMR3H Clock Source T3ML T3XCLK TMR3L Clock Source
0 0 SYSCLK/12 0 0 SYSCLK/12
0 1 External Clock/8 0 1 External Clock/8
1 X SYSCLK 1 X SYSCLK
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.
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR3RLL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR3RLH[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR3L[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name TMR3H[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
27. C2 Interface
C8051F50x/F51x devices include an on-chip Silicon Labs 2-Wire (C2) debug interface to allow Flash pro-
gramming and in-system debugging with the production part installed in the end application. The C2 inter-
face 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.
27.1. C2 Interface Registers
The following describes the C2 registers necessary to perform Flash programming through the C2 inter-
face. All C2 registers are accessed through the C2 interface as described in the C2 Interface Specification.
Bit 7 6 5 4 3 2 1 0
Name C2ADD[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name DEVICEID[7:0]
Type R/W
Reset 0 0 0 1 0 1 0 0
Bit 7 6 5 4 3 2 1 0
Name REVID[7:0]
Type R/W
Bit 7 6 5 4 3 2 1 0
Name FPCTL[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
C2 Address: 0x02
Bit Name Function
7:0 FPCTL[7:0] Flash Programming Control Register.
This register is used to enable Flash programming via the C2 interface. To enable C2
Flash programming, the following codes must be written in order: 0x02, 0x01. Note
that once C2 Flash programming is enabled, a system reset must be issued to
resume normal operation.
Bit 7 6 5 4 3 2 1 0
Name FPDAT[7:0]
Type R/W
Reset 0 0 0 0 0 0 0 0
C2 Address: 0xB4
Bit Name Function
7:0 FPDAT[7:0] C2 Flash Programming Data Register.
This register is used to pass Flash commands, addresses, and data during C2 Flash
accesses. Valid commands are listed below.
Code Command
0x06 Flash Block Read
0x07 Flash Block Write
0x08 Flash Page Erase
0x03 Device Erase
Note: The CEXn input signal must remain high or low for at least 2 system clock cycles to be recognized by the
hardware.
28.3.2. Software Timer (Compare) Mode
In Software Timer mode, the PCA counter/timer value is compared to the module's 16-bit capture/compare
register (PCA0CPHn and PCA0CPLn). When a match occurs, the Capture/Compare Flag (CCFn) in
PCA0CN is set to logic 1. An interrupt request is generated if the CCFn interrupt for that module is
enabled. The CCFn bit is not automatically cleared by hardware when the CPU vectors to the interrupt ser-
vice routine, and must be cleared by software. Setting the ECOMn and MATn bits in the PCA0CPMn regis-
ter enables Software Timer mode.
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Cap-
ture/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.
F PCA
F CEXn = ------------------------------------------
-
2 PCA0CPHn
Note: A value of 0x00 in the PCA0CPHn register is equal to 256 for this equation.
28.3.5. 8-bit, 9-bit, 10-bit and 11-bit Pulse Width Modulator Modes
Each module can be used independently to generate a pulse width modulated (PWM) output on its associ-
ated CEXn pin. The frequency of the output is dependent on the timebase for the PCA counter/timer, and
the setting of the PWM cycle length (8, 9, 10 or 11-bits). For backwards-compatibility with the 8-bit PWM
mode available on other devices, the 8-bit PWM mode operates slightly different than 9, 10 and 11-bit
PWM modes. It is important to note that all channels configured for 8/9/10/11-bit PWM mode will use
the same cycle length. It is not possible to configure one channel for 8-bit PWM mode and another for 11-
bit mode (for example). However, other PCA channels can be configured to Pin Capture, High-Speed Out-
put, Software Timer, Frequency Output, or 16-bit PWM mode independently.
28.3.5.1. 8-bit Pulse Width Modulator Mode
The duty cycle of the PWM output signal in 8-bit PWM mode is varied using the module's PCA0CPLn cap-
ture/compare register. When the value in the low byte of the PCA counter/timer (PCA0L) is equal to the
value in PCA0CPLn, the output on the CEXn pin will be set. When the count value in PCA0L overflows, the
CEXn output will be reset (see Figure 28.8). Also, when the counter/timer low byte (PCA0L) overflows from
0xFF to 0x00, PCA0CPLn is reloaded automatically with the value stored in the module’s capture/compare
high byte (PCA0CPHn) without software intervention. Setting the ECOMn and PWMn bits in the
PCA0CPMn register, and setting the CLSEL bits in register PCA0PWM to 00b enables 8-Bit Pulse Width
Modulator mode. If the MATn bit is set to 1, the CCFn flag for the module will be set each time an 8-bit
comparator match (rising edge) occurs. The COVF flag in PCA0PWM can be used to detect the overflow
(falling edge), which will occur every 256 PCA clock cycles. The duty cycle for 8-Bit PWM Mode is given in
Equation 28.2.
Important Note About Capture/Compare Registers: When writing a 16-bit value to the PCA0 Cap-
ture/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.
256 – PCA0CPHn
Duty Cycle = -------------------------------------------------------
256
Equation 28.2. 8-Bit PWM Duty Cycle
Using Equation 28.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.
2 N – PCA0CPn
Duty Cycle = ------------------------------------------------
2N
Equation 28.3. 9, 10, and 11-Bit PWM Duty Cycle
A 0% duty cycle may be generated by clearing the ECOMn bit to 0.
65536 – PCA0CPn
Duty Cycle = ---------------------------------------------------------
65536
Equation 28.4. 16-Bit PWM Duty Cycle
Using Equation 28.4, 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.
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 bit (CR) will read zero if the WDT is enabled but
user software has not enabled the PCA counter. If a match occurs between PCA0CPH5 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 PCA0CPH5. Upon a PCA0CPH5 write, PCA0H plus the offset held in PCA0CPL5 is
loaded into PCA0CPH5 (See Figure 28.11).
Note that the 8-bit offset held in PCA0CPH5 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 28.5, where PCA0L is the value of the PCA0L register
at the time of the update.
Bit 7 6 5 4 3 2 1 0
Name CF CR CCF5 CCF4 CCF3 CCF2 CCF1 CCF0
Type R/W R/W R/W R/W R/W R/W R/W R/W
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 1 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0
SFR Addresses: PCA0CPM0 = 0xDA, PCA0CPM1 = 0xDB, PCA0CPM2 = 0xDC; PCA0CPM3 = 0xDD,
PCA0CPM4 = 0xDE, PCA0CPM5 = 0xDF, SFR Page (all registers) = 0x00
Bit Name Function
7 PWM16n 16-bit Pulse Width Modulation Enable.
This bit enables 16-bit mode when Pulse Width Modulation mode is enabled.
0: 8 to 11-bit PWM selected.
1: 16-bit PWM selected.
6 ECOMn Comparator Function Enable.
This bit enables the comparator function for PCA module n when set to 1.
5 CAPPn Capture Positive Function Enable.
This bit enables the positive edge capture for PCA module n when set to 1.
4 CAPNn Capture Negative Function Enable.
This bit enables the negative edge capture for PCA module n when set to 1.
3 MATn Match Function Enable.
This bit enables the match function for PCA module n when set to 1. When enabled,
matches of the PCA counter with a module's capture/compare register cause the CCFn
bit in PCA0MD register to be set to logic 1.
2 TOGn Toggle Function Enable.
This bit enables the toggle function for PCA module n when set to 1. When enabled,
matches of the PCA counter with a module's capture/compare register cause the logic
level on the CEXn pin to toggle. If the PWMn bit is also set to logic 1, the module oper-
ates in Frequency Output Mode.
1 PWMn Pulse Width Modulation Mode Enable.
This bit enables the PWM function for PCA module n when set to 1. When enabled, a
pulse width modulated signal is output on the CEXn pin. 8 to 11-bit PWM is used if
PWM16n is cleared; 16-bit mode is used if PWM16n is set to logic 1. If the TOGn bit is
also set, the module operates in Frequency Output Mode.
0 ECCFn Capture/Compare Flag Interrupt Enable.
This bit sets the masking of the Capture/Compare Flag (CCFn) interrupt.
0: Disable CCFn interrupts.
1: Enable a Capture/Compare Flag interrupt request when CCFn is set.
Note: When the WDTE bit is set to 1, the PCA0CPM5 register cannot be modified, and module 5 acts as the
watchdog timer. To change the contents of the PCA0CPM5 register or the function of module 5, the Watchdog
Timer must be disabled.
Bit 7 6 5 4 3 2 1 0
Name PCA0[7:0]
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name PCA0[15:8]
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Name PCA0CPn[7:0]
Reset 0 0 0 0 0 0 0 0
SFR Addresses: PCA0CPL0 = 0xFB, PCA0CPL1 = 0xE9, PCA0CPL2 = 0xEB, PCA0CPL3 = 0xED,
PCA0CPL4 = 0xFD, PCA0CPL5 = 0xCE; SFR Page (all registers) = 0x00
Bit Name Function
7:0 PCA0CPn[7:0] PCA Capture Module Low Byte.
The PCA0CPLn register holds the low byte (LSB) of the 16-bit capture module n.
This register address also allows access to the low byte of the corresponding
PCA channel’s auto-reload value for 9, 10, or 11-bit PWM mode. The ARSEL bit
in register PCA0PWM controls which register is accessed.
Note: A write to this register will clear the module’s ECOMn bit to a 0.
Bit 7 6 5 4 3 2 1 0
Name PCA0CPn[15:8]
Reset 0 0 0 0 0 0 0 0
SFR Addresses: PCA0CPH0 = 0xFC, PCA0CPH1 = 0xEA, PCA0CPH2 = 0xEC, PCA0CPH3 = 0xEE,
PCA0CPH4 = 0xFE, PCA0CPH5 = 0xCF; SFR Page (all registers) = 0x00
Bit Name Function
7:0 PCA0CPn[15:8] PCA Capture Module High Byte.
The PCA0CPHn register holds the high byte (MSB) of the 16-bit capture module n.
This register address also allows access to the high byte of the corresponding
PCA channel’s auto-reload value for 9, 10, or 11-bit PWM mode. The ARSEL bit in
register PCA0PWM controls which register is accessed.
Note: A write to this register will set the module’s ECOMn bit to a 1.
Disclaimer
Silicon Labs intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software imple-
menters using or intending to use the Silicon Labs products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each
specific device, and “Typical” parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon
Labs reserves the right to make changes without further notice to the product information, specifications, and descriptions herein, and does not give warranties as to the
accuracy or completeness of the included information. Without prior notification, Silicon Labs may update product firmware during the manufacturing process for security or
reliability reasons. Such changes will not alter the specifications or the performance of the product. Silicon Labs shall have no liability for the consequences of use of the infor-
mation supplied in this document. This document does not imply or expressly grant any license to design or fabricate any integrated circuits. The products are not designed or
authorized to be used within any FDA Class III devices, applications for which FDA premarket approval is required or Life Support Systems without the specific written consent
of Silicon Labs. A “Life Support System” is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in
significant personal injury or death. Silicon Labs products are not designed or authorized for military applications. Silicon Labs products shall under no circumstances be used
in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons. Silicon Labs disclaims
all express and implied warranties and shall not be responsible or liable for any injuries or damages related to use of a Silicon Labs product in such unauthorized applications.
Note: This content may contain offensive terminology that is now obsolete. Silicon Labs is replacing these terms with inclusive language wherever possible. For more
information, visit www.silabs.com/about-us/inclusive-lexicon-project
Trademark Information
Silicon Laboratories Inc. ® , Silicon Laboratories ® , Silicon Labs ® , SiLabs ® and the Silicon Labs logo ® , Bluegiga ® , Bluegiga Logo ® , EFM ® , EFM32 ® , EFR, Ember® , Energy Micro, Energy
Micro logo and combinations thereof, “the world’s most energy friendly microcontrollers”, Redpine Signals ® , WiSeConnect , n-Link, ThreadArch ® , EZLink® , EZRadio ® , EZRadioPRO ® ,
Gecko ® , Gecko OS, Gecko OS Studio, Precision32 ® , Simplicity Studio ® , Telegesis, the Telegesis Logo ® , USBXpress ® , Zentri, the Zentri logo and Zentri DMS, Z-Wave ® , and others
are trademarks or registered trademarks of Silicon Labs. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered
trademark of ARM Limited. Wi-Fi is a registered trademark of the Wi-Fi Alliance. All other products or brand names mentioned herein are trademarks of their respective holders.
www.silabs.com
Mouser Electronics
Authorized Distributor
Silicon Laboratories:
C8051F500-IMR C8051F500-IQR C8051F501-IMR C8051F501-IQR C8051F502-IMR C8051F502-IQR
C8051F503-IMR C8051F503-IQR C8051F504-IMR C8051F504-IQR C8051F505-IMR C8051F505-IQR C8051F506-
IMR C8051F506-IQR C8051F507-IMR C8051F507-IQR C8051F508-IMR C8051F509-IMR C8051F510-IMR
C8051F511-IMR C8051F506-IM C8051F505-IM C8051F505-IQ C8051F503-IM C8051F503-IQ C8051F500-IQ
C8051F502-IQ C8051F501-IM C8051F507-IM C8051F504-IM C8051F501-IQ C8051F504-IQ C8051F500-IM
C8051F507-IQ C8051F502-IM C8051F506-IQ C8051F508-IM C8051F509-IM C8051F510-IM C8051F511-IM
C8051F500-AM C8051F501-AM C8051F501-AMR C8051F501-AQ C8051F501-AQR C8051F502-AM C8051F507-
AQR C8051F500-AMR C8051F500-AQR C8051F500-AQ C8051F506-AMR C8051F506-AQ C8051F506-AQR
C8051F507-AM C8051F507-AMR C8051F507-AQ C8051F503-AQR C8051F504-AQ C8051F504-AQR C8051F505-
AQ C8051F505-AQR C8051F506-AM C8051F502-AMR C8051F502-AQ C8051F502-AQR C8051F503-AM
C8051F503-AMR C8051F503-AQ C8051F505-AM C8051F511-AMR C8051F504-AM C8051F509-AM C8051F509-
AMR C8051F510-AM C8051F504-AMR C8051F505-AMR C8051F511-AM C8051F508-AMR C8051F508-AM
C8051F510-AMR