The C8051F04x family of devices are fully integrated mixed-signal System-on-a-Chip MCUs with 64 digital
I/O pins (C8051F040/2/4/6) or 32 digital I/O pins (C8051F041/3/5/7), and an integrated CAN 2.0B controller. Highlighted features are listed below; refer to Table 1.1 for specific product feature selection.
•High-Speed pipelined 8051-compatible CIP-51 microcontroller core (up to 25 MIPS)
•Controller Area Network (CAN 2.0B) Controller with 32 message objects, each with its own indentifier
mask.
•True 12-bit (C8051F040/1) or 10-bit (C8051F042/3/4/5/6/7) 100 ksps 8-channel ADC with PGA and
analog multiplexer
•High Voltage Difference Amplifier input to the 12/10-bit ADC (60 V Peak-to-Peak) with programmable
gain.
•True 8-bit 500 ksps 8-channel ADC with PGA and analog multiplexer (C8051F040/1/2/3)
•Two 12-bit DACs with programmable update scheduling (C8051F040/1/2/3)
•64 kB (C8051F040/1/2/3/4/5) or 32 kB (C8051F046/7) of in-system programmable Flash memory
•4352 (4096 + 256) bytes of on-chip RAM
•External Data Memory Interface with 64 kB address space
•SPI, SMBus/I2C, and (2) UART serial interfaces implemented in hardware
•Five general purpose 16-bit Timers
•Programmable Counter/Timer Array with six capture/compare modules
•On-chip Watchdog Timer, VDD Monitor, and Temperature Sensor
With on-chip VDD monitor, Watchdog Timer, and clock oscillator, the C8051F04x family of devices are truly
stand-alone System-on-a-Chip solutions. All analog and digital peripherals are enabled/disabled and con-
figured by user firmware. The Flash memory can be reprogrammed even in-circuit, providing non-volatile
data storage, and also allowing field upgrades of the 8051 firmware.
On-board JTAG debug circuitry allows non-intrusive (uses no on-chip resources), full speed, in-circuit programming and debugging using the production MCU installed in the final application. This debug system
supports inspection and modification of memory and registers, setting breakpoints, watchpoints, single
stepping, Run, and Halt commands. All analog and digital peripherals are fully functional while debugging
using JTAG.
Each MCU is specified for 2.7 V to 3.6 V operation over the industrial temperature range (–45 to +85 °C).
The Port I/Os, /RST, and JTAG pins are tolerant for input signals up to 5 V. The C8051F040/2/4/6 are available in a 100-pin TQFP and the C8051F041/3/5/7 are available in a 64-pin TQFP.
Rev. 1.419
C8051F040/1/2/3/4/5/6/7
Table 1.1. Product Selection Guide
C and SPI
2
MIPS (Peak)
Flash Memory
RAM
External Memory Interface
SMBus/I
CAN
UARTS
C8051F040 25 64 kB 4352
3 3 3
25
Timers (16-bit)
3
Programmable Counter Array
Digital Port I/O’s
12-bit 100ksps ADC
10-bit 100ksps ADC
8-bit 500ksps ADC Inputs
High Voltage Diff Amp
Voltage Reference
Temperature Sensor
DAC Resolution (bits)
DAC Outputs
64
3
-8
3 3 3
Analog Comparators
1223 100TQFP
Package
C8051F041 25 64 kB 4352
C8051F042 25 64 kB 4352
C8051F043 25 64 kB 4352
C8051F044 25 64 kB 4352
C8051F045 25 64 kB 4352
C8051F046 25 32 kB 4352
C8051F047 25 32 kB 4352
3 3 3
3 3 3
3 3 3
3 3 3
3 3 3
3 3 3
3 3 3
25
25
25
25
25
25
25
3
3
3
3
3
3
3
32
64 -
32 -
64 -
32 -
64 -
32 -
3
-8
3
8
3
8
33 3 3
33 3 3
33 3 3
33 3 3
3 3 3
3 3 3
3 3 3
122364TQFP
1223 100TQFP
122364TQFP
3 100TQFP
364TQFP
3 100TQFP
364TQFP
20Rev. 1.4
VDD
VDD
VDD
DGND
DGND
DGND
AV+
AV+
AV+
AGND
AGND
AGND
TCK
TMS
TDI
TDO
/RST
MONEN
XTAL1
XTAL2
VREF
VREFD
DAC1
DAC0
VREF0
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN+
HVAIN-
HVREF
HVCAP
Digital Power
Analog Power
JTAG
Logic
V
DD
Monitor
External
Oscillator
Circuit
A
M
U
X
HVAMP
VREF
DAC1
(12-Bit)
DAC0
(12-Bit)
Prog
Gain
Boundary Scan
Debug HW
WDT
Internal
Oscillator
TEMP
SENSOR
Reset
System
Clock
ADC
100 ksps
(12 or 10-
Bit)
A
M
U
X
8
SFR Bus
0
5
Memories
1
64 kB
Flash
C
o
r
e
External Memory Data
8:2
32x136
CANRAM
256 byte
RAM
4 kB
RAM
Bus
C8051F040/1/2/3/4/5/6/7
UART0
UART1
SMBus
SPI Bus
PCA
Timers
0,1,2,3,4
Port
0,1,2,3
&4
Latches
CAN
2.0B
Bus Control
Address [15:0]
Data [7:0]
C
R
O
S
S
B
A
R
ADC
500 ksps
(8-Bit)
CP0
CP1
+
CP2
-
Port 4 <from crossbar>
Ctrl Latch
P5 Latch
Addr [15:8]
P6 Latch
Addr [7:0]
P7 Latch
Data Latch
P0
Drv
P1
Drv
P2
Drv
P3
Drv
A
M
Prog
8:1
Gain
U
X
P2.6
+
P2.7
-
+
-
P2.2
P2.3
P2.4
P2.5
P4
DRV
P5
DRV
P6
DRV
P7
DRV
P0.0
P0.7
P1.0
P1.7
P2.0
P2.7
P3.0
P3.7
CANTX
CANRX
VREF2
P4.0
P4.4
P4.5/ALE
P4.6/RD
P4.7/WR
P5.0/A8
P5.7/A51
P6.0/A0
P6.7/A7
P7.0/D0
P7.7/D7
Figure 1.1. C8051F040/2 Block Diagram
Rev. 1.421
C8051F040/1/2/3/4/5/6/7
VDD
VDD
VDD
DGND
DGND
DGND
AV+
AV+
AGND
AGND
TCK
TMS
TDI
TDO
/RST
MONEN
XTAL1
XTAL2
VREF
DAC1
DAC0
VREFA
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN+
HVAIN-
HVREF
HVCAP
Digital Power
Analog Power
JTAG
Logic
V
DD
Monitor
External
Oscillator
Circuit
A
M
U
X
HVAMP
VREF
DAC1
(12-Bit)
DAC0
(12-Bit)
Prog
Boundary Scan
Debug HW
WDT
Internal
Oscillator
Gain
TEMP
SENSOR
Reset
System
Clock
ADC
100 ksps
(12 or 10-
Bit)
A
M
U
X
8
0
SFR Bus
5
1
C
o
Memories
32x136
CANRAM
r
256 byte
e
External Memory Data
8:2
64 kB
Flash
RAM
4 kB
RAM
Bus
UART0
UART1
SMBus
SPI Bus
PCA
Timers
0,1,2,3,4
Port
0,1,2,3
&4
Latches
CAN
2.0B
Bus Control
Address [15:0]
Data [7:0]
C
R
O
S
S
B
A
R
ADC
500 ksps
(8-Bit)
VREFA
CP0
CP1
+
CP2
-
Port 4 <from crossbar>
Ctrl Latch
P5 Latch
Addr [15:8]
P6 Latch
Addr [7:0]
P7 Latch
Data Latch
P0
Drv
P1
Drv
P2
Drv
P3
Drv
A
M
Prog
8:1
Gain
U
X
P2.6
+
P2.7
-
+
-
P2.2
P2.3
P2.4
P2.5
P4
DRV
P5
DRV
P6
DRV
P7
DRV
P0.0
P0.7
P1.0
P1.7
P2.0
P2.7
P3.0
P3.7
CANTX
CANRX
Figure 1.2. C8051F041/3 Block Diagram
22Rev. 1.4
VDD
VDD
VDD
DGND
DGND
DGND
AV+
AV+
AV+
AGND
AGND
AGND
TCK
TMS
TDI
TDO
/RST
MONEN
XTAL1
XTAL2
VREF
VREF0
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN+
HVAIN-
HVREF
HVCAP
Digital Power
Analog Power
JTAG
Logic
V
DD
Monitor
External
Oscillator
Circuit
A
M
U
X
HVAMP
VREF
Prog
Gain
Boundary Scan
Debug HW
WDT
Internal
Oscillator
TEMP
SENSOR
Reset
System
Clock
ADC
100 ksps
(10-Bit)
A
M
U
X
8
0
SFR Bus
5
1
C
o
e
8:2
Memories
64/32 kB
Flash
32x136
CANRAM
r
256 byte
RAM
4 kB
RAM
External Memory Data
Bus
C8051F040/1/2/3/4/5/6/7
UART0
UART1
SMBus
SPI Bus
PCA
Timers
0,1,2,3,4
Port
0,1,2,3
&4
Latches
CAN
2.0B
Bus Control
Address [15:0]
Data [7:0]
C
R
O
S
S
B
A
R
CP0
CP1
+
CP2
-
Port 4 <from crossbar>
Ctrl Latch
P5 Latch
Addr [15:8]
P6 Latch
Addr [7:0]
P7 Latch
Data Latch
P0
Drv
P1
Drv
P2
Drv
P3
Drv
P2.6
+
P2.7
-
+
-
P2.2
P2.3
P2.4
P2.5
P4
DRV
P5
DRV
P6
DRV
P7
DRV
P0.0
P0.7
P1.0
P1.7
P2.0
P2.7
P3.0
P3.7
CANTX
CANRX
P4.0
P4.4
P4.5/ALE
P4.6/RD
P4.7/WR
P5.0/A8
P5.7/A51
P6.0/A0
P6.7/A7
P7.0/D0
P7.7/D7
Figure 1.3. C8051F044/6 Block Diagram
Rev. 1.423
C8051F040/1/2/3/4/5/6/7
VDD
VDD
VDD
DGND
DGND
DGND
AV+
AV+
AGND
AGND
TCK
TMS
TDI
TDO
/RST
MONEN
XTAL1
XTAL2
VREF
VREFA
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN+
HVAIN-
HVREF
HVCAP
Digital Power
Analog Power
JTAG
Logic
V
DD
Monitor
External
Oscillator
Circuit
A
M
U
X
HVAMP
VREF
Prog
Gain
Boundary Scan
Debug HW
WDT
Internal
Oscillator
TEMP
SENSOR
Reset
System
Clock
ADC
100 ksps
(10-Bit)
A
M
U
X
8
0
SFR Bus
5
1
C
o
Memories
64/32 kB
32x136
CANRAM
r
256 byte
e
External Memory Data
8:2
Flash
RAM
4 kB
RAM
Bus
UART0
UART1
SMBus
SPI Bus
PCA
Timers
0,1,2,3,4
Port
0,1,2,3
&4
Latches
CAN
2.0B
Bus Control
Address [15:0]
Data [7:0]
C
R
O
S
S
B
A
R
CP0
+
CP1
+
CP2
-
Port 4 <from crossbar>
Ctrl Latch
P5 Latch
Addr [15:8]
P6 Latch
Addr [7:0]
P7 Latch
Data Latch
P0
Drv
P1
Drv
P2
Drv
P3
Drv
P2.6
+
P2.7
-
P2.2
-
P2.3
P2.4
P2.5
P4
DRV
P5
DRV
P6
DRV
P7
DRV
P0.0
P0.7
P1.0
P1.7
P2.0
P2.7
P3.0
P3.7
CANTX
CANRX
Figure 1.4. C8051F045/7 Block Diagram
24Rev. 1.4
C8051F040/1/2/3/4/5/6/7
1.1.CIP-51™ Microcontroller Core
1.1.1. Fully 8051 Compatible
The C8051F04x family of devices utilizes Silicon Labs' proprietary CIP-51 microcontroller core. The CIP51 is fully compatible with the MCS-51™ instruction set; standard 803x/805x assemblers and compilers
can be used to develop software. The core has all the peripherals included with a standard 8052, including
five 16-bit counter/timers, two full-duplex UARTs, 256 bytes of internal RAM, 128 byte Special Function
Register (SFR) address space, and up to 8 byte-wide I/O Ports.
1.1.2. Improved Throughput
The CIP-51 employs a pipelined architecture that greatly increases its instruction throughput over the standard 8051 architecture. In a standard 8051, all instructions except for MUL and DIV take 12 or 24 system
clock cycles to execute with a maximum system clock of 12-to-24 MHz. By contrast, the CIP-51 core executes 70% of its instructions in one or two system clock cycles, with only four instructions taking more than
four system clock cycles.
The CIP-51 has a total of 109 instructions. The table below shows the total number of instructions that
require each execution time.
Clocks to Execute122/333/444/558
Number of Instructions265051473121
With the CIP-51's maximum system clock at 25 MHz, it has a peak throughput of 25 MIPS. Figure 1.5
shows a comparison of peak throughputs of various 8-bit microcontroller cores with their maximum system
clocks.
25
20
15
MIPS
10
5
Silicon Labs
CIP-51
(25 MHz clk)
Microchip
PIC17C75x
(33 MHz clk)
Philips
80C51
(33 MHz clk)
ADuC812
8051
(16 MHz clk)
Figure 1.5. Comparison of Peak MCU Execution Speeds
Rev. 1.425
C8051F040/1/2/3/4/5/6/7
1.1.3. Additional Features
The C8051F04x MCU family includes several key enhancements to the CIP-51 core and peripherals to
improve overall performance and ease of use in end applications.
The extended interrupt handler provides 20 interrupt sources into the CIP-51 (as opposed to 7 for the standard 8051), allowing the numerous analog and digital peripherals to interrupt the controller. An interrupt
driven system requires less intervention by the MCU, giving it more effective throughput. The extra interrupt sources are very useful when building multi-tasking, real-time systems.
There are up to seven reset sources for the MCU: an on-board V
monitor, a Watchdog Timer, a missing
DD
clock detector, a voltage level detection from Comparator0, a forced software reset, the CNVSTR0 input
pin, and the /RST pin. The /RST pin is bi-directional, accommodating an external reset, or allowing the
internally generated POR to be output on the /RST pin. Each reset source except for the V
Reset Input pin may be disabled by the user in software; the V
monitor is enabled/disabled via the
DD
monitor and
DD
MONEN pin. The Watchdog Timer may be permanently enabled in software after a power-on reset during
MCU initialization.
The MCU has an internal, stand alone clock generator which is used by default as the system clock after
any reset. If desired, the clock source may be switched on the fly to the external oscillator, which can use a
crystal, ceramic resonator, capacitor, RC, or external clock source to generate the system clock. This can
be extremely useful in low power applications, allowing the MCU to run from a slow (power saving) external crystal source, while periodically switching to the fast (up to 25 MHz) internal oscillator as needed.
V
DD
(Port I/O)
CP0+
CP0-
Crossbar
CNVSTR
(CNVSTR
reset
enable)
Comparator0
+
-
(CP0
reset
enable)
Missing
Clock
Detector
(one-
shot)
EN
WDT
EN
Supply
Monitor
+
-
PRE
Supply
Reset
Timeout
(wired-OR)
Reset
Funnel
RST
WDT
Enable
Enable
CIP-51
Core
Extended Interrupt
Handler
XTAL1
XTAL2
Internal
Clock
Generator
OSC
System
Clock
Clock Select
MCD
Microcontroller
Figure 1.6. On-Board Clock and Reset
26Rev. 1.4
WDT
Strobe
Software Reset
System Reset
C8051F040/1/2/3/4/5/6/7
1.2.On-Chip Memory
The CIP-51 has a standard 8051 program and data address configuration. It includes 256 bytes of data
RAM, with the upper 128 bytes dual-mapped. Indirect addressing accesses the upper 128 bytes of general
purpose RAM, and direct addressing accesses the 128 byte SFR address space. The CIP-51 SFR
address space contains up to 256 SFR Pages. In this way, the CIP-51 MCU can accommodate the many
SFR’s required to control and configure the various peripherals featured on the device. The lower
128 bytes of RAM are accessible via direct and indirect addressing. The first 32 bytes are addressable as
four banks of general purpose registers, and the next 16 bytes can be byte addressable or bit addressable.
The CIP-51 in the C8051F04x MCUs additionally has an on-chip 4 kB RAM block and an external memory
interface (EMIF) for accessing off-chip data memory or memory-mapped peripherals. The on-chip 4 byte
block can be addressed over the entire 64 kB external data memory address range (overlapping 4 kB
boundaries). External data memory address space can be mapped to on-chip memory only, off-chip memory only, or a combination of the two (addresses up to 4 kB directed to on-chip, above 4 kB directed to
EMIF). The EMIF is also configurable for multiplexed or non-multiplexed address/data lines.
The MCU's program memory consists of 64 kB (C8051F040/1/2/3/4/5) or 32 kB (C8051F046/7) of Flash.
This memory may be reprogrammed in-system in 512 byte sectors, and requires no special off-chip programming voltage. The 512 bytes from addresses 0xFE00 to 0xFFFF are reserved for the 64 kB devices.
There is also a single 128 byte sector at address 0x10000 to 0x1007F, which may be useful as a small
table for software constants. See Figure 1.7 for the MCU system memory map.
PROGRAM/DATA MEMORY
(FLASH)
C8051F040/1/2/3/4/5
0x1007F
0x10000
0xFE00
0xFDFF
0x0000
0x1007F
0x10000
0x8000
0x7FFF
Scrachpad Memory
(DATA only)
RESERVED
64 kB
Flash
(In-System
Programmable in 512
Byte Sectors)
C8051F046/7
Scrachpad Memory
(DATA only)
RESERVED
32 kB
Flash
(In-System
Programmable in 512
Byte Sectors)
0xFF
0x80
0x7F
0x30
0x2F
0x20
0x1F
0x00
0xFFFF
0x1000
0x0FFF
0x0000
DATA MEMORY (RAM)
INTERNAL DATA ADDRESS SPACE
Upper 128 RAM
(Indirect Addressing
Only)
(Direct and Indirect
Addressing)
Bit Addressable
General Purpose
Registers
Special Function
Registers
(Direct Addressing Only)
Lower 128 RAM
(Direct and Indirect
Addressing)
EXTERNAL DATA ADDRESS SPACE
Off-chip XRAM space
XRAM - 4096 Bytes
(accessable using MOVX
instruction)
0
1
2
3
F
Up To
256 SFR Pages
0x0000
Figure 1.7. On-Chip Memory Map
Rev. 1.427
C8051F040/1/2/3/4/5/6/7
1.3.JTAG Debug and Boundary Scan
The C8051F04x family has on-chip JTAG boundary scan and debug circuitry that provides non-intrusive,
full speed, in-circuit debugging using the production part installed in the end application, via the four-pin
JTAG interface. The JTAG port is fully compliant to IEEE 1149.1, providing full boundary scan for test and
manufacturing purposes.
Silicon Labs' debugging system supports inspection and modification of memory and registers, breakpoints, watchpoints, a stack monitor, and single stepping. No additional target RAM, program memory, timers, or communications channels are required. All the digital and analog peripherals are functional and
work correctly while debugging. All the peripherals (except for the ADC and SMBus) are stalled when the
MCU is halted, during single stepping, or at a breakpoint in order to keep them synchronized with instruction execution.
The C8051F040DK development kit provides all the hardware and software necessary to develop application code and perform in-circuit debugging with the C8051F04x MCUs. The development kit includes two
target boards and a cable to facilitate evaluating a simple CAN communication network. The kit also
includes software with a developer's studio and debugger, a target application board with the associated
MCU installed, and the required cables and wall-mount power supply. The Serial Adapter takes its power
from the application board; it requires roughly 20 mA at 2.7-3.6 V. For applications where there is not sufficient power available from the target system, the provided power supply can be connected directly to the
Serial Adapter.
Silicon Labs’ debug environment is a vastly superior configuration for developing and debugging embedded applications compared to standard MCU emulators, which use on-board "ICE Chips" and target cables
and require the MCU in the application board to be socketed. Silicon Labs' debug environment both
increases ease of use and preserves the performance of the precision, on-chip analog peripherals.
Integrated Development
Environment
WINDO WS 95 o r later
Serial
Adapter
JTAG (x4), VDD, GND
VDD GND
C8051
TARGET PCB
F040
Figure 1.8. Development/In-System Debug Diagram
28Rev. 1.4
C8051F040/1/2/3/4/5/6/7
1.4.Programmable Digital I/O and Crossbar
The standard 8051 Ports (0, 1, 2, and 3) are available on the MCUs. The C8051F040/2/4/6 have 4 additional 8-bit ports (4, 5, 6, and 7) for a total of 64 general-purpose I/O Ports. The Ports behave like the standard 8051 with a few enhancements.
Each port pin can be configured as either a push-pull or open-drain output. Also, the "weak pullups" which
are normally fixed on an 8051 can be globally disabled, providing additional power saving capabilities for
low-power applications.
Perhaps the most unique enhancement is the Digital Crossbar. This is essentially a large digital switching
network that allows mapping of internal digital system resources to Port I/O pins on P0, P1, P2, and P3
(See Figure 1.9). Unlike microcontrollers with standard multiplexed digital I/O ports, all combinations of
functions are supported with all package options offered.
The on-chip counter/timers, serial buses, HW interrupts, ADC Start of Conversion input, comparator outputs, and other digital signals in the controller can be configured to appear on the Port I/O pins specified in
the Crossbar Control registers. This allows the user to select the exact mix of general purpose Port I/O and
digital resources needed for the particular application.
XBR0, XBR1, XBR2,
Highest
Priority
Lowest
Priority
Port
Latches
(Internal Digital Signals)
UART0
SPI
SMBus
UART1
PCA
Comptr.
Outputs
T0, T1,
T2, T2EX,
T3, T3EX,
T4,T4EX,
/INT0,
/INT1
/SYSCLK
CNVSTR0
CNVSTR2
P0
P1
P2
P3
8
(P0.0-P0.7)
8
(P1.0-P1.7)
8
(P2.0-P2.7)
8
(P3.0-P3.7)
2
4
2
2
6
2
XBR3 P1MDIN,
P2MDIN, P3MDIN
Registers
Priority
Decoder
Digital
Crossbar
8
To External
Memory
Interface
(EMIF)
P0MDOUT, P1MDOUT,
P2MDOUT, P3MDOUT
Registers
8
8
8
8
P0
I/O
Cells
P1
I/O
Cells
P2
I/O
Cells
P3
I/O
Cells
To
ADC2
Input
To
Comparators
To
ADC0
Input
External
Pins
P0.0
P0.7
P1.0
P1.7
P2.0
P2.7
P3.0
P3.7
Highest
Priority
Lowest
Priority
Figure 1.9. Digital Crossbar Diagram
Rev. 1.429
C8051F040/1/2/3/4/5/6/7
1.5.Programmable Counter Array
The C8051F04x MCU family includes an on-board Programmable Counter/Timer Array (PCA) in addition
to the five 16-bit general purpose counter/timers. The PCA consists of a dedicated 16-bit counter/timer
time base with six programmable capture/compare modules. The timebase is clocked from one of six
sources: the system clock divided by 12, the system clock divided by 4, Timer 0 overflow, an External
Clock Input (ECI pin), the system clock, or the external oscillator source divided by 8.
Each capture/compare module can be configured to operate in one of six modes: Edge-Triggered Capture,
Software Timer, High Speed Output, Frequency Output, 8-Bit Pulse Width Modulator, or 16-Bit Pulse Width
Modulator. The PCA Capture/Compare Module I/O and External Clock Input are routed to the MCU Port
I/O via the Digital Crossbar.
SYSCLK/12
SYSCLK/4
Timer 0 Overflow
ECI
SYSCLK
External Clock/8
PCA
CLOCK
MUX
16-Bit Counter/Timer
ECI
Capture/Compare
Module 0
CEX0
Capture/Compare
Module 1
CEX1
Capture/Compare
Module 2
CEX2
Capture/Compare
Module 3
Crossbar
Port I/O
Figure 1.10. PCA Block Diagram
CEX3
Capture/Compare
Module 4
CEX4
Capture/Compare
Module 5
CEX5
30Rev. 1.4
C8051F040/1/2/3/4/5/6/7
1.6.Controller Area Network
The C8051F04x family of devices feature a Controller Area Network (CAN) controller that implements
serial communication using the CAN protocol. The CAN controller facilitates communication on a CAN network in accordance with the Bosch specification 2.0A (basic CAN) and 2.0B (full CAN). The CAN controller
consists of a CAN Core, Message RAM (separate from the C8051 RAM), a message handler state
machine, and control registers.
The CAN controller can operate at bit rates up to 1 Mbit/second. Silicon Labs CAN has 32 message
objects each having its own identifier mask used for acceptance filtering of received messages. Incoming
data, message objects and identifier masks are stored in the CAN message RAM. All protocol functions for
transmission of data and acceptance filtering is performed by the CAN controller and not by the C8051
MCU. In this way, minimal CPU bandwidth is used for CAN communication. The C8051 configures the
CAN controller, accesses received data, and passes data for transmission via Special Function Registers
(SFR) in the C8051.
CANTX
TXRX
CAN
Core
Message RAM
(32 Message Objects)
Message Handler
Figure 1.11. CAN Controller Diagram
CANRX
CAN Controller
BRP
Prescaler
REGISTERS
CAN_CLK
(f
Interrupt
C8051F04x
)
sys
S
Y
S
C
L
K
CIP-51
MCU
S
F
R
's
1.7.Serial Ports
The C8051F04x MCU Family includes two Enhanced Full-Duplex UARTs, an enhanced SPI Bus, and
SMBus/I2C. Each of the serial buses is fully implemented in hardware and makes extensive use of the
CIP-51's interrupts, thus requiring very little intervention by the CPU. The serial buses do not "share"
resources such as timers, interrupts, or Port I/O, so any or all of the serial buses may be used together with
any other.
Rev. 1.431
C8051F040/1/2/3/4/5/6/7
1.8.12/10-Bit Analog to Digital Converter
The C8051F040/1 devices have an on-chip 12-bit SAR ADC (ADC0) with a 9-channel input multiplexer
and programmable gain amplifier. With a maximum throughput of 100 ksps, the ADC offers true 12-bit performance with an INL of ±1LSB. C8051F042/3/4/5/6/7 devices include a 10-bit SAR ADC with similar specifications and configuration options. The ADC0 voltage reference is selected between the DAC0 output
and an external VREF pin. On C8051F040/2/4/6 devices, ADC0 has its own dedicated VREF0 input pin;
on C8051F041/3/5/7 devices, the ADC0 uses the VREFA input pin and, on the C8051F041/3, shares it
with the 8-bit ADC2. The on-chip 15 ppm/°C voltage reference may generate the voltage reference for the
on-chip ADCs or other system components via the VREF output pin.
The ADC is under full control of the CIP-51 microcontroller via its associated Special Function Registers.
One input channel is tied to an internal temperature sensor, while the other eight channels are available
externally. Each pair of the eight external input channels can be configured as either two single-ended
inputs or a single differential input. The system controller can also put the ADC into shutdown mode to
save power.
A programmable gain amplifier follows the analog multiplexer. The gain can be set to 0.5, 1, 2, 4, 8, or 16
and is software programmable. The gain stage can be especially useful when different ADC input channels
have widely varied input voltage signals, or when it is necessary to "zoom in" on a signal with a large dc
offset (in differential mode, a DAC could be used to provide the dc offset).
Conversions can be started in four ways; a software command, an overflow of Timer 2, an overflow of
Timer 3, or an external signal input. This flexibility allows the start of conversion to be triggered by software
events, external HW signals, or a periodic timer overflow signal. Conversion completions are indicated by a
status bit and an interrupt (if enabled). The resulting 10- or 12-bit data word is latched into two SFRs upon
completion of a conversion. The data can be right or left justified in these registers under software control.
Window Compare registers for the ADC data can be configured to interrupt the controller when ADC data
is within or outside of a specified range. The ADC can monitor a key voltage continuously in background
mode, but not interrupt the controller unless the converted data is within the specified window.
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN +
HVAIN -
Port 3
Pins
Analog Multiplexer
HVDA
TEMP
SENSOR
AGND
+
-
+
-
+
-
9-to-1
AMUX
(SE or
DIFF)
Configuration, Control, and Data
Progra mmab le Gain
Amplifie r
AV+
+
X
-
External VREF
(C8051F040/1/2/3 Only)
DAC0 Output
Registers
Pin
12/10-Bit
SAR
ADC
VREF
Start
Conversion
Window Compare
Logic
12
Write to AD0BUSY
Timer 3 Overflow
CNVSTR0
Timer 2 Overflow
Window
Compare
Interrupt
ADC Data
Registers
Conversion
Complete
Interrupt
Figure 1.12. 10/12-Bit ADC Block Diagram
32Rev. 1.4
C8051F040/1/2/3/4/5/6/7
1.9.8-Bit Analog to Digital Converter (C8051F040/1/2/3 Only)
The C8051F040/1/2/3 devices have an on-board 8-bit SAR ADC (ADC2) with an 8-channel input multiplexer and programmable gain amplifier. This ADC features a 500 ksps maximum throughput and true 8bit performance with an INL of ±1LSB. Eight input pins are available for measurement and can be programmed as single-ended or differential inputs. The ADC is under full control of the CIP-51 microcontroller
via the Special Function Registers. The ADC2 voltage reference is selected between the analog power
supply (AV+) and an external VREF pin. On C8051F040/2 devices, ADC2 has its own dedicated VREF2
input pin; on C8051F041/3 devices, ADC2 shares the VREFA input pin with the 12/10-bit ADC0. User software may put ADC2 into shutdown mode to save power.
A programmable gain amplifier follows the analog multiplexer. The gain stage can be especially useful
when different ADC input channels have widely varied input voltage signals, or when it is necessary to
"zoom in" on a signal with a large dc offset (in differential mode, a DAC could be used to provide the dc offset). The PGA gain can be set in software to 0.5, 1, 2, or 4.
A flexible conversion scheduling system allows ADC2 conversions to be initiated by software commands,
timer overflows, or an external input signal. ADC2 conversions may also be synchronized with ADC0 software-commanded conversions. Conversion completions are indicated by a status bit and an interrupt (if
enabled), and the resulting 8-bit data word is latched into an SFR upon completion.
Analog Multiplexer
AIN2.0
AIN2.1
AIN2.2
AIN2.3
AIN2.4
AIN2.5
AIN2.6
AIN2.7
+
-
+
-
+
-
+
-
8-to-1
AMUX
Single-ended or
Differential Measurement
Configuration, Control, and Data Registers
Programmable Gain
Ampli fier
X
AV+
+
-
8-Bit
SAR
ADC
External VREF
Figure 1.13. 8-Bit ADC Diagram
Pin
AV+
VREF
Start Conversion
8
Window
Compare Logic
Write to AD2BUSY
Timer 3 Overflow
CNVSTR2 Input
Timer 2 Overflow
Write to AD0BUSY
(synchronized with
ADC0)
Window
Compare
Interrupt
ADC Data
Register
Conversion
Complete
Interrupt
Rev. 1.433
C8051F040/1/2/3/4/5/6/7
1.10. Comparators and DACs
Each C8051F040/1/2/3 MCU has two 12-bit DACs, and all C8051F04x devices have three comparators on
chip. The MCU data and control interface to each comparator and DAC is via the Special Function Registers. The MCU can place any DAC or comparator in low power shutdown mode.
The comparators have software programmable hysteresis and response time. Each comparator can generate an interrupt on its rising edge, falling edge, or both; these interrupts are capable of waking up the
MCU from sleep mode. The comparators' output state can also be polled in software. The comparator outputs can be programmed to appear on the Port I/O pins via the Crossbar.
The DACs are voltage output mode and include a flexible output scheduling mechanism. This scheduling
mechanism allows DAC output updates to be forced by a software write or a Timer 2, 3, or 4 overflow. The
DAC voltage reference is supplied via the dedicated VREFD input pin on C8051F040/2 devices or via the
internal voltage reference on C8051F041/3 devices. The DACs are especially useful as references for the
comparators or offsets for the differential inputs of the ADC.
(Po rt I/O )
Comparator inputs
Port 2.[7:2]
CPn+
CPn-
DAC0
(C8051F040/1/2/3 only)
DAC1
CPn Output
3 Comparators
+
CPn
-
VREF
DAC0
VREF
DAC1
CROSSBAR
SFR's
(Data
and
Cntrl)
CIP-51
and
Interrupt
Handler
(C8051F040/1/2/3 only)
Figure 1.14. Comparator and DAC Diagram
34Rev. 1.4
C8051F040/1/2/3/4/5/6/7
2.Absolute Maximum Ratings
Table 2.1. Absolute Maximum Ratings*
ParameterConditionsMinTypMaxUnits
Ambient temperature under bias–55—125°C
Storage Temperature–65—150°C
Voltage on any Pin (except V
pins) with respect to DGND
Voltage on any Port I/O Pin, /RST, and JTAG pins with
respect to DGND
Voltage on V
with respect to DGND–0.3—4.2V
DD
Maximum Total current through V
AGND
Maximum output current sunk by any Port pin——100mA
Maximum output current sunk by any other I/O pin——50 mA
Maximum output current sourced by any Port pin——100mA
Maximum output current sourced by any other I/O pin——50mA
, Port I/O, and JTAG
DD
, AV+, DGND, and
DD
–0.3—VDD +
0.3
–0.3—5.8V
——800mA
V
*Note: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the device.
This is a stress rating only and functional operation of the devices at those or any other 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.
Due to special I/O design requirements of the High Voltage Difference Amplifier, undue electrical over-voltage
stress (i.e., ESD) experienced by these pads may result in impedance degredation of these inputs (HVAIN+
and HVAIN–). For this reason, care should be taken to ensure proper handling and use as typically required to
prevent ESD damage to electrostatically sensitive CMOS devices (e.g., static-free workstations, use of
grounding straps, over-voltage protection in end-applications, etc.)
Rev. 1.435
C8051F040/1/2/3/4/5/6/7
3.Global DC Electrical Characteristic
Table 3.1. Global DC Electrical Characteristics
–40 to +85 °C, 25 MHz System Clock unless otherwise specified.
ParameterConditionsMinTypMaxUnits
Analog Supply Voltage
1
Analog Supply CurrentInternal REF, ADC, DAC, Com-
2.73.03.6V
—1.7—mA
parators all active
Analog Supply Current with
analog sub-systems inactive
Internal REF, ADC, DAC, Comparators all disabled, oscillator
—0.2—mA
disabled
Analog-to-Digital Supply
Delta (|V
- AV+|)
DD
——0.5V
Digital Supply Voltage2.73.03.6V
Digital Supply Current with
CPU active
(Normal Mode)
Digital Supply Current with
CPU inactive (not accessing
Flash) (Idle Mode)
Digital Supply Current
= 2.7 V, Clock = 25 MHz
V
DD
V
= 2.7 V, Clock = 1 MHz
DD
= 2.7 V, Clock = 32 kHz
V
DD
V
= 2.7 V, Clock = 25 MHz
DD
V
= 2.7 V, Clock = 1 MHz
DD
= 2.7 V, Clock = 32 kHz
V
DD
Oscillator not running—0.2—µA
—
—
—
—
—
—
10
0.5
20
5
0.2
10
—
—
—
—
—
—
mA
mA
µA
mA
mA
µA
(shutdown) (Stop Mode)
Digital Supply RAM Data
—1.5— V
Retention Voltage
Specified Operating
–40—+85°C
Temperature Range
SYSCLK (system clock
frequency)
2
0—25MHz
Tsysl (SYSCLK low time)18——ns
Tsysh (SYSCLK high time)18——ns
Notes:
1. Analog Supply AV+ must be greater than 1 V for VDD monitor to operate.
2. SYSCLK must be at least 32 kHz to enable debugging.
36Rev. 1.4
4.Pinout and Package Definitions
Table 4.1. Pin Definitions
C8051F040/1/2/3/4/5/6/7
Name
V
DD
DGND38, 63, 89 25, 40, 56Digital Ground. Must be tied to Ground.
AV+8, 11, 143, 6Analog Supply Voltage. Must be tied to +2.7 to +3.6 V.
AGND9, 10, 134, 5Analog Ground. Must be tied to Ground.
TMS158D In JTAG Test Mode Select with internal pullup.
TCK259D InJTAG Test Clock with internal pullup.
TDI360D In JTAG Test Data Input with internal pullup. TDI is latched on the
TDO461D Out JTAG Test Data Output with internal pullup. Data is shifted out on
/RST562D I/O Device Reset. Open-drain output of internal VDD monitor. Is
XTAL12617A InCrystal Input. This pin is the return for the internal oscillator circuit
Pin Numbers
F040/2/4/6 F041/3/5/7
37, 64, 90 24, 41, 57Digital Supply Voltage. Must be tied to +2.7 to +3.6 V.
Typ e Description
rising edge of TCK.
TDO on the falling edge of TCK. TDO output is a tri-state driver.
driven low when V
source can initiate a system reset by driving this pin low.
for a crystal or ceramic resonator. For a precision internal clock,
connect a crystal or ceramic resonator from XTAL1 to XTAL2. If
overdriven by an external CMOS clock, this becomes the system
clock.
is < 2.7 V and MONEN is high. An external
DD
XTAL22718A Out Crystal Output. This pin is the excitation driver for a crystal or
ceramic resonator.
MONEN2819D In VDD Monitor Enable. When tied high, this pin enables the internal
monitor, which forces a system reset when VDD is < 2.7 V.
V
DD
When tied low, the internal V
In most applications, MONEN should be connected directly
to V
VREF127A I/O Bandgap Voltage Reference Output (all devices).
DAC Voltage Reference Input (C8051F041/3 only).
VREFA8A In ADC0 (C8051F041/3/5/7) and ADC2 (C8051F041/3 only)
Voltage Reference Input.
VREF016A In ADC0 Voltage Reference Input.
VREF217A In ADC2 Voltage Reference Input (C8051F040/2 only).
VREF15A In DAC Voltage Reference Input (C8051F040/2 only).
AIN0.0189A In ADC0 Input Channel 0 (See ADC0 Specification for complete
description).
AIN0.11910A In ADC0 Input Channel 1 (See ADC0 Specification for complete
description).
DD
.
monitor is disabled.
DD
Rev. 1.437
C8051F040/1/2/3/4/5/6/7
Table 4.1. Pin Definitions (Continued)
Name
AIN0.22011A In ADC0 Input Channel 2 (See ADC0 Specification for complete
AIN0.32112A In ADC0 Input Channel 3 (See ADC0 Specification for complete
HVCAP2213A I/O High Voltage Difference Amplifier Capacitor.
HVREF2314A InHigh Voltage Difference Amplifier Reference.
HVAIN+2415A InHigh Voltage Difference Amplifier Positive Signal Input.
HVAIN-2516A InHigh Voltage Difference Amplifier Positive Signal Input.
CANTX72D Out Controller Area Network Transmit Output.
CANRX61D In Controller Area Network Receive Input.
DAC010064A Out Digital to Analog Converter 0 Voltage Output. (See DAC Specifi-
DAC19963A Out Digital to Analog Converter 1 Voltage Output. (See DAC Specifi-
P0.06255D I/O Port 0.0. See Port Input/Output section for complete description.
P0.16154D I/O Port 0.1. See Port Input/Output section for complete description.
P0.26053D I/O Port 0.2. See Port Input/Output section for complete description.
Pin Numbers
Typ e Description
F040/2/4/6 F041/3/5/7
description).
description).
cation for complete description). (C8051F040/1/2/3 only)
cation for complete description). (C8051F040/1/2/3 only)
P0.35952D I/O Port 0.3. See Port Input/Output section for complete description.
P0.45851D I/O Port 0.4. See Port Input/Output section for complete description.
P0.5/ALE5750D I/O ALE Strobe for External Memory Address bus (multiplexed mode)
Port 0.5
See Port Input/Output section for complete description.
P0.6/RD5649D I/O /RD Strobe for External Memory Address bus
Port 0.6
See Port Input/Output section for complete description.
P0.7/WR5548D I/O /WR Strobe for External Memory Address bus
Port 0.7
See Port Input/Output section for complete description.
P1.0/AIN2.0/A83629A In
D I/O
P1.1/AIN2.1/A93528A In
D I/O
P1.2/AIN2.2/A103427A In
D I/O
P1.3/AIN2.3/A113326A In
D I/O
ADC1 Input Channel 0 (See ADC1 Specification for complete
description).
Bit 8 External Memory Address bus (Non-multiplexed mode)
Port 1.0
See Port Input/Output section for complete description.
Port 1.1. See Port Input/Output section for complete description.
Port 1.2. See Port Input/Output section for complete description.
Port 1.3. See Port Input/Output section for complete description.
38Rev. 1.4
C8051F040/1/2/3/4/5/6/7
Table 4.1. Pin Definitions (Continued)
Name
P1.4/AIN2.4/A123223A In
P1.5/AIN2.5/A133122A In
P1.6/AIN2.6/A143021A In
P1.7/AIN2.7/A152920A In
P2.0/A8m/A04637D I/O Bit 8 External Memory Address bus (Multiplexed mode)
P2.1/A9m/A14536D I/O Port 2.1. See Port Input/Output section for complete description.
P2.2/A10m/A24435D I/O Port 2.2. See Port Input/Output section for complete description.
P2.3/A11m/A34334D I/O Port 2.3. See Port Input/Output section for complete description.
P2.4/A12m/A44233D I/O Port 2.4. See Port Input/Output section for complete description.
P2.5/A13m/A54132D I/O Port 2.5. See Port Input/Output section for complete description.
P2.6/A14m/A64031D I/O Port 2.6. See Port Input/Output section for complete description.
P2.7/A15m/A73930D I/O Port 2.7. See Port Input/Output section for complete description.
P3.0/AD0/D05447A In
Pin Numbers
F040/2/4/6 F041/3/5/7
Typ e Description
Port 1.4. See Port Input/Output section for complete description.
D I/O
Port 1.5. See Port Input/Output section for complete description.
D I/O
Port 1.6. See Port Input/Output section for complete description.
D I/O
Port 1.7. See Port Input/Output section for complete description.
D I/O
Bit 0 External Memory Address bus (Non-multiplexed mode) Port
2.0
See Port Input/Output section for complete description.
Bit 0 External Memory Address/Data bus (Multiplexed mode)
D I/O
Bit 0 External Memory Data bus (Non-multiplexed mode)
Port 3.0
See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
P3.1/AD1/D15346A In
D I/O
P3.2/AD2/D25245A In
D I/O
P3.3/AD3/D35144A In
D I/O
P3.4/AD4/D45043A In
D I/O
P3.5/AD5/D54942A In
D I/O
P3.6/AD6/D64839A In
D I/O
P3.7/AD7/D74738A In
D I/O
P4.098D I/O Port 4.0. See Port Input/Output section for complete description.
Port 3.1. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.2. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.3. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.4. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.5. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.6. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Port 3.7. See Port Input/Output section for complete description.
ADC0 Input. (See ADC0 Specification for complete description.)
Rev. 1.439
C8051F040/1/2/3/4/5/6/7
Table 4.1. Pin Definitions (Continued)
Name
P4.197D I/O Port 4.1. See Port Input/Output section for complete description.
P4.296D I/O Port 4.2. See Port Input/Output section for complete description.
P4.395D I/O Port 4.3. See Port Input/Output section for complete description.
P4.494D I/O Port 4.4. See Port Input/Output section for complete description.
P4.5/ALE93D I/O ALE Strobe for External Memory Address bus (multiplexed mode)
P4.6/RD92D I/O /RD Strobe for External Memory Address bus
P4.7/WR91D I/O /WR Strobe for External Memory Address bus
P5.0/A888D I/O Bit 8 External Memory Address bus (Non-multiplexed mode)
P5.1/A987D I/O Port 5.1. See Port Input/Output section for complete description.
P5.2/A1086D I/O Port 5.2. See Port Input/Output section for complete description.
Pin Numbers
Typ e Description
F040/2/4/6 F041/3/5/7
Port 4.5
See Port Input/Output section for complete description.
Port 4.6
See Port Input/Output section for complete description.
Port 4.7
See Port Input/Output section for complete description.
Port 5.0
See Port Input/Output section for complete description.
P5.3/A1185D I/O Port 5.3. See Port Input/Output section for complete description.
P5.4/A1284D I/O Port 5.4. See Port Input/Output section for complete description.
P5.5/A1383D I/O Port 5.5. See Port Input/Output section for complete description.
P5.6/A1482D I/O Port 5.6. See Port Input/Output section for complete description.
P5.7/A1581D I/O Port 5.7. See Port Input/Output section for complete description.
P6.0/A8m/A080D I/O Bit 8 External Memory Address bus (Multiplexed mode)
Bit 0 External Memory Address bus (Non-multiplexed mode)
Port 6.0
See Port Input/Output section for complete description.
P6.1/A9m/A179D I/O Port 6.1. See Port Input/Output section for complete description.
P6.2/A10m/A278D I/O Port 6.2. See Port Input/Output section for complete description.
P6.3/A11m/A377D I/O Port 6.3. See Port Input/Output section for complete description.
P6.4/A12m/A476D I/O Port 6.4. See Port Input/Output section for complete description.
P6.5/A13m/A575D I/O Port 6.5. See Port Input/Output section for complete description.
P6.6/A14m/A674D I/O Port 6.6. See Port Input/Output section for complete description.
P6.7/A15m/A773D I/O Port 6.7. See Port Input/Output section for complete description.
P7.0/AD0/D072D I/O Bit 0 External Memory Address/Data bus (Multiplexed mode)
Bit 0 External Memory Data bus (Non-multiplexed mode)
Port 7.0
See Port Input/Output section for complete description.
40Rev. 1.4
C8051F040/1/2/3/4/5/6/7
Table 4.1. Pin Definitions (Continued)
Name
P7.1/AD1/D171D I/O Port 7.1. See Port Input/Output section for complete description.
P7.2/AD2/D270D I/O Port 7.2. See Port Input/Output section for complete description.
P7.3/AD3/D369D I/O Port 7.3. See Port Input/Output section for complete description.
P7.4/AD4/D468D I/O Port 7.4. See Port Input/Output section for complete description.
P7.5/AD5/D567D I/O Port 7.5. See Port Input/Output section for complete description.
P7.6/AD6/D666D I/O Port 7.6. See Port Input/Output section for complete description.
P7.7/AD7/D765D I/O Port 7.7. See Port Input/Output section for complete description.
Pin Numbers
Typ e Description
F040/2/4/6 F041/3/5/7
Rev. 1.441
C8051F040/1/2/3/4/5/6/7
DAC0
DAC1
P4.0
P4.1
P4.2
P4.3
P4.4
P4.5/ALE
P4.6/RD
P4.7/WR
VDD
DGND
9998979695949392919089888786858483828180797877
100
P5.0/A8
P5.1/A9
P5.2/A10
P5.3/A11
P5.4/A12
P5.5/A13
P5.6/A14
P5.7/A15
P6.0/A8m/A0
P6.1/A9m/A1
P6.2/A10m/A2
P6.3/A11m/A3
P6.4/A12m/A4
76
TMS
TCK
TDI
TDO
/RST
CANRX
CANTX
AV+
AGND
AGND
AV+
VREF
AGND
AV+
VREFD
VREF0
VREF2
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVCAP
HVREF
HVAIN+
HVAIN-
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1
2
3
4
5
6
7
8
9
C8051F040/2/4/6
262728293031323334353637383940
41
424344454647484950
75
P6.5/A13m/A5
74
P6.6/A14m/A6
73
P6.7/A15m/A7
72
P7.0/AD0/D0
71
P7.1/AD1/D1
70
P7.2/AD2/D2
69
P7.3/AD3/D3
68
P7.4/AD4/D4
67
P7.5/AD5/D5
66
P7.6/AD6/D6
65
P7.7/AD7/D7
64
VDD
63
DGND
62
P0.0
61
P0.1
60
P0.2
59
P0.3
58
P0.4
57
P0.5/ALE
56
P0.6/RD
55
P0.7/WR
54
P3.0/AD0/D0
53
P3.1/AD1/D1
52
P3.2/AD2/D2
51
P3.3/AD3/D3
VDD
P1.0/AIN2.0/A8
DGND
P2.7/A15m/A7
P2.6/A14m/A6
XTAL1
XTAL2
MONEN
P1.7/AIN2.7/A15
P1.6/AIN2.6/A14
P1.5/AIN2.5/A13
P1.4/AIN2.4/A12
P1.1/AIN2.1/A9
P1.3/AIN2.3/A11
P1.2/AIN2.2/A10
Figure 4.1. TQFP-100 Pinout Diagram
42Rev. 1.4
P2.5/A13m/A5
P2.4/A12m/A4
P2.3/A11m/A3
P2.2/A10m/A2
P3.7/AD7/D7
P3.6/AD6/D6
P3.5/AD5/D5
P2.1/A9m/A1
P2.0/A8m/A0
P3.4/AD4/D4
C8051F040/1/2/3/4/5/6/7
100
PIN 1
DESIGNATOR
D
D1
E1E
1
A
A1
A2
b
D
D1
e
E
E1
L
MIN
(mm)
-
0.05
0.95
0.17
-
-
-
-
-
0.45
NOM
(mm)
-
-
1.00
0.22
16.00
14.00
0.50
16.00
14.00
0.60
MAX
(mm)
1.20
0.15
1.05
0.27
-
-
-
-
-
0.75
A2
L
e
A
b
A1
Figure 4.2. TQFP-100 Package Drawing
Rev. 1.443
C8051F040/1/2/3/4/5/6/7
DAC0
DAC1
/RST
TDO
TDI
TCK
TMS
64
63
62
61
60
59
58
VDD
57
DGND
56
P0.0
55
P0.1
54
P0.2
53
P0.3
52
P0.4
51
P0.5/ALE
50
P0.6/RD
49
CANRX
CANTX
AV+
AGND
AGND
AV+
VREF
VREFA
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVCAP
HVREF
HVAIN+
HVAIN-
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
17
18
C8051F041/3/5/7
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
P0.7/WR
47
P3.0/AD0/D0
46
P3.1/AD1/D1
45
P3.2/AD2/D2
44
P3.3/AD3/D3
43
P3.4/AD4/D4
42
P3.5/AD5/D5
41
VDD
40
DGND
39
P3.6/AD6/D6
38
P3.7/AD7/D7
37
P2.0/A8m/A0
36
P2.1/A9m/A1
35
P2.2/A10m/A2
34
P2.3/A11m/A3
33
P2.4/A12m/A4
VDD
XTAL1
XTAL2
MONEN
P1.7/AIN2.7/A15
P1.6/AIN2.6/A14
P1.5/AIN2.5/A13
P1.4/AIN2.4/A12
DGND
Figure 4.3. TQFP-64 Pinout Diagram
44Rev. 1.4
P1.3/AIN2.3/A11
P1.2/AIN2.2/A10
P1.1/AIN2.1/A9
P1.0/AIN2.0/A8
P2.7/A15m/A7
P2.6/A14m/A6
P2.5/A13m/A5
D
D1
C8051F040/1/2/3/4/5/6/7
64
PIN 1
DESIGNATOR
A2
L
1
MIN
(mm)
A
A1
0.05
A2
E1
E
0.95
b
0.17
D
D1
e
e
A
b
A1
E
E1
L
0.45
-
-
-
-
-
-
NOM
(mm)
-
-
-
0.22
12.00
10.00
0.50
12.00
10.00
0.6
MAX
(mm)
1.20
0.15
1.05
0.27
-
-
-
-
-
0.75
Figure 4.4. TQFP-64 Package Drawing
Rev. 1.445
C8051F040/1/2/3/4/5/6/7
NOTES:
46Rev. 1.4
C8051F040/1/2/3/4/5/6/7
5.12-Bit ADC (ADC0, C8051F040/1 Only)
The ADC0 subsystem for the C8051F040/1 consists of a 9-channel, configurable analog multiplexer
(AMUX0), a programmable gain amplifier (PGA0), and a 100 ksps, 12-bit successive-approximation-register ADC with integrated track-and-hold and Programmable Window Detector (see block diagram in
Figure 5.1). The AMUX0, PGA0, Data Conversion Modes, and Window Detector are all configurable under
software control via the Special Function Registers shown in Figure 5.1. The voltage reference used by
ADC0 is selected as described in Section “9. Voltage Reference (C8051F040/2/4/6)” on page 113 for
C8051F040 devices, or Section “10. Voltage Reference (C8051F041/3/5/7)” on page 117 for
C8051F041 devices. The ADC0 subsystem (ADC0, track-and-hold and PGA0) is enabled only when the
AD0EN bit in the ADC0 Control register (ADC0CN) is set to logic 1. The ADC0 subsystem is in low power
shutdown when this bit is logic 0.
ADC0LTLADC0LTHADC0GTLADC0GTH
24
HV
Input
Port 3
I/O Pins
Analog
Input
Pins
9-to-1
AMUX
(SE or
DIFF)
X
+
-
AD0EN
AV+
AGND
AV+
12-Bit
SAR
ADC
Comb.
Logic
12
REF
SYSCLK
12
ADC0LADC0H
AD0WINT
00
01
10
11
AD0BUSY (W)
Timer 3 Overflow
CNVSTR0
TEMP
SENSOR
AGNDTimer 2 Overflow
HVDAIC
AIN01IC
AIN23IC
PORT3IC
AMX0CF
AMX0SL
AMX0AD0
AMX0AD1
AMX0AD2
AMX0AD3
AD0SC3
AD0SC4
ADC0CF
AD0SC1
AD0SC2
AMP0GN0
AMP0GN1
AMP0GN2
AD0SC0
AD0INT
AD0TM
AD0EN
ADC0CN
AD0BUSY
AD0CM1
AD0CM0
Start Conversion
AD0LJST
AD0WINT
Figure 5.1. 12-Bit ADC0 Functional Block Diagram
5.1.Analog Multiplexer and PGA
The analog multiplexer can input analog signals to the ADC from four external analog input pins (AIN0.0 AIN0.3), Port 3 port pins (optionally configured as analog input pins), High Voltage Difference Amplifier, or
an internally connected on-chip temperature sensor (temperature transfer function is shown in Figure 5.6).
AMUX input pairs can be programmed to operate in either differential or single-ended mode. This allows
the user to select the best measurement technique for each input channel, and even accommodates mode
changes "on-the-fly". The AMUX defaults to all single-ended inputs upon reset. There are three registers
associated with the AMUX: the Channel Selection register AMX0SL (SFR Definition 5.2), the Configuration
register AMX0CF (SFR Definition 5.1), and the Port Pin Selection register AMX0PRT (SFR Definition 5.3).
Table 5.1 shows AMUX functionality by channel for each possible configuration. The PGA amplifies the
AMUX output signal by an amount determined by the states of the AMP0GN2-0 bits in the ADC0 Configuration register, ADC0CF (SFR Definition 5.5). The PGA can be software-programmed for gains of 0.5, 2, 4,
8 or 16. Gain defaults to unity on reset.
Rev. 1.447
C8051F040/1/2/3/4/5/6/7
5.1.1. Analog Input Configuration
The analog multiplexer routes signals from external analog input pins, Port 3 I/O pins (See Section
“17.1.5. Configuring Port 1, 2, and 3 Pins as Analog Inputs” on page 209), a High Voltage Difference
Amplifier, and an on-chip temperature sensor as shown in Figure 5.2.
AIN01IC
AIN23IC
HVDAIC
PORT3IC
12-Bit
SAR
ADC
PAIN0EN
PAIN2EN
PAIN4EN
PAIN6EN
PAIN1EN
PAIN3EN
AMX0PRT
PAIN5EN
PAIN7EN
AIN0.0
AIN0.1
AIN0.2
AIN0.3
HVAIN +
HVAIN -
HVCAP
HVREF
P3.6
P3.4
P3.2
P3.0
P3.7
P3.5
P3.3
P3.1
HV
AMP
AGND
(WIRED -OR)
P3EVEN
P3ODD
(WIRED -OR)
+
0
-
1
2
+
-
3
+
4
-
5
9-to-1
AMUX
(SE or
DIFF)
6
+
7
8
AMX0CF
X
TEMP SENSOR
AMX0AD0
AMX0AD1
AMX0AD2
AMX0AD3
AGND
AMX0SL
Figure 5.2. Analog Input Diagram
Analog signals may be input from four external analog input pins (AIN0.0 through AIN0.3) as differential or
single-ended measurements. Additionally, Port 3 I/O Port Pins may be configured to input analog signals.
Port 3 pins configured as analog inputs are selected using the Port Pin Selection register (AMX0PRT). Any
number of Port 3 pins may be selected simultaneously as inputs to the AMUX. Even numbered Port 3 pins
and odd numbered Port 3 pins are routed to separate AMUX inputs. (Note: Even port pins and odd port
pins that are simultaneously selected will be shorted together as “wired-OR”.) In this way, differential measurements may be made when using the Port 3 pins (voltage difference between selected even and odd
Port 3 pins) as shown in Figure 5.2.
The High Voltage Difference Amplifier (HVDA) will accept analog input signals and reject up to 60 volts
common-mode for differential measurement of up to the reference voltage to the ADC (0 to VREF volts).
The output of the HVDA can be selected as an input to the ADC using the AMUX as any other channel is
selected for input. (See Section “5.2. High Voltage Difference Amplifier” on page 52).
48Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 5.1. AMX0CF: AMUX0 Configuration
RRRRR/WR/WR/WR/WReset Value
----PORT3IC HVDA2CAIN23ICAIN01IC 00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-4:UNUSED. Read = 0000b; Write = don’t care
Bit3:PORT3IC: Port 3 even/odd Pin Input Pair Configuration Bit
0: Port 3 even and odd input channels are independent single-ended inputs
1: Port 3 even and odd input channels are (respectively) +, - difference input pair
Bit2:HVDA2C: HVDA 2’s Compliment Bit
0: HVDA output measured as an independent single-ended input
1: HVDA result for 2’s compliment value
Bit1:AIN23IC: AIN0.2, AIN0.3 Input Pair Configuration Bit
0: AIN0.2 and AIN0.3 are independent single-ended inputs
1: AIN0.2, AIN0.3 are (respectively) +, - difference input pair
Bit0:AIN01IC: AIN0.0, AIN0.1 Input Pair Configuration Bit
0: AIN0.0 and AIN0.1 are independent single-ended inputs
1: AIN0.0, AIN0.1 are (respectively) +, - difference input pair
SFR
Address:
0xBA
0
NOTE:The ADC0 Data Word is in 2’s complement format for channels configured as difference.
0: P3.7 is not selected as an analog input to the AMUX.
1: P3.7 is selected as an analog input to the AMUX.
Bit6:PAIN6EN: Pin 6 Analog Input Enable Bit
0: P3.6 is not selected as an analog input to the AMUX.
1: P3.6 is selected as an analog input to the AMUX.
Bit5:PAIN5EN: Pin 5 Analog Input Enable Bit
0: P3.5 is not selected as an analog input to the AMUX.
1: P3.5 is selected as an analog input to the AMUX.
Bit4:PAIN4EN: Pin 4 Analog Input Enable Bit
0: P3.4 is not selected as an analog input to the AMUX.
1: P3.4 is selected as an analog input to the AMUX.
Bit3:PAIN3EN: Pin 3 Analog Input Enable Bit
0: P3.3 is not selected as an analog input to the AMUX.
1: P3.3 is enabled as an analog input to the AMUX.
Bit2:PAIN2EN: Pin 2 Analog Input Enable Bit
0: P3.2 is not selected as an analog input to the AMUX.
1: P3.2 is enabled as an analog input to the AMUX.
Bit1:PAIN1EN: Pin 1 Analog Input Enable Bit
0: P3.1 is not selected as an analog input to the AMUX.
1: P3.1 is enabled as an analog input to the AMUX.
Bit0:PAIN0EN: Pin 0 Analog Input Enable Bit
0: P3.0 is not selected as an analog input to the AMUX.
1: P3.0 is enabled as an analog input to the AMUX.
0xBD
0
Note:Any number of Port 3 pins may be selected simultaneously inputs to the AMUX. Odd numbered and even
numbered pins that are selected simultaneously are shorted together as “wired-OR”.
Rev. 1.451
C8051F040/1/2/3/4/5/6/7
5.2.High Voltage Difference Amplifier
The High Voltage Difference Amplifier (HVDA) can be used to measure high differential voltages up to 60 V
peak-to-peak, reject high common-mode voltages up to ±60 V, and condition the signal voltage range to be
suitable for input to ADC0. The input signal to the HVDA may be below AGND to –60 volts, and as high as
+60 volts, making the device suitable for both single and dual supply applications. The HVDA will provides
a common-mode signal for the ADC via the High Voltage Reference Input (HVREF), allowing measurement of signals outside the specified ADC input range using on-chip circuitry. The HVDA has a gain of
0.05 V/V to 14 V/V. The first stage 20:1 difference amplifier has a gain of 0.05 V/V when the output amplifier is used as a unity gain buffer. When the output amplifier is set to a gain of 280 (selected using the
HVGAIN bits in the High Voltage Control Register), the overall gain of 14 can be attained. The HVDA is
factory calibrated for a high common-mode rejection of 72 dB.
The HVDA uses four available external pins: +HVAIN, –HVAIN, HVCAP, and the aforementioned HVREF.
HVAIN+ and HVAIN- serve as the differential inputs to the HVDA. HVREF can be used to provide a common mode reference for input to ADC0. HVCAP facilitates the use of a capacitor for noise filtering in conjunction with R7 (see Figure 5.3 for R7 and other approximate resistor values). Alternatively, the HVCAP
could also be used to access amplification of the first stage of the HVDA at an external pin. (See Table 5.3
on page 68 for electrical specifications of the HVDA.)
V
OUT
Note: The output voltage of the HVDA is selected as an input to ADC0 via its analog multiplexer (AMUX0). HVDA
output voltages greater than the ADC0 reference voltage (Vref) or less than 0 volts (with respect to analog
ground) will result in saturation (output codes > full-scale or output codes < 0 respectively.) Allow for adequate
settle/tracking time for proper voltage measurements.
HVAIN+()HVAIN-()–[]GainHVREF+⋅=
Equation 5.1. Calculating HVDA Output Voltage to ADC0
HVCAP
100kΩ
HVAIN-
HVAIN+
100k
Resistor values are
approximate
5k
Ω
5k
Ω
HVA0CN
5k
Ω
Ω
Gain Setting
HVREF
Vout
(To AMUX0)
Figure 5.3. High Voltage Difference Amplifier Functional Diagram
52Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 5.4. HVA0CN: High Voltage Difference Amplifier Control
R/WRRRR/WR/WR/WR/WReset Value
HVDAEN---HVGAIN3 HVGAIN2 HVGAIN1 HVGAIN0 00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bit7:HVDAEN: High Voltage Difference Amplifier (HVDA) Enable Bit.
0: The HVDA is disabled.
1: The HVDA is enabled.
Bits6-3:Reserved.
Bits2-0:HVGAIN3-HVGAIN0: HVDA Gain Control Bits.
HVDA Gain Control Bits set the amplification gain if the difference signal input to the HVDA
as defined in the table below:
HVGAIN3:HVGAIN0HVDA Gain
00000.05
00010.1
00100.125
00110.2
01000.25
01010.4
01100.5
01110.8
10001.0
10011.6
10102.0
10113.2
11004.0
11016.2
11107.6
111114
0xD6
0
Rev. 1.453
C8051F040/1/2/3/4/5/6/7
5.3.ADC Modes of Operation
ADC0 has a maximum conversion speed of 100 ksps. The ADC0 conversion clock is derived from the system clock divided by the value held in the ADC0SC bits of register ADC0CF.
5.3.1. Starting a Conversion
A conversion can be initiated in one of four ways, depending on the programmed states of the ADC0 Start
of Conversion Mode bits (AD0CM1, AD0CM0) in ADC0CN. Conversions may be initiated by the following:
• Writing a ‘1’ to the AD0BUSY bit of ADC0CN;
• A Timer 3 overflow (i.e., timed continuous conversions);
• A rising edge detected on the external ADC convert start signal, CNVSTR0;
• A Timer 2 overflow (i.e., timed continuous conversions).
The AD0BUSY bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete.
The falling edge of AD0BUSY triggers an interrupt (when enabled) and sets the AD0INT interrupt flag
(ADC0CN.5). Converted data is available in the ADC0 data word MSB and LSB registers, ADC0H, ADC0L.
Converted data can be either left or right justified in the ADC0H:ADC0L register pair (see example in
Figure 5.7) depending on the programmed state of the AD0LJST bit in the ADC0CN register.
When initiating conversions by writing a ‘1’ to AD0BUSY, the AD0INT bit should be polled to determine
when a conversion has completed (ADC0 interrupts may also be used). The recommended polling procedure is shown below.
Step 1. Write a ‘0’ to AD0INT;
Step 2. Write a ‘1’ to AD0BUSY;
Step 3. Poll AD0INT for ‘1’;
Step 4. Process ADC0 data.
5.3.2. Tracking Modes
According to Table 5.2, each ADC0 conversion must be preceded by a minimum tracking time for the converted result to be accurate. The AD0TM bit in register ADC0CN controls the ADC0 track-and-hold mode.
In its default state, the ADC0 input is continuously tracked when a conversion is not in progress. When the
AD0TM bit is logic 1, ADC0 operates in low-power tracking mode. In this mode, each conversion is preceded by a tracking period of 3 SAR clocks after the start-of-conversion signal. When the CNVSTR0 signal
is used to initiate conversions in low-power tracking mode, ADC0 tracks only when CNVSTR0 is low; conversion begins on the rising edge of CNVSTR0 (see Figure 5.4). Tracking can also be disabled when the
entire chip is in low power standby or sleep modes. Low-power tracking mode is also useful when AMUX
or PGA settings are frequently changed, to ensure that settling time requirements are met (see Section
“5.3.3. Settling Time Requirements” on page 56).
54Rev. 1.4
(AD0STM[1:0]=10)
CNVSTR
SAR Clocks
C8051F040/1/2/3/4/5/6/7
A. ADC Timing for External Trigger Source
12345678910111213141516
ADC0TM=1
ADC0TM=0
Timer 2, Timer 3 Overflow;
Write '1' to AD0BUSY
(AD0STM[1:0]=00, 01, 11)
SAR Clocks
ADC0TM=1
SAR Clocks
ADC0TM=0
Figure 5.4. 12-Bit ADC Track and Conversion Example Timing
Low Power
or Convert
Track Or ConvertConvertTrack
TrackConvertLow Power Mode
B. ADC Timing for Internal Trigger Sources
1234567891011121314151617 18 19
Low Power
or Convert
Track or
Convert
TrackConvertLow Power Mode
12345678910111213141516
ConvertTrack
Rev. 1.455
C8051F040/1/2/3/4/5/6/7
5.3.3. Settling Time Requirements
A minimum tracking time is required before an accurate conversion can be performed. This tracking time is
determined by the ADC0 MUX resistance, the ADC0 sampling capacitance, any external source resistance, and the accuracy required for the conversion. Figure 5.5 shows the equivalent ADC0 input circuits
for both differential and Single-ended modes. Notice that the equivalent time constant for both input circuits
is the same. The required settling time for a given settling accuracy (SA) may be approximated by
Equation 5.2. When measuring the Temperature Sensor output, R
Low-Power tracking mode, three SAR clocks are used for tracking at the start of every conversion. For
most applications, these three SAR clocks will meet the tracking requirements. See Table 5.2 for absolute
minimum settling/tracking time requirements.
n
2
⎛⎞
t
-------
×ln=
⎝⎠
SA
R
TOTALCSAMPLE
Equation 5.2. 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
R
n is the ADC resolution in bits (12).
is the sum of the ADC0 MUX resistance and any external source resistance.
This flag must be cleared by software.
0: ADC0 has not completed a data conversion since the last time this flag was cleared.
1: ADC0 has completed a data conversion.
Bit4:AD0BUSY: ADC0 Busy Bit.
Read:
0: ADC0 Conversion is complete or a conversion is not currently in progress. AD0INT is set
to logic 1 on the falling edge of AD0BUSY.
1: ADC0 Conversion is in progress.
Write:
0: No Effect.
1: Initiates ADC0 Conversion if AD0STM1-0 = 00b
Bit3-2:AD0CM1-0: ADC0 Start of Conversion Mode Select.
If AD0TM = 0:
00: ADC0 conversion initiated on every write of ‘1’ to AD0BUSY.
01: ADC0 conversion initiated on overflow of Timer 3.
10: ADC0 conversion initiated on rising edge of external CNVSTR0.
11: ADC0 conversion initiated on overflow of Timer 2.
If AD0TM = 1:
00: Tracking starts with the write of ‘1’ to AD0BUSY and lasts for 3 SAR clocks, followed by
conversion.
01: Tracking started by the overflow of Timer 3 and last for 3 SAR clocks, followed by conversion.
10: ADC0 tracks only when CNVSTR0 input is logic low; conversion starts on rising
CNVSTR0 edge.
11: Tracking started by the overflow of Timer 2 and last for 3 SAR clocks, followed by conversion.
Bit1:AD0WINT: ADC0 Window Compare Interrupt Flag.
This bit must be cleared by software.
0: ADC0 Window Comparison Data match has not occurred since this flag was last cleared.
1: ADC0 Window Comparison Data match has occurred.
Bit0:AD0LJST: ADC0 Left Justify Select.
0: Data in ADC0H:ADC0L registers are right-justified.
1: Data in ADC0H:ADC0L registers are left-justified.
Bit
Addressable
0xE8
0
Rev. 1.459
C8051F040/1/2/3/4/5/6/7
SFR Definition 5.7. ADC0H: ADC0 Data Word MSB
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0SFR Address:
SFR Address:
SFR Page:
Bits7-0:ADC0 Data Word High-Order Bits.
For AD0LJST = 0: Bits 7-4 are the sign extension of Bit3. Bits 3-0 are the upper 4 bits of the
12-bit ADC0 Data Word.
For AD0LJST = 1: Bits 7-0 are the most-significant bits of the 12-bit ADC0 Data Word.
SFR Definition 5.8. ADC0L: ADC0 Data Word LSB
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0SFR Address:
SFR Address:
SFR Page:
00000000
0xBF
0
00000000
0xBE
0
Bits7-0:ADC0 Data Word Low-Order Bits.
For AD0LJST = 0: Bits 7-0 are the lower 8 bits of the 12-bit ADC0 Data Word.
For AD0LJST = 1: Bits 7-4 are the lower 4 bits of the 12-bit ADC0 Data Word. Bits3-0 will
always read ‘0’.
60Rev. 1.4
C8051F040/1/2/3/4/5/6/7
12-bit ADC0 Data Word appears in the ADC0 Data Word Registers as follows:
ADC0H[3:0]:ADC0L[7:0], if AD0LJST = 0
(ADC0H[7:4] will be sign-extension of ADC0H.3 for a differential reading,
otherwise = 0000b).
ADC0H[7:0]:ADC0L[7:4], if AD0LJST = 1
(ADC0L[3:0] = 0000b).
Example: ADC0 Data Word Conversion Map, AIN0 Input in Single-Ended Mode
(AMX0CF = 0x00, AMX0SL = 0x00)
AIN0-AGND (Volts)
VREF * (4095/4096)0x0FFF0xFFF0
VREF / 20x08000x8000
VREF * (2047/4096)0x07FF0x7FF0
00x00000x0000
Example: ADC0 Data Word Conversion Map, AIN0-AIN1 Differential Input Pair
(AMX0CF = 0x01, AMX0SL = 0x00)
AIN0-AGND (Volts)
VREF * (2047/2048)0x07FF0x7FF0
VREF / 20x04000x4000
VREF * (1/2048)0x00010x0010
00x00000x0000
-VREF * (1/2048)0xFFFF (-1d)0xFFF0
-VREF / 20xFC00 (-1024d)0xC000
-VREF0xF800 (-2048d)0x8000
ADC0H:ADC0L
(AD0LJST = 0)
ADC0H:ADC0L
(AD0LJST = 0)
ADC0H:ADC0L
(AD0LJST = 1)
ADC0H:ADC0L
(AD0LJST = 1)
For AD0LJST = 0:
CodeVin
×2n×=
Figure 5.7. ADC0 Data Word Example
Gain
---------------
VREF
; ‘n’ = 12 for Single-Ended; ‘n’=11 for Differential.
Rev. 1.461
C8051F040/1/2/3/4/5/6/7
5.4.ADC0 Programmable Window Detector
The ADC0 Programmable Window Detector continuously compares the ADC0 output to user-programmed
limits, and notifies the system when an out-of-bound condition is detected. This is especially effective in an
interrupt-driven system, saving code space and CPU bandwidth while delivering faster system response
times. The window detector interrupt flag (AD0WINT in ADC0CN) can also be used in polled mode. The
high and low bytes of the reference words are loaded into the ADC0 Greater-Than and ADC0 Less-Than
registers (ADC0GTH, ADC0GTL, ADC0LTH, and ADC0LTL). Reference comparisons are shown starting
on page 63. Notice that the window detector flag can be asserted when the measured data is inside or outside the user-programmed limits, depending on the programming of the ADC0GTx and ADC0LTx registers.
SFR Definition 5.9. ADC0GTH: ADC0 Greater-Than Data High Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
11111111
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:High byte of ADC0 Greater-Than Data Word.
0xC5
0
SFR Definition 5.10. ADC0GTL: ADC0 Greater-Than Data Low Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
0xC4
0
Bits7-0:Low byte of ADC0 Greater-Than Data Word.
SFR Definition 5.11. ADC0LTH: ADC0 Less-Than Data High Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:High byte of ADC0 Less-Than Data Word.
0xC7
0
11111111
62Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 5.12. ADC0LTL: ADC0 Less-Than Data Low Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:Low byte of ADC0 Less-Than Data Word.
0xC6
0
Input Voltage
(AD0 - AGND)
REF x (4095/4096)
REF x (512/4096)
REF x (256/4096)
0
ADC Data
Word
0x0FFF
0x0201
0x0200
0x01FF
0x0101
0x0100
0x00FF
0x0000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x00
AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0200,
ADC0GTH:ADC0GTL = 0x0100.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0x0200 and > 0x0100.
Input Voltage
(AD0 - AGND)
REF x (4095/4096)
REF x (512/4096)
REF x (256/4096)
0
ADC Data
Word
0x0FFF
0x0201
0x0200
0x01FF
0x0101
0x0100
0x00FF
0x0000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
Given:
AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0x0200.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
> 0x0200 or < 0x0100.
Figure 5.8. 12-Bit ADC0 Window Interrupt Example: Right Justified Single-Ended
Data
Rev. 1.463
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AD1)
REF x (2047/2048)
REF x (256/2048)
REF x (-1/2048)
-REF
ADC Data
Word
0x07FF
0x0101
0x0100
0x00FF
0x0000
0xFFFF
0xFFFE
0xF800
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0xFFFF.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0x0100 and > 0xFFFF. (In two’s-complement
math, 0xFFFF = -1.)
Input Voltage
(AD0 - AD1)
REF x (2047/2048)
REF x (256/2048)
REF x (-1/2048)
-REF
ADC Data
Word
0x07FF
0x0101
0x0100
0x00FF
0x0000
0xFFFF
0xFFFE
0xF800
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
Given:
AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘0’,
ADC0LTH:ADC0LTL = 0xFFFF,
ADC0GTH:ADC0GTL = 0x0100.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0xFFFF or > 0x0100. (In two’s-complement
math, 0xFFFF = -1.)
Figure 5.9. 12-Bit ADC0 Window Interrupt Example: Right Justified Differential
Data
64Rev. 1.4
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AGND)
REF x (4095/4096)
REF x (512/4096)
REF x (256/4096)
0
ADC Data
Word
0xFFF0
0x2010
0x2000
0x1FF0
0x1010
0x1000
0x0FF0
0x0000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘1’,
ADC0LTH:ADC0LTL = 0x2000,
ADC0GTH:ADC0GTL = 0x1000.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0x2000 and > 0x1000.
Input Voltage
(AD0 - AGND)
REF x (4095/4096)
REF x (512/4096)
REF x (256/4096)
0
ADC Data
Word
0xFFF0
0x2010
0x2000
0x1FF0
0x1010
0x1000
0x0FF0
0x0000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
Given:
AMX0SL = 0x00, AMX0CF = 0x00,
AD0LJST = ‘1’
ADC0LTH:ADC0LTL = 0x1000,
ADC0GTH:ADC0GTL = 0x2000.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0x1000 or > 0x2000.
Figure 5.10. 12-Bit ADC0 Window Interrupt Example: Left Justified Single-Ended
Data
Rev. 1.465
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AD1)
REF x (2047/2048)
REF x (256/2048)
REF x (-1/2048)
-REF
ADC Data
Word
0x7FF0
0x1010
0x1000
0x0FF0
0x0000
0xFFF0
0xFFE0
0x8000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘1’,
ADC0LTH:ADC0LTL = 0x1000,
ADC0GTH:ADC0GTL = 0xFFF0.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0x1000 and > 0xFFF0. (Two’s-complement
math.)
Input Voltage
(AD0 - AD1)
REF x (2047/2048)
REF x (256/2048)
REF x (-1/2048)
-REF
ADC Data
Word
0x7FF0
0x1010
0x1000
0x0FF0
0x0000
0xFFF0
0xFFE0
0x8000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
Given:
AMX0SL = 0x00, AMX0CF = 0x01,
AD0LJST = ‘1’,
ADC0LTH:ADC0LTL = 0xFFF0,
ADC0GTH:ADC0GTL = 0x1000.
An ADC0 End of Conversion will cause an
ADC0 Window Compare Interrupt (AD0WINT
= ‘1’) if the resulting ADC0 Data Word is
< 0xFFF0 or > 0x1000. (Two’s-complement
math.)
Figure 5.11. 12-Bit ADC0 Window Interrupt Example: Left Justified Differential Data
66Rev. 1.4
C8051F040/1/2/3/4/5/6/7
Table 5.2. 12-Bit ADC0 Electrical Characteristics
VDD = 3.0 V, AV+ = 3.0 V, VREF = 2.40 V (REFBE = 0), PGA Gain = 1, –40 to +85 °C unless otherwise specified.
= 3.0 V, –40 to +85 °C unless otherwise specified.
REF
68Rev. 1.4
C8051F040/1/2/3/4/5/6/7
6.10-Bit ADC (ADC0, C8051F042/3/4/5/6/7 Only)
The ADC0 subsystem for the C8051F042/3/4/5/6/7 consists of a 9-channel, configurable analog multiplexer (AMUX0), a programmable gain amplifier (PGA0), and a 100 ksps, 10-bit successive-approximation-register ADC with integrated track-and-hold and Programmable Window Detector (see block diagram
in Figure 6.1). The AMUX0, PGA0, Data Conversion Modes, and Window Detector are all configurable
under software control via the Special Function Registers shown in Figure 6.1. The voltage reference used
by ADC0 is selected as described in Section “9. Voltage Reference (C8051F040/2/4/6)” on page 113 for
C8051F042/4/6 devices, or Section “10. Voltage Reference (C8051F041/3/5/7)” on page 117 for
C8051F043/5/7 devices. The ADC0 subsystem (ADC0, track-and-hold and PGA0) is enabled only when
the AD0EN bit in the ADC0 Control register (ADC0CN) is set to logic 1. The ADC0 subsystem is in low
power shutdown when this bit is logic 0.
ADC0LTLADC0LTHADC0GTLADC0GTH
10-Bit
SAR
ADC
AMP0GN0
AMP0GN1
AV+
AD0INT
AD0TM
AD0EN
ADC0CN
AD0BUSY
AD0CM1
REF
SYSCLK
AD0LJST
AD0WINT
AD0CM0
HV
Input
PORT3IC
HVDA2IC
9-to-1
AMUX
(SE or
DIFF)
AIN01IC
AIN23IC
X
AMX0AD3
AMX0SL
Port 3
I/O Pins
Analog
Input
Pins
TEMP
SENSOR
AGNDTimer 2 Overflow
AMX0CF
AMX0AD2
AMX0AD1
+
-
AMX0AD0
AD0EN
AV+
AGND
AD0SC4
AD0SC0
AD0SC1
AD0SC2
AD0SC3
ADC0CF
AMP0GN2
20
10
ADC0LADC0H
Start Conversion
Comb.
Logic
10
00
01
10
11
AD0WINT
AD0BUSY (W)
Timer 3 Overflow
CNVSTR0
Figure 6.1. 10-Bit ADC0 Functional Block Diagram
6.1.Analog Multiplexer and PGA
The analog multiplexer can input analog signals to the ADC from four external analog input pins, Port 3
port pins (optionally configured as analog input pins), High Voltage Difference Amplifier, and an internally
connected on-chip temperature sensor (temperature transfer function is shown in Figure 6.6). AMUX input
pairs can be programmed to operate in either differential or single-ended mode. This allows the user to
select the best measurement technique for each input channel, and even accommodates mode changes
"on-the-fly". The AMUX defaults to all single-ended inputs upon reset. There are three registers associated
with the AMUX: the Channel Selection register AMX0SL (SFR Definition 6.2), the Configuration register
AMX0CF (SFR Definition 6.1), and the Port Pin Selection register AMX0PRT (SFR Definition 6.3).
Table 6.1 shows AMUX functionality by channel for each possible configuration. The PGA amplifies the
AMUX output signal by an amount determined by the states of the AMP0GN2-0 bits in the ADC0 Configuration register, ADC0CF (SFR Definition 6.5). The PGA can be software-programmed for gains of 0.5, 2, 4,
8 or 16. Gain defaults to unity on reset.
Rev. 1.469
C8051F040/1/2/3/4/5/6/7
6.1.1. Analog Input Configuration
The analog multiplexer routes signals from external analog input pins, Port 3 I/O pins (programmed to be
analog inputs), a High Voltage Difference Amplifier, and an on-chip temperature sensor as shown in
Figure 6.2.
AIN01IC
AIN23IC
AIN45IC
AMX0CF
X
AIN67IC
10-Bit
SAR
ADC
PAIN0EN
PAIN2EN
PAIN4EN
PAIN6EN
PAIN1EN
PAIN3EN
AMX0PRT
PAIN5EN
PAIN7EN
AIN0.0
AIN0.1
AIN0.2
AIN0.3
P3.6
P3.4
P3.2
P3.0
P3.7
P3.5
P3.3
P3.1
HVAIN +
HVAIN -
HVREF
HVCAP
(WIRED-OR)
P3EVEN
P3ODD
(WIRED-OR)
AGND
HV
AMP
+
0
-
1
2
+
-
3
9-to-1
+
6
AMUX
(SE or
-
7
DIFF)
5
4
8
TEMP SENSOR
AMX0AD0
AMX0AD1
AMX0AD2
AMX0AD3
AGND
AMX0SL
Figure 6.2. Analog Input Diagram
Analog signals may be input from four external analog input pins (AIN0.0 through AIN0.3) as differential or
single-ended measurements. Additionally, Port 3 I/O Port Pins may be configured to input analog signals.
Port 3 pins configured as analog inputs are selected using the Port Pin Selection register (AMX0PRT). Any
number of Port 3 pins may be selected simultaneously as inputs to the AMUX. Even numbered Port 3 pins
and odd numbered Port 3 pins are routed to separate AMUX inputs. (NOTE: Even port pins and odd port
pins that are simultaneously selected will be shorted together as “wired-OR”.) In this way, differential measurements may be made when using the Port 3 pins (voltage difference between selected even and odd
Port 3 pins) as shown in Figure 6.2.
The High Voltage Difference Amplifier (HVDA) will accept analog input signals and reject up to 60 volts
common-mode for differential measurement of up to the reference voltage to the ADC (0 to VREF volts).
The output of the HVDA can be selected as an input to the ADC using the AMUX as any other channel is
selected for measurement.
70Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 6.1. AMX0CF: AMUX0 Configuration
RRRRR/WR/WR/WR/WReset Value
----PORT3IC HVDA2CAIN23ICAIN01IC00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0SFR Address:
SFR Address:
SFR Page:
Bits7-4:UNUSED. Read = 0000b; Write = don’t care
Bit3:PORT3IC: Port 3 even/odd Pin Input Pair Configuration Bit
0: Port 3 even and odd input channels are independent single-ended inputs
1: Port 3 even and odd input channels are (respectively) +, - differential input pair
Bit2:HVDA2C: HVDA 2’s Compliment Bit
0: HVDA output measured as an independent single-ended input
1: 2’s compliment value Result from HVDA
Bit1:AIN23IC: AIN2, AIN3 Input Pair Configuration Bit
0: AIN2 and AIN3 are independent single-ended inputs
1: AIN2, AIN3 are (respectively) +, - differential input pair
Bit0:AIN01IC: AIN0, AIN1 Input Pair Configuration Bit
0: AIN0 and AIN1 are independent single-ended inputs
1: AIN0, AIN1 are (respectively) +, - differential input pair
0xBA
0
NOTE:The ADC0 Data Word is in 2’s complement format for channels configured as differential.
0: P3.7 is not selected as an analog input to the AMUX.
1: P3.7 is selected as an analog input to the AMUX.
Bit6:PAIN6EN: Pin 6 Analog Input Enable Bit
0: P3.6 is not selected as an analog input to the AMUX.
1: P3.6 is selected as an analog input to the AMUX.
Bit5:PAIN5EN: Pin 5 Analog Input Enable Bit
0: P3.5 is not selected as an analog input to the AMUX.
1: P3.5 is selected as an analog input to the AMUX.
Bit4:PAIN4EN: Pin 4 Analog Input Enable Bit
0: P3.4 is not selected as an analog input to the AMUX.
1: P3.4 is selected as an analog input to the AMUX.
Bit3:PAIN3EN: Pin 3 Analog Input Enable Bit
0: P3.3 is not selected as an analog input to the AMUX.
1: P3.3 is enabled as an analog input to the AMUX.
Bit2:PAIN2EN: Pin 2 Analog Input Enable Bit
0: P3.2 is not selected as an analog input to the AMUX.
1: P3.2 is enabled as an analog input to the AMUX.
Bit1:PAIN1EN: Pin 1 Analog Input Enable Bit
0: P3.1 is not selected as an analog input to the AMUX.
1: P3.1 is enabled as an analog input to the AMUX.
Bit0:PAIN0EN: Pin 0 Analog Input Enable Bit
0: P3.0 is not selected as an analog input to the AMUX.
1: P3.0 is enabled as an analog input to the AMUX.
0xBA
0
NOTE: Any number of Port 3 pins may be selected simultaneously inputs to the AMUX. Odd num-
bered and even numbered pins that are selected simultaneously are shorted together as
“wired-OR”.
Rev. 1.473
C8051F040/1/2/3/4/5/6/7
6.2.High Voltage Difference Amplifier
The High Voltage Difference Amplifier (HVDA) can be used to measure high differential voltages up to 60 V
peak-to-peak, reject high common-mode voltages up to ±60 V, and condition the signal voltage range to be
suitable for input to ADC0. The input signal to the HVDA may be below AGND to -60 volts, and as high as
+60 volts, making the device suitable for both single and dual supply applications. The HVDA will provides
a common-mode signal for the ADC via the High Voltage Reference Input (HVREF), allowing measurement of signals outside the specified ADC input range using on-chip circuitry. The HVDA has a gain of
0.05 V/V to 14 V/V. The first stage 20:1 difference amplifier has a gain of 0.05 V/V when the output amplifier is used as a unity gain buffer. When the output amplifier is set to a gain of 280 (selected using the
HVGAIN bits in the High Voltage Control Register), the overall gain of 14 can be attained. The HVDA is
factory calibrated for a high common-mode rejection of 72 dB.
The HVDA uses four available external pins: +HVAIN, -HVAIN, HVCAP, and the aforementioned HVREF.
HVAIN+ and HVAIN- serve as the differential inputs to the HVDA. HVREF can be used to provide a common mode reference for input to ADC0. HVCAP facilitates the use of a capacitor for noise filtering in conjunction with R7 (see Figure 6.3 for R7 and other approximate resistor values). Alternatively, the HVCAP
could also be used to access amplification of the first stage of the HVDA at an external pin. (See Table 6.3
on page 90 for electrical specifications of the HVDA.)
HVCAP
100kΩ
HVAIN-
5k
Ω
5k
Ω
Vout
(To AMUX0)
HVAIN+
5k
100k
Ω
Ω
Resistor values are
HVA0CN
Gain Setting
approximate
HVREF
Figure 6.3. High Voltage Difference Amplifier Functional Diagram
V
OUT
Note: The output voltage of the HVDA is selected as an input to ADC0 via its analog multiplexer (AMUX0). HVDA
output voltages greater than the ADC0 reference voltage (Vref) or less than 0 volts (with respect to analog
ground) will result in saturation (output codes > full-scale or output codes < 0 respectively.) Allow for adequate
settle/tracking time for proper voltage measurements.
HVAIN+()HVAIN-()–[]GainHVREF+⋅=
Equation 6.1. Calculating HVDA Output Voltage to ADC0
74Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 6.4. HVA0CN: High Voltage Difference Amplifier Control
R/WRRRR/WR/WR/WR/WReset Value
HVDAEN---HVGAIN3 HVGAIN2 HVGAIN1 HVGAIN0 00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bit7:HVDAEN: High Voltage Difference Amplifier (HVDA) Enable Bit.
0: The HVDA is disabled.
1: The HVDA is enabled.
Bits6-3:Reserved.
Bits2-0:HVGAIN3-HVGAIN0: HVDA Gain Control Bits.
HVDA Gain Control Bits set the amplification gain if the difference signal input to the HVDA
as defined in the table below:
HVGAIN3:HVGAIN0HVDA Gain
00000.05
00010.1
00100.125
00110.2
01000.25
01010.4
01100.5
01110.8
10001.0
10011.6
10102.0
10113.2
11004.0
11016.2
11107.6
111114
0xD6
0
Rev. 1.475
C8051F040/1/2/3/4/5/6/7
6.3.ADC Modes of Operation
ADC0 has a maximum conversion speed of 100 ksps. The ADC0 conversion clock is derived from the system clock divided by the value held in the ADC0SC bits of register ADC0CF.
6.3.1. Starting a Conversion
A conversion can be initiated in one of four ways, depending on the programmed states of the ADC0 Start
of Conversion Mode bits (AD0CM1, AD0CM0) in ADC0CN. Conversions may be initiated by the following:
• Writing a ‘1’ to the AD0BUSY bit of ADC0CN;
• A Timer 3 overflow (i.e. timed continuous conversions);
• A rising edge detected on the external ADC convert start signal, CNVSTR0;
• A Timer 2 overflow (i.e. timed continuous conversions).
The AD0BUSY bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete.
The falling edge of AD0BUSY triggers an interrupt (when enabled) and sets the AD0INT interrupt flag
(ADC0CN.5). Converted data is available in the ADC0 data word MSB and LSB registers, ADC0H, ADC0L.
Converted data can be either left or right justified in the ADC0H:ADC0L register pair (see example in
Figure 6.7) depending on the programmed state of the AD0LJST bit in the ADC0CN register.
When initiating conversions by writing a ‘1’ to AD0BUSY, the AD0INT bit should be polled to determine
when a conversion has completed (ADC0 interrupts may also be used). The recommended polling procedure is shown below.
Step 1. Write a ‘0’ to AD0INT;
Step 2. Write a ‘1’ to AD0BUSY;
Step 3. Poll AD0INT for ‘1’;
Step 4. Process ADC0 data.
6.3.2. Tracking Modes
According to Table 6.2, each ADC0 conversion must be preceded by a minimum tracking time for the converted result to be accurate. The AD0TM bit in register ADC0CN controls the ADC0 track-and-hold mode.
In its default state, the ADC0 input is continuously tracked when a conversion is not in progress. When the
AD0TM bit is logic 1, ADC0 operates in low-power tracking mode. In this mode, each conversion is preceded by a tracking period of 3 SAR clocks after the start-of-conversion signal. When the CNVSTR0 signal
is used to initiate conversions in low-power tracking mode, ADC0 tracks only when CNVSTR0 is low; conversion begins on the rising edge of CNVSTR0 (see Figure 6.4). Tracking can also be disabled when the
entire chip is in low power standby or sleep modes. Low-power tracking mode is also useful when AMUX
or PGA settings are frequently changed, to ensure that settling time requirements are met (see Section
“6.3.3. Settling Time Requirements” on page 78).
76Rev. 1.4
(AD0STM[1:0]=10)
CNVSTR
SAR Clocks
C8051F040/1/2/3/4/5/6/7
A. ADC Timing for External Trigger Source
12345678910111213141516
ADC0TM=1
ADC0TM=0
Timer 2, Timer 3 Overflow;
Write '1' to AD0BUSY
(AD0STM[1:0]=00, 01, 11)
SAR Clocks
ADC0TM=1
SAR Clocks
ADC0TM=0
Figure 6.4. 10-Bit ADC Track and Conversion Example Timing
Low Power
or Convert
Track Or ConvertConvertTrack
TrackConvertLow Power Mode
B. ADC Timing for Internal Trigger Sources
1234567891011121314151617 18 19
Low Power
or Convert
Track or
Convert
TrackConvertLow Power Mode
12345678910111213141516
ConvertTrack
Rev. 1.477
C8051F040/1/2/3/4/5/6/7
6.3.3. Settling Time Requirements
A minimum tracking time is required before an accurate conversion can be performed. This tracking time is
determined by the ADC0 MUX resistance, the ADC0 sampling capacitance, any external source resistance, and the accuracy required for the conversion. Figure 6.5 shows the equivalent ADC0 input circuits
for both Differential and Single-ended modes. Notice that the equivalent time constant for both input circuits is the same. The required settling time for a given settling accuracy (SA) may be approximated by
Equation 6.2. When measuring the Temperature Sensor output, R
power tracking mode, three SAR clocks are used for tracking at the start of every conversion. For most
applications, these three SAR clocks will meet the tracking requirements. See Table 6.2 for absolute minimum settling/tracking time requirements.
n
2
⎛⎞
t
-------
×ln=
⎝⎠
SA
R
TOTALCSAMPLE
reduces to R
TOTAL
. Note that in low-
MUX
Equation 6.2. 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
R
n is the ADC resolution in bits (10).
is the sum of the ADC0 MUX resistance and any external source resistance.
TOTAL
AIN0.x
AIN0.y
Differential Mode
MUX Select
R
= 5k
MUX
RC
= R
MUX
* C
R
MUX
SAMP LE
= 5k
Input
MUX Select
C
SAMPLE
C
SAMPLE
= 10pF
= 10pF
Single-Ended Mode
MUX Select
AIN0.x
RC
Input
= R
MUX
R
* C
MUX
= 5k
SAMPL E
C
SAMPLE
= 10pF
Figure 6.5. ADC0 Equivalent Input Circuits
78Rev. 1.4
(Volts)
1.000
0.900
0.800
0.700
0.600
0.500
C8051F040/1/2/3/4/5/6/7
V
= 0.00286(TEMPC) + 0.776
TEMP
for PGA Gain = 1
0-5050100
Figure 6.6. Temperature Sensor Transfer Function
(Celsius)
Rev. 1.479
C8051F040/1/2/3/4/5/6/7
SFR Definition 6.5. ADC0CF: ADC0 Configuration
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
AD0SC4A D 0 S C3AD 0 S C 2A D 0 SC1AD 0 S C 0 AMP0GN2 AM P 0 G N1 AMP0G N 0 11111000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
Bits7-3:AD0SC4-0: ADC0 SAR Conversion Clock Period Bits
SAR Conversion clock is derived from system clock by the following equation, where
AD0SC refers to the 5-bit value held in AD0SC4-0, and CLK
SAR clock. See Table 6.2 on page 89 for SAR clock setting requirements.
SYSCLK
AD0SC
*Note: AD0SC is the rounded-up result.
Bits2-0:AMP0GN2-0: ADC0 Internal Amplifier Gain (PGA)
000: Gain = 1
001: Gain = 2
010: Gain = 4
011: Gain = 8
10x: Gain = 16
11x: Gain = 0.5
This flag must be cleared by software.
0: ADC0 has not completed a data conversion since the last time this flag was cleared.
1: ADC0 has completed a data conversion.
Bit4:AD0BUSY: ADC0 Busy Bit.
Read:
0: ADC0 Conversion is complete or a conversion is not currently in progress. AD0INT is set
to logic 1 on the falling edge of AD0BUSY.
1: ADC0 Conversion is in progress.
Write:
0: No Effect.
1: Initiates ADC0 Conversion if AD0STM1-0 = 00b
Bit3-2:AD0CM1-0: ADC0 Start of Conversion Mode Select.
If AD0TM = 0:
00: ADC0 conversion initiated on every write of ‘1’ to AD0BUSY.
01: ADC0 conversion initiated on overflow of Timer 3.
10: ADC0 conversion initiated on rising edge of external CNVSTR0.
11: ADC0 conversion initiated on overflow of Timer 2.
If AD0TM = 1:
00: Tracking starts with the write of ‘1’ to AD0BUSY and lasts for 3 SAR clocks, followed by
conversion.
01: Tracking started by the overflow of Timer 3 and last for 3 SAR clocks, followed by conversion.
10: ADC0 tracks only when CNVSTR0 input is logic low; conversion starts on rising
CNVSTR0 edge.
11: Tracking started by the overflow of Timer 2 and last for 3 SAR clocks, followed by conversion.
Bit1:AD0WINT: ADC0 Window Compare Interrupt Flag.
This bit must be cleared by software.
0: ADC0 Window Comparison Data match has not occurred since this flag was last cleared.
1: ADC0 Window Comparison Data match has occurred.
Bit0:AD0LJST: ADC0 Left Justify Select.
0: Data in ADC0H:ADC0L registers are right-justified.
1: Data in ADC0H:ADC0L registers are left-justified.
Bit
Addressable
0xE8
0
Rev. 1.481
C8051F040/1/2/3/4/5/6/7
SFR Definition 6.7. ADC0H: ADC0 Data Word MSB
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:ADC0 Data Word High-Order Bits.
For AD0LJST = 0: Bits 7-2 are the sign extension of Bit 1. Bits 0 and 1 are the upper 2 bits of
the 10-bit ADC0 Data Word.
For AD0LJST = 1: Bits 7-0 are the most-significant bits of the 10-bit ADC0 Data Word.
SFR Definition 6.8. ADC0L: ADC0 Data Word LSB
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
00000000
SFR
Address:
0xBF
0
00000000
SFR
Address:
0xBE
0
Bits7-0:ADC0 Data Word Low-Order Bits.
For AD0LJST = 0: Bits 7-0 are the lower 8 bits of the 10-bit ADC0 Data Word.
For AD0LJST = 1: Bits 6 and 7 are the lower 2 bits of the 10-bit ADC0 Data Word. Bits 5-0
82Rev. 1.4
C8051F040/1/2/3/4/5/6/7
10-bit ADC Data Word appears in the ADC Data Word Registers as follows:
ADC0H[1:0]:ADC0L[7:0], if ADLJST = 0
(ADC0H[7:2] will be sign-extension of ADC0H.1 for a differential reading,
otherwise = 000000b).
ADC0H[7:0]:ADC0L[7:6], if ADLJST = 1
(ADC0L[5:0] = 000000b).
Example: ADC Data Word Conversion Map, AIN0 Input in Single-Ended Mode
(AMX0CF = 0x00, AMX0SL = 0x00)
AIN0-AGND (Volts)
VREF * (1023/1024)0x03FF0xFFC0
VREF / 20x02000x8000
VREF * (511/1024)0x01FF0x7FC0
00x00000x0000
Example: ADC Data Word Conversion Map, AIN0-AIN1 Differential Input Pair
(AMX0CF = 0x01, AMX0SL = 0x00)
AIN0-AGND (Volts)
VREF * (511/512)0x01FF0x7FC0
VREF / 20x01000x4000
VREF * (1/512)0x00010x0040
00x00000x0000
-VREF * (1/512)0xFFFF (-1)0xFFC0
-VREF / 20xFF00 (-256)0xC000
-VREF0xFE00 (-512)0x8000
ADC0H:ADC0L
(ADLJST = 0)
ADC0H:ADC0L
(ADLJST = 0)
ADC0H:ADC0L
(ADLJST = 1)
ADC0H:ADC0L
(ADLJST = 1)
ADLJST = 0:
CodeVin
Gain
---------------
×2n×=
VREF
; ‘n’ = 10 for Single-Ended; ‘n’=9 for Differential.
Figure 6.7. ADC0 Data Word Example
Rev. 1.483
C8051F040/1/2/3/4/5/6/7
6.4.ADC0 Programmable Window Detector
The ADC0 Programmable Window Detector continuously compares the ADC0 output to user-programmed
limits, and notifies the system when an out-of-bound condition is detected. This is especially effective in an
interrupt-driven system, saving code space and CPU bandwidth while delivering faster system response
times. The window detector interrupt flag (AD0WINT in ADC0CN) can also be used in polled mode. The
high and low bytes of the reference words are loaded into the ADC0 Greater-Than and ADC0 Less-Than
registers (ADC0GTH, ADC0GTL, ADC0LTH, and ADC0LTL). Reference comparisons are shown starting
on page 85. Notice that the window detector flag can be asserted when the measured data is inside or outside the user-programmed limits, depending on the programming of the ADC0GTx and ADC0LTx registers.
SFR Definition 6.9. ADC0GTH: ADC0 Greater-Than Data High Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
11111111
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:High byte of ADC0 Greater-Than Data Word.
0xC5
0
SFR Definition 6.10. ADC0GTL: ADC0 Greater-Than Data Low Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
0xC4
0
Bits7-0:Low byte of ADC0 Greater-Than Data Word.
SFR Definition 6.11. ADC0LTH: ADC0 Less-Than Data High Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:High byte of ADC0 Less-Than Data Word.
0xC7
0
11111111
84Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 6.12. ADC0LTL: ADC0 Less-Than Data Low Byte
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:Low byte of ADC0 Less-Than Data Word.
0xC6
0
Input Voltage
(AD0 - AGND)
REF x (1023/1024)
REF x (512/1024)
REF x (256/1024)
0
ADC Data
Word
0x03FF
0x0201
0x0200
0x01FF
0x0101
0x0100
0x00FF
0x0000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x00, ADLJST = 0,
ADC0LTH:ADC0LTL = 0x0200,
ADC0GTH:ADC0GTL = 0x0100.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0x0200 and
> 0x0100.
Given:
Input Voltage
(AD0 - AGND)
REF x (1023/1024)
REF x (512/1024)
REF x (256/1024)
0
ADC Data
Word
0x03FF
0x0201
0x0200
0x01FF
0x0101
0x0100
0x00FF
0x0000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
AMX0SL = 0x00, AMX0CF = 0x00, ADLJST = 0,
ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0x0200.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is > 0x0200 or
< 0x0100.
Figure 6.8. 10-Bit ADC0 Window Interrupt Example: Right Justified Single-Ended
Data
Rev. 1.485
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AD 1)
REF x (511/512)
REF x (256/512)
REF x (-1/512)
-REF
ADC Data
Word
0x01FF
0x0101
0x0100
0x00FF
0x0000
0xFFFF
0xFFFE
0xFE00
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x01, ADLJST = 0,
ADC0LTH:ADC0LTL = 0x0100,
ADC0GTH:ADC0GTL = 0xFFFF.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0x0100 and
> 0xFFFF. (In two’s-complement math,
0xFFFF = -1.)
Given:
Input Voltage
(AD0 - AD 1)
REF x (511/512)
REF x (256/512)
REF x (-1/512)
-REF
ADC Data
Word
0x01FF
0x0101
0x0100
0x00FF
0x0000
0xFFFF
0xFFFE
0xFE00
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
AMX0SL = 0x00, AMX0CF = 0x01, ADLJST = 0,
ADC0LTH:ADC0LTL = 0xFFFF,
ADC0GTH:ADC0GTL = 0x0100.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0xFFFF or
> 0x0100. (In two’s-complement math,
0xFFFF = -1.)
Figure 6.9. 10-Bit ADC0 Window Interrupt Example: Right Justified Differential
Data
86Rev. 1.4
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AG ND)
REF x (1023/1024)
REF x (512/1024)
REF x (256/1024)
0
ADC Data
Word
0xFFC0
0x8040
0x8000
0x7FC0
0x4040
0x4000
0x3FC0
0x0000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x00, ADLJST = 1,
ADC0LTH:ADC0LTL = 0x8000,
ADC0GTH:ADC0GTL = 0x4000.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0x8000 and
> 0x4000.
Given:
Input Voltage
(AD0 - AG ND)
REF x (1023/1024)
REF x (512/1024)
REF x (256/1024)
0
ADC Data
Word
0xFFC0
0x8040
0x8000
0x7FC0
0x4040
0x4000
0x3FC0
0x0000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
AMX0SL = 0x00, AMX0CF = 0x00, ADLJST = 1,
ADC0LTH:ADC0LTL = 0x4000,
ADC0GTH:ADC0GTL = 0x8000.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0x4000 or
> 0x8000.
Figure 6.10. 10-Bit ADC0 Window Interrupt Example: Left Justified Single-Ended
Data
Rev. 1.487
C8051F040/1/2/3/4/5/6/7
Input Voltage
(AD0 - AD1)
REF x (511/512)
REF x (256/512)
REF x (-1/512)
-REF
ADC Data
Word
0x7FC0
0x4040
0x4000
0x3FC0
0x0000
0xFFC0
0xFF80
0x8000
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
Given:
AMX0SL = 0x00, AMX0CF = 0x01, ADLJST = 1,
ADC0LTH:ADC0LTL = 0x4000,
ADC0GTH:ADC0GTL = 0xFFC0.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0x4000 and
> 0xFFC0. (Two’s-complement math.)
Given:
Input Voltage
(AD0 - AD 1)
REF x (511/512)
REF x (256/512)
REF x (-1/512)
-REF
ADC Data
Word
0x7FC0
0x4040
0x4000
0x3FC0
0x0000
0xFFC0
0xFF80
0x8000
AD0WINT=1
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
AD0WINT=1
AMX0SL = 0x00, AMX0CF = 0x01, ADLJST = 1,
ADC0LTH:ADC0LTL = 0xFFC0,
ADC0GTH:ADC0GTL = 0x4000.
An ADC End of Conversion will cause an ADC
Window Compare Interrupt (ADWINT=1) if the
resulting ADC Data Word is < 0xFFC0 or
> 0x4000. (Two’s-complement math.)
Figure 6.11. 10-Bit ADC0 Window Interrupt Example: Left Justified Differential Data
= 3.0 V, –40 to +85 °C unless otherwise specified.
REF
90Rev. 1.4
C8051F040/1/2/3/4/5/6/7
7.8-Bit ADC (ADC2, C8051F040/1/2/3 Only)
The ADC2 subsystem for the C8051F040/1/2/3 consists of an 8-channel, configurable analog multiplexer,
a programmable gain amplifier, and a 500 ksps, 8-bit successive-approximation-register ADC with integrated track-and-hold (see block diagram in Figure 7.1). The AMUX2, PGA2, and Data Conversion Modes,
are all configurable under software control via the Special Function Registers shown in Figure 7.1. The
ADC2 subsystem (8-bit ADC, track-and-hold and PGA) is enabled only when the AD2EN bit in the ADC2
Control register (ADC2CN) is set to logic 1. The ADC2 subsystem is in low power shutdown when this bit is
logic 0. The voltage reference used by ADC2 is selected as described in Section “9. Voltage Reference
(C8051F040/2/4/6)” on page 113 for C8051F040/2 devices, or Section “10. Voltage Reference
(C8051F041/3/5/7)” on page 117 for C8051F041/3 devices.
AIN67IC
AMX2CF
AIN45IC
+
-
+
-
+
-
+
-
8-to-1
AMUX
AIN01IC
AIN23IC
X
AMX2AD1
AMX2AD2
AMX2SLADC2CN
AIN2.0 (P1.0)
AIN2.1 (P1.1)
AIN2.2 (P1.2)
AIN2.3 (P1.3)
AIN2.4 (P1.4)
AIN2.5 (P1.5)
AIN2.6 (P1.6)
AIN2.7 (P1.7)
Figure 7.1. ADC2 Functional Block Diagram
7.1.Analog Multiplexer and PGA
AD2EN
AV+
AV+
ADC2LTHADC2GTH
REF
SYSCLK
16
Dig
Comp
ADC Window
Interrupt
8-Bit
+
SAR
-
AD2SC1
AD2SC0
ADC
AMP2GN0
AMP2GN1
AD2TM
AD2EN
AD2BUSY
AD2INT
AGND
AMX2AD0
AD2SC3
AD2SC4
ADC2CF
AD2SC2
Start Conversion
AD2CM0
AD2CM1
AD2CM2
8
ADC2
000
Write to AD2BUSY
Timer 3 Overflow
001
010
CNVSTR
Timer 2 Overflow
011
Write to AD0BUSY
1xx
(synchronized with
ADC0)
Eight ADC2 channels are available for measurement, as selected by the AMX2SL register (see SFR Definition 7.2). The PGA amplifies the ADC2 output signal by an amount determined by the states of the
AMP2GN2-0 bits in the ADC2 Configuration register, ADC2CF (SFR Definition 7.1). The PGA can be software-programmed for gains of 0.5, 1, 2, or 4. Gain defaults to 0.5 on reset.
Important Note: AIN2 pins also function as Port 1 I/O pins, and must be configured as analog inputs when
used as ADC2 inputs. To configure an AIN2 pin for analog input, set to ‘0’ the corresponding bit in register
P1MDIN. Port 1 pins selected as analog inputs are skipped by the Digital I/O Crossbar. See Section
“17.1.5. Configuring Port 1, 2, and 3 Pins as Analog Inputs” on page 209 for more information on con-
figuring the AIN2 pins.
Rev. 1.491
C8051F040/1/2/3/4/5/6/7
7.2.ADC2 Modes of Operation
ADC2 has a maximum conversion speed of 500 ksps. The ADC2 conversion clock (SAR2 clock) is a
divided version of the system clock, determined by the AD2SC bits in the ADC2CF register (system clock
divided by (AD2SC + 1) for 0 ≤ AD2SC ≤ 31). The maximum ADC2 conversion clock is 7.5 MHz.
7.2.1. Starting a Conversion
A conversion can be initiated in one of five ways, depending on the programmed states of the ADC2 Start
of Conversion Mode bits (AD2STM2-AD2STM0) in ADC2CN. Conversions may be initiated by the following:
•Writing a ‘1’ to the AD0BUSY of register ADC0CN (initiate conversion of ADC2 and ADC0 with a
single software command).
An important note about external convert start (CNVSTR0 and CNVSTR2): If CNVSTR2 is enabled in
the digital crossbar (Section “17.1. Ports 0 through 3 and the Priority Crossbar Decoder” on
page 206), CNVSTR2 will be the external convert start signal for ADC2. However, if only CNVSTR0 is
enabled in the digital crossbar and CNVSTR2 is not enabled, then CNVSTR0 may serve as the start of
conversion for both ADC0 and ADC2. This permits synchronous sampling of both ADC0 and ADC2.
During conversion, the AD2BUSY bit is set to logic 1 and restored to 0 when conversion is complete. The
falling edge of AD2BUSY triggers an interrupt (when enabled) and sets the interrupt flag in ADC2CN. Converted data is available in the ADC2 data word, ADC2.
When a conversion is initiated by writing a ‘1’ to AD2BUSY, it is recommended to poll AD2INT to determine
when the conversion is complete. The recommended procedure is:
Step 1. Write a ‘0’ to AD2INT;
Step 2. Write a ‘1’ to AD2BUSY;
Step 3. Poll AD2INT for ‘1’;
Step 4. Process ADC2 data.
7.2.2. Tracking Modes
According to Table 7.2, each ADC2 conversion must be preceded by a minimum tracking time for the converted result to be accurate. The AD2TM bit in register ADC2CN controls the ADC2 track-and-hold mode.
In its default state, the ADC2 input is continuously tracked, except when a conversion is in progress. When
the AD2TM bit is logic 1, ADC2 operates in low-power tracking mode. In this mode, each conversion is preceded by a tracking period of 3 SAR clocks (after the start-of-conversion signal). When the CNVSTR2 (or
CNVSTR0, See Section 7.2.1 above) signal is used to initiate conversions in low-power tracking mode,
ADC2 tracks only when CNVSTR2 is low; conversion begins on the rising edge of CNVSTR2 (see
Figure 7.2). Tracking can also be disabled (shutdown) when the entire chip is in low power standby or
sleep modes. Low-power Track-and-Hold mode is also useful when AMUX or PGA settings are frequently
changed, due to the settling time requirements described in Section “7.2.3. Settling Time Require-
ments” on page 94.
92Rev. 1.4
CNVSTR2/CNVSTR0
(AD2CM[2:0]=010)
SAR2 Clocks
C8051F040/1/2/3/4/5/6/7
A. ADC Timing for External Trigger Source
123456789
AD2TM=1
Write '1' to AD2BUSY,
Timer 3 Overflow,
Timer 2 Overflow,
Write '1' to AD0BUSY
(AD2CM[2:0]=000, 001, 011, 0xx)
SAR2 Clocks
AD2TM=1
SAR2 Clocks
AD2TM=0
Figure 7.2. ADC2 Track and Conversion Example Timing
Low Power
or Convert
Track or ConvertConvertTrackAD2TM=0
TrackConvertLow Power Mode
B. ADC Timing for Internal Trigger Source
123456789101112
Low Power
or Convert
Track or
Convert
TrackConvertLow Power Mode
123456789
ConvertTrack
Rev. 1.493
C8051F040/1/2/3/4/5/6/7
7.2.3. Settling Time Requirements
A minimum tracking time is required before an accurate conversion can be performed. This tracking time is
determined by the ADC2 MUX resistance, the ADC2 sampling capacitance, any external source resistance, and the accuracy required for the conversion. Figure 7.3 shows the equivalent ADC2 input circuit.
The required ADC2 settling time for a given settling accuracy (SA) may be approximated by Equation 7.1.
Note: An absolute minimum settling time of 0.8 µs required after any MUX selection. Note that in lowpower tracking mode, three SAR2 clocks are used for tracking at the start of every conversion. For most
applications, these three SAR2 clocks will meet the tracking requirements.
n
2
⎛⎞
t
Equation 7.1. ADC2 Settling Time Requirements
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
R
n is the ADC resolution in bits (8).
is the sum of the ADC2 MUX resistance and any external source resistance.
TOTAL
-------
×ln=
⎝⎠
SA
R
TOTALCSAMPLE
MUX Select
AIN2.x
R
= 5k
MUX
C
= 10pF
SAMPLE
RC
= R
MUX
* C
SAMP LE
Input
Figure 7.3. ADC2 Equivalent Input Circuit
94Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 7.1. AMX2CF: AMUX2 Configuration
RRRRR/WR/WR/WR/WReset Value
----PIN67ICPIN45ICPIN23ICPIN01IC 00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-4:UNUSED. Read = 0000b; Write = don’t care
Bit3:PIN67IC: P1.6, P1.7 Input Pair Configuration Bit
0: P1.6 and P1.7 are independent single-ended inputs
1: P1.6, P1.7 are (respectively) +, - differential input pair
Bit2:PIN45IC: P1.4, P1.5 Input Pair Configuration Bit
0: P1.4 and P1.5 are independent single-ended inputs
1: P1.4, P1.5 are (respectively) +, - differential input pair
Bit1:PIN23IC: P1.2, P1.3 Input Pair Configuration Bit
0: P1.2 and P1.3 are independent single-ended inputs
1: P1.2, P1.3 are (respectively) +, - differential input pair
Bit0:PIN01IC: P1.0, P1.1 Input Pair Configuration Bit
0: P1.0 and P1.1 are independent single-ended inputs
1: P1.0, P1.1 are (respectively) +, - differential input pair
0xBA
2
NOTE:The ADC2 Data Word is in 2’s complement format for channels configured as differential.
Table 7.1. AMUX Selection Chart (AMX2AD2-0 and AMX2CF3-0 bits)
000001010011100101110111
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
AMX2CF Bits 3-0
1010
1011
1100
1101
1110
1111
P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7
+(P1.0)
-(P1.1)
P1.0P1.1
+(P1.0)
-(P1.1)
P1.0P1.1P1.2P1.3
+(P1.0)
-(P1.1)
P1.0P1.1
+(P1.0)
-(P1.1)
P1.0P1.1P1.2P1.3P1.4P1.5
+(P1.0)
-(P1.1)
P1.0P1.1
+(P1.0)
-(P1.1)
P1.0P1.1P1.2P1.3
+(P1.0)
-(P1.1)
P1.0P1.1
+(P1.0)
-(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
-(P1.0)
+(P1.1)
P1.2P1.3P1.4P1.5P1.6P1.7
+(P1.2)
-(P1.3)
+(P1.2)
-(P1.3)
P1.2P1.3
+(P1.2)
-(P1.3)
+(P1.2)
-(P1.3)
P1.2P1.3P1.4P1.5
+(P1.2)
-(P1.3)
+(P1.2)
-(P1.3)
P1.2P1.3
+(P1.2)
-(P1.3)
+(P1.2)
-(P1.3)
AMX2AD2-0
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
-(P1.2)
+(P1.3)
P1.4P1.5P1.6P1.7
P1.4P1.5P1.6P1.7
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
P1.4P1.5
P1.4P1.5
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
+(P1.4)
-(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
-(P1.4)
+(P1.5)
P1.6P1.7
P1.6P1.7
P1.6P1.7
P1.6P1.7
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
+(P1.6)
-(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
-(P1.6)
+(P1.7)
96Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 7.3. ADC2CF: ADC2 Configuration
R/WR/WR/WR/WR/WRR/WR/WReset Value
AD2SC4A D 2 S C3AD 2 S C 2A D 2 SC1AD 2 S C 0-AMP 2 G N 1 AMP2 G N 0 1111100 0
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
Bits7-3:AD2SC4-0: ADC2 SAR Conversion Clock Period Bits
SAR Conversion clock is derived from system clock by the following equation, where
AD2SC refers to the 5-bit value held in AD2SC4-0. SAR conversion clock requirements are
given in Table 7.2.
0: ADC2 Disabled. ADC2 is in low-power shutdown.
1: ADC2 Enabled. ADC2 is active and ready for data conversions.
Bit6:AD2TM: ADC2 Track Mode Bit.
0: Normal Track Mode: When ADC2 is enabled, tracking is continuous unless a conversion is in
process.
1: Low-power Track Mode: Tracking defined by AD2STM2-0 bits (see below).
This flag must be cleared by software.
0: ADC2 has not completed a data conversion since the last time this flag was cleared.
1: ADC2 has completed a data conversion.
Bit4:AD2BUSY: ADC2 Busy Bit.
Read:
0: ADC2 Conversion is complete or a conversion is not currently in progress. AD2INT is set to
logic 1 on the falling edge of AD2BUSY.
1: ADC2 Conversion is in progress.
Write:
0: No Effect.
1: Initiates ADC2 Conversion if AD2STM2-0 = 000b
Bits3-1:AD2CM2-0: ADC2 Start of Conversion Mode Select.
AD2TM = 0:
000: ADC2 conversion initiated on every write of ‘1’ to AD2BUSY.
001: ADC2 conversion initiated on overflow of Timer 3.
010: ADC2 conversion initiated on rising edge of external CNVSTR2 or CNVSTR0.
011: ADC2 conversion initiated on overflow of Timer 2.
1xx: ADC2 conversion initiated on write of ‘1’ to AD0BUSY (synchronized with ADC0 softwarecommanded conversions).
AD2TM = 1:
000: Tracking initiated on write of ‘1’ to AD2BUSY and lasts 3 SAR2 clocks, followed by conversion.
001: Tracking initiated on overflow of Timer 3 and lasts 3 SAR2 clocks, followed by conversion.
010: ADC2 tracks only when CNVSTR2 (or CNVSTR0, See Section 7.2.1) input is logic low; conversion starts on rising CNVSTR2 edge.
011: Tracking initiated on overflow of Timer 2 and lasts 3 SAR2 clocks, followed by conversion.
1xx: Tracking initiated on write of ‘1’ to AD0BUSY and lasts 3 SAR2 clocks, followed by conversion.
Bit0:AD2WINT: ADC2 Window Compare Interrupt Flag.
0: ADC2 window comparison data match has not occurred since this flag was last cleared.
1: ADC2 window comparison data match has occurred. This flag must be cleared in software.
An important note about external convert start (CNVSTR0 and CNVSTR2)
the digital crossbar (
on page 206
CNVSTR0 is enabled in the digital crossbar and CNVSTR2 is not enabled, then CNVSTR0 may
serve as the start of conversion for both ADC0 and ADC2.
Section “17.1. Ports 0 through 3 and the Priority Crossbar Decoder”
), CNVSTR2 will be the external convert start signal for ADC2. However, if only
SFR Address:
SFR Page:
: If CNVSTR2 is enabled in
0xE8
2
98Rev. 1.4
C8051F040/1/2/3/4/5/6/7
SFR Definition 7.5. ADC2: ADC2 Data Word
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
Bits7-0:ADC2 Data Word.
8-bit ADC Data Word appears in the ADC2 Data Word Register as follows:
Example: ADC2 Data Word Conversion Map, AIN1.0 Input
(AMX2SL = 0x00)
AIN1.0-AGND
(Volts)
VREF * (255/256)0xFF
VREF / 20x80
VREF * (127/256)0x7F
00x00
SFR Address:
SFR Page:
ADC2
0xBE
2
CodeVin
Gain
---------------
×256×=
VREF
Figure 7.4. ADC2 Data Word Example
Rev. 1.499
C8051F040/1/2/3/4/5/6/7
7.3.ADC2 Programmable Window Detector
The ADC2 Programmable Window Detector continuously compares the ADC2 output to user-programmed
limits, and notifies the system when an out-of-bound condition is detected. This is especially effective in an
interrupt-driven system, saving code space and CPU bandwidth while delivering faster system response
times. The window detector interrupt flag (AD2WINT in ADC2CN) can also be used in polled mode. The
reference words are loaded into the ADC2 Greater-Than and ADC2 Less-Than registers (ADC2GT and
ADC2LT). Notice that the window detector flag can be asserted when the measured data is inside or outside the user-programmed limits, depending on the programming of the ADC2GT and ADC2LT registers.
SFR Definition 7.6. ADC2GT: ADC2 Greater-Than Data
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
11111111
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:High byte of ADC2 Greater-Than Data Word.
0xC4
2
SFR Definition 7.7. ADC2LT: ADC2 Less-Than Data
R/WR/WR/WR/WR/WR/WR/WR/WReset Value
00000000
Bit7Bit6Bit5Bit4Bit3Bit2Bit1Bit0
SFR Address:
SFR Page:
Bits7-0:Low byte of ADC2 Greater-Than Data Word.
7.3.1. Window Detector In Single-Ended Mode
Figure 7.5 shows two example window comparisons for Single-ended mode, with ADC2LT = 0x20 and
ADC2GT = 0x10. In Single-ended mode, the codes vary from 0 to VREF*(255/256) and are represented as
8-bit unsigned integers. In the left example, an AD2WINT interrupt will be generated if the ADC2 conversion word (ADC2) is within the range defined by ADC2GT and ADC2LT (if 0x10 < ADC2 < 0x20). In the
right example, and AD2WINT interrupt will be generated if ADC2 is outside of the range defined by
ADC2GT and ADC2LT (if ADC2 < 0x10 or ADC2 > 0x20).
0xC6
2
100Rev. 1.4
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.