ETC C8051F062

Advanced
Information
C8051F060/1/2/3
Mixed-Signal ISP FLASH MCU Family
HIGH SPEED 8051 µC CORE
- Pipelined Instruction Architecture; Executes 70% of
ANALOG PERIPHERALS
- Two 16-Bit SAR ADCs
• 16-Bit Resolution
• ±0.75 LSB INL, guaranteed no missing codes
• Programmable Throughput up to 1 Msps
• Operate as Two Single-Ended or One Differential Con-
-
Can Synchronize Outputs to Timers for Jitter-Free Waveform Generation
Three Analog Comparators
•
-
Programmable Hysteresis/Response Time
- Voltage Reference
- Precision VDD Monitor/Brown-Out Detector
ON-CHIP JTAG DEBUG & BOUNDARY SCAN
- On-Chip Debug Circuitry Facilitates Full- Speed, Non-
-
ED
-
Intrusive In-Circuit/In-System Debugging
Provides Breakpoints, Single-Stepping, Watchpoints,
Stack Monitor; Inspect/Modify Memory and Registers
Superior Performance to Emulation Systems Using ICEChips, Target Pods, and Sockets
IEEE1149.1 Compliant Boundary Scan
Complete Development Kit
IN
-
N
Two 12-bit DACs
•
-
DIGITAL PERIPHERALS
- 59 General Purpose I/O Pins (C8051F060/2)
- 24 General Purpose I/O Pins (C8051F061/3)
- Bosch Controller Area Network (CAN 2.0B), Hardware
Programmable Throughput up to 200 ksps
8 External Inputs, Single-Ended or Differential
Built-in Temperature Sensor
SMBus™ (I2C™ Compatible), SPI™, and Two UART
Serial Ports Available Concurrently
Programmable 16-bit Counter/Timer Array with
6 Capture/Compare Modules
5 General Purpose 16-bit Counter/Timers
Dedicated Watch-Dog Timer; Bi-directional Reset Pin
CLOCK SOURCES
- Internal Calibrated Precision Oscillator: 24.5 MHz
- External Oscillator: Crystal, RC, C, or Clock
- Real-Time Clock Mode using Timer 2, 3, 4, or PCA
SUPPLY VOLTAGE .......................... 2.7V TO 3.6V
- Multiple Power Saving Sleep and Shutdown Modes
100-Pin TQFP and 64-Pin TQFP Packages Available
Temperature Range: -40°C to +85°C
ANALOG PERIPHERALS
VA
NC
16-bit
1 Msps
ADC
DMA
Interface
AD
AMUX
16-bit
1 Msps
ADC
DS007-0.4-NOV02
10-bit
200ksps
ADC
TEMP
SENSOR
DIGITAL I/O
CAN
2.0B
UART0
UART1
SMBus
12-Bit
DAC
VREF
-
Timer 1
+
+
Timer 3
-
-
Timer 4
VOLTAGE
COMPARATORS
Port 2
PCA
Timer 2
+
Port 1
Port 3
SPI Bus
Timer 0
12-Bit
DAC
Port 0
CROSSBAR
•
•
•
IO
10-bit SAR ADC
Sectors
External 64k Byte Data Memory Interface with multiplexed and non-multiplexed modes (C8051F060/2)
FO
-
-
External Memory
Interface
•
verter
Direct Memory Access; Data Stored in RAM Without Software Overhead
Data-Dependent Windowed Interrupt Generator
RM
AT
•
Instruction Set in 1 or 2 System Clocks
- Up to 25 MIPS Throughput with 25 MHz Clock
- Flexible Interrupt Sources
MEMORY
- 4352 Bytes Internal Data RAM (4k + 256)
- 64k Bytes FLASH; In-System programmable in 512-byte
Port 4
Port 5
Port 6
Port 7
100 pin Only
HIGH-SPEED CONTROLLER CORE
8051 CPU
(25MIPS)
22
INTERRUPTS
64KB
ISP FLASH
DEBUG
CIRCUITRY
4352 B
JTAG
SRAM
CLOCK
SANITY
CIRCUIT
CONTROL
CYGNAL Integrated Products, Inc. © 2002
Page 1
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 2
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
TABLE OF CONTENTS
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
1. SYSTEM OVERVIEW .........................................................................................................19
1.1. CIP-51™ Microcontroller Core ......................................................................................23
1.1.1. Fully 8051 Compatible ..........................................................................................23
1.1.2. Improved Throughput ............................................................................................23
1.1.3. Additional Features................................................................................................24
1.2. On-Chip Memory ............................................................................................................25
1.3. JTAG Debug and Boundary Scan ...................................................................................26
1.4. Programmable Digital I/O and Crossbar .........................................................................27
1.5. Programmable Counter Array .........................................................................................28
1.6. Controller Area Network.................................................................................................29
1.7. Serial Ports.......................................................................................................................30
1.8. 16-Bit Analog to Digital Converters ...............................................................................31
1.9. 10-Bit Analog to Digital Converter.................................................................................32
1.10.Comparators and DACs...................................................................................................33
2. ABSOLUTE MAXIMUM RATINGS ..................................................................................34
3. GLOBAL DC ELECTRICAL CHARACTERISTICS ......................................................35
4. PINOUT AND PACKAGE DEFINITIONS........................................................................36
5. 16-BIT ADCS (ADC0 AND ADC1)......................................................................................45
5.1. Single-Ended or Differential Operation ..........................................................................46
5.1.1. Pseudo-Differential Inputs .....................................................................................46
5.2. Voltage Reference ...........................................................................................................47
5.3. ADC Modes of Operation ...............................................................................................48
5.3.1. Starting a Conversion.............................................................................................48
5.3.2. Tracking Modes .....................................................................................................49
5.3.3. Settling Time Requirements ..................................................................................51
5.4. Calibration .......................................................................................................................61
5.5. ADC0 Programmable Window Detector.........................................................................64
6. DIRECT MEMORY ACCESS INTERFACE (DMA0) .....................................................71
6.1. Writing to the Instruction Buffer.....................................................................................71
6.2. DMA0 Instruction Format...............................................................................................72
6.3. XRAM Addressing and Setup .........................................................................................72
6.4. Instruction Execution in Mode 0 .....................................................................................73
6.5. Instruction Execution in Mode 1 .....................................................................................74
6.6. Interrupt Sources .............................................................................................................75
6.7. Data Buffer Overflow Warnings and Errors ...................................................................75
7. 10-BIT ADC (ADC2) .............................................................................................................83
7.1. Analog Multiplexer .........................................................................................................84
7.2. Modes of Operation.........................................................................................................85
7.2.1. Starting a Conversion.............................................................................................85
7.2.2. Tracking Modes .....................................................................................................86
7.2.3. Settling Time Requirements ..................................................................................87
7.3. Programmable Window Detector ....................................................................................93
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 3
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
7.3.1. Window Detector In Single-Ended Mode .............................................................95
7.3.2. Window Detector In Differential Mode.................................................................96
8. DACS, 12-BIT VOLTAGE MODE (DAC0 AND DAC1) ..................................................99
8.1. DAC Output Scheduling................................................................................................100
8.1.1. Update Output On-Demand .................................................................................100
8.1.2. Update Output Based on Timer Overflow ...........................................................100
8.2. DAC Output Scaling/Justification.................................................................................100
9. VOLTAGE REFERENCE 2 (C8051F060/2).....................................................................107
10. VOLTAGE REFERENCE 2 (C8051F061/3) ....................................................................109
11. COMPARATORS................................................................................................................111
11.1.Comparator Inputs .........................................................................................................113
12. CIP-51 MICROCONTROLLER........................................................................................117
12.1.Instruction Set................................................................................................................118
12.1.1. Instruction and CPU Timing................................................................................118
12.1.2. MOVX Instruction and Program Memory...........................................................118
12.2.Memory Organization ...................................................................................................123
12.2.1. Program Memory .................................................................................................123
12.2.2. Data Memory .......................................................................................................123
12.2.3. General Purpose Registers ...................................................................................124
12.2.4. Bit Addressable Locations ...................................................................................124
12.2.5. Stack .................................................................................................................124
12.2.6. Special Function Registers...................................................................................125
12.2.6.1. SFR Paging..................................................................................................125
12.2.6.2.Interrupts and SFR Paging...........................................................................125
12.2.6.3.SFR Page Stack Example ............................................................................127
12.2.7. Register Descriptions ...........................................................................................140
12.3.Interrupt Handler ...........................................................................................................143
12.3.1. MCU Interrupt Sources and Vectors ...................................................................143
12.3.2. External Interrupts ...............................................................................................143
12.3.3. Interrupt Priorities................................................................................................145
12.3.4. Interrupt Latency..................................................................................................145
12.3.5. Interrupt Register Descriptions ............................................................................146
12.4.Power Management Modes ...........................................................................................152
12.4.1. Idle Mode .............................................................................................................152
12.4.2. Stop Mode............................................................................................................152
13. RESET SOURCES ..............................................................................................................155
13.1.Power-on Reset..............................................................................................................156
13.2.Power-fail Reset ............................................................................................................156
13.3.External Reset................................................................................................................156
13.4.Missing Clock Detector Reset .......................................................................................157
13.5.Comparator0 Reset ........................................................................................................157
13.6.External CNVSTR2 Pin Reset.......................................................................................157
13.7.Watchdog Timer Reset ..................................................................................................157
13.7.1. Enable/Reset WDT ..............................................................................................157
13.7.2. Disable WDT .......................................................................................................158
Page 4
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
13.7.3. Disable WDT Lockout.........................................................................................158
13.7.4. Setting WDT Interval...........................................................................................158
14. OSCILLATORS...................................................................................................................161
14.1.Programmable Internal Oscillator .................................................................................161
14.2.External Oscillator Drive Circuit...................................................................................163
14.3.System Clock Selection.................................................................................................163
14.4.External Crystal Example..............................................................................................165
14.5.External RC Example ....................................................................................................165
14.6.External Capacitor Example..........................................................................................165
15. FLASH MEMORY ..............................................................................................................167
15.1.Programming The Flash Memory .................................................................................167
15.2.Non-volatile Data Storage .............................................................................................169
15.3.Security Options ............................................................................................................169
16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM.......................175
16.1.Accessing XRAM..........................................................................................................175
16.1.1. 16-Bit MOVX Example.......................................................................................175
16.1.2. 8-Bit MOVX Example.........................................................................................175
16.2.Configuring the External Memory Interface .................................................................176
16.3.Port Selection and Configuration ..................................................................................176
16.4.Multiplexed and Non-multiplexed Selection.................................................................178
16.4.1. Multiplexed Configuration ..................................................................................178
16.4.2. Non-multiplexed Configuration...........................................................................179
16.5.Memory Mode Selection ...............................................................................................180
16.5.1. Internal XRAM Only ...........................................................................................180
16.5.2. Split Mode without Bank Select ..........................................................................180
16.5.3. Split Mode with Bank Select ...............................................................................181
16.5.4. External Only .......................................................................................................181
16.6.Timing .......................................................................................................................182
16.6.1. Non-multiplexed Mode........................................................................................183
16.6.1.1.16-bit MOVX: EMI0CF[4:2] = ‘101’, ‘110’, or ‘111’................................183
16.6.1.2. 8-bit MOVX without Bank Select: EMI0CF[4:2] = ‘101’ or ‘111’............184
16.6.1.3. 8-bit MOVX with Bank Select: EMI0CF[4:2] = ‘110’. ..............................185
16.6.2. Multiplexed Mode................................................................................................186
16.6.2.1.16-bit MOVX: EMI0CF[4:2] = ‘001’, ‘010’, or ‘011’................................186
16.6.2.2. 8-bit MOVX without Bank Select: EMI0CF[4:2] = ‘001’ or ‘011’............187
16.6.2.3. 8-bit MOVX with Bank Select: EMI0CF[4:2] = ‘010’. ..............................188
17. PORT INPUT/OUTPUT .....................................................................................................191
17.1.Ports 0 through 3 and the Priority Crossbar Decoder....................................................193
17.1.1. Crossbar Pin Assignment and Allocation ............................................................193
17.1.2. Configuring the Output Modes of the Port Pins ..................................................194
17.1.3. Configuring Port Pins as Digital Inputs ...............................................................195
17.1.4. Weak Pull-ups......................................................................................................195
17.1.5. Configuring Port 1 and 2 pins as Analog Inputs..................................................195
17.1.6. Crossbar Pin Assignment Example......................................................................196
17.2.Ports 4 through 7 (C8051F060/2 only)..........................................................................207
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 5
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
17.2.1. Configuring Ports which are not Pinned Out.......................................................207
17.2.2. Configuring the Output Modes of the Port Pins ..................................................207
17.2.3. Configuring Port Pins as Digital Inputs ...............................................................207
17.2.4. Weak Pull-ups......................................................................................................207
17.2.5. External Memory Interface ..................................................................................208
18. CONTROLLER AREA NETWORK (CAN0) ..................................................................213
18.1.Bosch CAN Controller Operation .................................................................................215
18.2.CAN Registers...............................................................................................................216
18.2.1. CAN Controller Protocol Registers .....................................................................216
18.2.2. Message Object Interface Registers.....................................................................216
18.2.3. Message Handler Registers..................................................................................216
18.2.4. CIP-51 MCU Special Function Registers ............................................................217
18.2.5. Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN Registers .217
18.2.6. CAN0ADR Autoincrement Feature.....................................................................217
19. SYSTEM MANAGEMENT BUS / I2C BUS (SMBUS0) .................................................223
19.1.Supporting Documents ..................................................................................................224
19.2.SMBus Protocol.............................................................................................................224
19.2.1. Arbitration............................................................................................................225
19.2.2. Clock Low Extension...........................................................................................225
19.2.3. SCL Low Timeout ...............................................................................................225
19.2.4. SCL High (SMBus Free) Timeout.......................................................................225
19.3.SMBus Transfer Modes.................................................................................................226
19.3.1. Master Transmitter Mode ....................................................................................226
19.3.2. Master Receiver Mode.........................................................................................226
19.3.3. Slave Transmitter Mode.......................................................................................227
19.3.4. Slave Receiver Mode ...........................................................................................227
19.4.SMBus Special Function Registers ...............................................................................228
19.4.1. Control Register ...................................................................................................228
19.4.2. Clock Rate Register .............................................................................................230
19.4.3. Data Register........................................................................................................231
19.4.4. Address Register ..................................................................................................231
19.4.5. Status Register .....................................................................................................232
20. ENHANCED SERIAL PERIPHERAL INTERFACE (SPI0) .........................................235
20.1.Signal Descriptions........................................................................................................236
20.1.1. Master Out, Slave In (MOSI) ..............................................................................236
20.1.2. Master In, Slave Out (MISO) ..............................................................................236
20.1.3. Serial Clock (SCK) ..............................................................................................236
20.1.4. Slave Select (NSS)...............................................................................................236
20.2.SPI0 Master Mode Operation........................................................................................237
20.3.SPI0 Slave Mode Operation ..........................................................................................239
20.4.SPI0 Interrupt Sources...................................................................................................239
20.5.Serial Clock Timing ......................................................................................................240
20.6.SPI Special Function Registers .....................................................................................241
21. UART0 ..................................................................................................................................249
21.1.UART0 Operational Modes ..........................................................................................250
Page 6
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
21.1.1. Mode 0: Synchronous Mode................................................................................250
21.1.2. Mode 1: 8-Bit UART, Variable Baud Rate .........................................................251
21.1.3. Mode 2: 9-Bit UART, Fixed Baud Rate ..............................................................252
21.1.4. Mode 3: 9-Bit UART, Variable Baud Rate .........................................................253
21.2.Multiprocessor Communications...................................................................................254
21.2.1. Configuration of a Masked Address ....................................................................254
21.2.2. Broadcast Addressing ..........................................................................................254
21.3.Frame and Transmission Error Detection......................................................................255
22. UART1 ..................................................................................................................................261
22.1.Enhanced Baud Rate Generation...................................................................................262
22.2.Operational Modes ........................................................................................................263
22.2.1. 8-Bit UART .........................................................................................................263
22.2.2. 9-Bit UART .........................................................................................................264
22.3.Multiprocessor Communications...................................................................................265
23. TIMERS................................................................................................................................271
23.1.Timer 0 and Timer 1......................................................................................................271
23.1.1. Mode 0: 13-bit Counter/Timer.............................................................................271
23.1.2. Mode 1: 16-bit Counter/Timer.............................................................................272
23.1.3. Mode 2: 8-bit Counter/Timer with Auto-Reload .................................................273
23.1.4. Mode 3: Two 8-bit Counter/Timers (Timer 0 Only) ...........................................274
23.2.Timer 2, Timer 3, and Timer 4 ......................................................................................279
23.2.1. Configuring Timer 2, 3, and 4 to Count Down....................................................279
23.2.2. Capture Mode ......................................................................................................280
23.2.3. Auto-Reload Mode ..............................................................................................281
23.2.4. Toggle Output Mode............................................................................................281
24. PROGRAMMABLE COUNTER ARRAY .......................................................................287
24.1.PCA Counter/Timer.......................................................................................................288
24.2.Capture/Compare Modules............................................................................................289
24.2.1. Edge-triggered Capture Mode .............................................................................290
24.2.2. Software Timer (Compare) Mode........................................................................291
24.2.3. High Speed Output Mode ....................................................................................292
24.2.4. Frequency Output Mode ......................................................................................293
24.2.5. 8-Bit Pulse Width Modulator Mode ....................................................................294
24.2.6. 16-Bit Pulse Width Modulator Mode ..................................................................295
24.3.Register Descriptions for PCA0 ....................................................................................296
25. JTAG (IEEE 1149.1)............................................................................................................301
25.1.Boundary Scan...............................................................................................................302
25.1.1. EXTEST Instruction ............................................................................................305
25.1.2. SAMPLE Instruction ...........................................................................................305
25.1.3. BYPASS Instruction ............................................................................................305
25.1.4. IDCODE Instruction ............................................................................................305
25.2.Flash Programming Commands ....................................................................................306
25.3.Debug Support...............................................................................................................309
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 7
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 8
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
LIST OF FIGURES
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
1. SYSTEM OVERVIEW .........................................................................................................19
Figure 1.1. C8051F060/2 Block Diagram..............................................................................21
Figure 1.2. C8051F061/3 Block Diagram..............................................................................22
Figure 1.3. Comparison of Peak MCU Execution Speeds.....................................................23
Figure 1.4. On-Board Clock and Reset..................................................................................24
Figure 1.5. On-Chip Memory Map ........................................................................................25
Figure 1.6. Development/In-System Debug Diagram ...........................................................26
Figure 1.7. Digital Crossbar Diagram....................................................................................27
Figure 1.8. PCA Block Diagram............................................................................................28
Figure 1.9. CAN Controller Overview ..................................................................................29
Figure 1.10. 16-Bit ADC Block Diagram................................................................................31
Figure 1.11. 10-Bit ADC Diagram ..........................................................................................32
Figure 1.12. Comparator and DAC Diagram...........................................................................33
2. ABSOLUTE MAXIMUM RATINGS ..................................................................................34
3. GLOBAL DC ELECTRICAL CHARACTERISTICS ......................................................35
4. PINOUT AND PACKAGE DEFINITIONS........................................................................36
Figure 4.1. TQFP-100 Pinout Diagram..................................................................................41
Figure 4.2. TQFP-100 Package Drawing...............................................................................42
Figure 4.3. TQFP-64 Pinout Diagram....................................................................................43
Figure 4.4. TQFP-64 Package Drawing.................................................................................44
5. 16-BIT ADCS (ADC0 AND ADC1)......................................................................................45
Figure 5.1. 16-Bit ADC0 and ADC1 Control Path Diagram.................................................45
Figure 5.2. 16-bit ADC0 and ADC1 Data Path Diagram ......................................................46
Figure 5.3. Voltage Reference Block Diagram......................................................................47
Figure 5.4. ADC Track and Conversion Example Timing ....................................................49
Figure 5.5. ADC0 and ADC1 Equivalent Input Circuits .......................................................51
Figure 5.6. AMX0SL: AMUX Configuration Register .........................................................52
Figure 5.7. ADC0CF: ADC0 Configuration Register ...........................................................53
Figure 5.8. ADC1CF: ADC1 Configuration Register ...........................................................54
Figure 5.9. ADC0CN: ADC0 Control Register .....................................................................55
Figure 5.10. ADC1CN: ADC1 Control Register .....................................................................56
Figure 5.11. REF0CN: Reference Control Register 0 .............................................................57
Figure 5.12. REF1CN: Reference Control Register 1 .............................................................57
Figure 5.13. ADC0H: ADC0 Data Word MSB Register.........................................................58
Figure 5.14. ADC0L: ADC0 Data Word LSB Register ..........................................................58
Figure 5.15. ADC0 Data Word Example.................................................................................59
Figure 5.16. ADC1H: ADC1 Data Word MSB Register.........................................................60
Figure 5.17. ADC1L: ADC1 Data Word LSB Register ..........................................................60
Figure 5.18. ADC1 Data Word Example.................................................................................60
Figure 5.19. Calibration Coefficient Locations .......................................................................61
Figure 5.20. Offset and Gain Register Mapping......................................................................62
Figure 5.21. Offset and Gain Calibration Block Diagram .......................................................62
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 9
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Figure 5.22. ADC0CPT: ADC Calibration Pointer Register...................................................63
Figure 5.23. ADC0CCF: ADC Calibration Coefficient Register ............................................63
Figure 5.24. ADC0GTH: ADC0 Greater-Than Data High Byte Register...............................64
Figure 5.25. ADC0GTL: ADC0 Greater-Than Data Low Byte Register ................................64
Figure 5.26. ADC0LTH: ADC0 Less-Than Data High Byte Register ....................................65
Figure 5.27. ADC0LTL: ADC0 Less-Than Data Low Byte Register .....................................65
Figure 5.28. 16-Bit ADC0 Window Interrupt Example: Single-Ended Data ..........................66
Figure 5.29. 16-Bit ADC0 Window Interrupt Example: Differential Data .............................67
6. DIRECT MEMORY ACCESS INTERFACE (DMA0) .....................................................71
Figure 6.1. DMA0 Block Diagram ........................................................................................71
Figure 6.2. DMA Mode 0 Operation .....................................................................................73
Figure 6.3. DMA Mode 1 Operation .....................................................................................74
Figure 6.4. DMA0CN: DMA0 Control Register ...................................................................76
Figure 6.5. DMA0CF: DMA0 Configuration Register..........................................................77
Figure 6.6. DMA0IPT: DMA0 Instruction Write Address Register .....................................78
Figure 6.7. DMA0IDT: DMA0 Instruction Write Data Register ..........................................78
Figure 6.8. DMA0BND: DMA0 Instruction Boundary Register ..........................................79
Figure 6.9. DMA0ISW: DMA0 Instruction Status Register..................................................79
Figure 6.10. DMA0DAH: DMA0 Data Address Beginning MSB Register ...........................80
Figure 6.11. DMA0DAL: DMA0 Data Address Beginning LSB Register .............................80
Figure 6.12. DMA0DSH: DMA0 Data Address Pointer MSB Register .................................80
Figure 6.13. DMA0DSL: DMA0 Data Address Pointer LSB Register...................................80
Figure 6.14. DMA0CTH: DMA0 Repeat Counter Limit MSB Register.................................81
Figure 6.15. DMA0CTL: DMA0 Repeat Counter Limit LSB Register ..................................81
Figure 6.16. DMA0CSH: DMA0 Repeat Counter MSB Register...........................................81
Figure 6.17. DMA0CSL: DMA0 Repeat Counter LSB Register ............................................81
7. 10-BIT ADC (ADC2) .............................................................................................................83
Figure 7.1. ADC2 Functional Block Diagram .......................................................................83
Figure 7.2. Typical Temperature Sensor Transfer Function..................................................85
Figure 7.3. 10-Bit ADC Track and Conversion Example Timing.........................................86
Figure 7.4. ADC2 Equivalent Input Circuits .........................................................................87
Figure 7.5. AMX2CF: AMUX2 Configuration Register.......................................................88
Figure 7.6. AMX2SL: AMUX2 Channel Select Register .....................................................89
Figure 7.7. ADC2CF: ADC2 Configuration Register ...........................................................90
Figure 7.8. ADC2H: ADC2 Data Word MSB Register.........................................................91
Figure 7.9. ADC2L: ADC2 Data Word LSB Register ..........................................................91
Figure 7.10. ADC2CN: ADC2 Control Register .....................................................................92
Figure 7.11. ADC2GTH: ADC2 Greater-Than Data High Byte Register...............................93
Figure 7.12. ADC2GTL: ADC2 Greater-Than Data Low Byte Register ................................93
Figure 7.13. ADC2LTH: ADC2 Less-Than Data High Byte Register ....................................94
Figure 7.14. ADC2LTL: ADC2 Less-Than Data Low Byte Register .....................................94
Figure 7.15. ADC Window Compare Example: Right-Justified Single-Ended Data..............95
Figure 7.16. ADC Window Compare Example: Left-Justified Single-Ended Data ................95
Figure 7.17. ADC Window Compare Example: Right-Justified Differential Data.................96
Figure 7.18. ADC Window Compare Example: Left-Justified Differential Data ...................96
Page 10
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
8. DACS, 12-BIT VOLTAGE MODE (DAC0 AND DAC1) ..................................................99
Figure 8.1. DAC Functional Block Diagram .........................................................................99
Figure 8.2. DAC0H: DAC0 High Byte Register .................................................................101
Figure 8.3. DAC0L: DAC0 Low Byte Register ..................................................................101
Figure 8.4. DAC0CN: DAC0 Control Register ...................................................................102
Figure 8.5. DAC1H: DAC1 High Byte Register .................................................................103
Figure 8.6. DAC1L: DAC1 Low Byte Register ..................................................................103
Figure 8.7. DAC1CN: DAC1 Control Register ...................................................................104
9. VOLTAGE REFERENCE 2 (C8051F060/2).....................................................................107
Figure 9.1. Voltage Reference Functional Block Diagram..................................................107
Figure 9.2. REF2CN: Reference Control Register 2 ...........................................................108
10. VOLTAGE REFERENCE 2 (C8051F061/3) ....................................................................109
Figure 10.1. Voltage Reference Functional Block Diagram .................................................109
Figure 10.2. REF2CN: Reference Control Register 2 ...........................................................110
11. COMPARATORS................................................................................................................111
Figure 11.1. Comparator Functional Block Diagram ............................................................111
Figure 11.2. Comparator Hysteresis Plot...............................................................................112
Figure 11.3. CPTnCN: Comparator 0, 1, and 2 Control Register..........................................114
Figure 11.4. CPTnMD: Comparator Mode Selection Register .............................................115
12. CIP-51 MICROCONTROLLER........................................................................................117
Figure 12.1. CIP-51 Block Diagram .....................................................................................117
Figure 12.2. Memory Map .....................................................................................................123
Figure 12.3. SFR Page Stack .................................................................................................126
Figure 12.4. SFR Page Stack While Using SFR Page 0x0F To Access Port 5 .....................127
Figure 12.5. SFR Page Stack After ADC2 Window Comparator Interrupt Occurs ..............128
Figure 12.6. SFR Page Stack Upon PCA Interrupt Occurring During an ADC2 ISR...........129
Figure 12.7. SFR Page Stack Upon Return From PCA Interrupt ..........................................130
Figure 12.8. SFR Page Stack Upon Return From ADC2 Window Interrupt.........................131
Figure 12.9. SFRPGCN: SFR Page Control Register............................................................132
Figure 12.10. SFRPAGE: SFR Page Register .......................................................................132
Figure 12.11. SFRNEXT: SFR Next Register .......................................................................133
Figure 12.12. SFRLAST: SFR Last Register ........................................................................133
Figure 12.13. SP: Stack Pointer .............................................................................................140
Figure 12.14. DPL: Data Pointer Low Byte ..........................................................................140
Figure 12.15. DPH: Data Pointer High Byte .........................................................................140
Figure 12.16. PSW: Program Status Word ............................................................................141
Figure 12.17. ACC: Accumulator..........................................................................................142
Figure 12.18. B: B Register ...................................................................................................142
Figure 12.19. IE: Interrupt Enable .........................................................................................146
Figure 12.20. IP: Interrupt Priority ........................................................................................147
Figure 12.21. EIE1: Extended Interrupt Enable 1 .................................................................148
Figure 12.22. EIE2: Extended Interrupt Enable 2 .................................................................149
Figure 12.23. EIP1: Extended Interrupt Priority 1.................................................................150
Figure 12.24. EIP2: Extended Interrupt Priority 2.................................................................151
Figure 12.25. PCON: Power Control.....................................................................................153
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 11
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
13. RESET SOURCES ..............................................................................................................155
Figure 13.1. Reset Sources ....................................................................................................155
Figure 13.2. Reset Timing .....................................................................................................156
Figure 13.3. WDTCN: Watchdog Timer Control Register ...................................................158
Figure 13.4. RSTSRC: Reset Source Register.......................................................................159
14. OSCILLATORS...................................................................................................................161
Figure 14.1. Oscillator Diagram ............................................................................................161
Figure 14.2. OSCICL: Internal Oscillator Calibration Register ............................................162
Figure 14.3. OSCICN: Internal Oscillator Control Register .................................................162
Figure 14.4. CLKSEL: Oscillator Clock Selection Register .................................................163
Figure 14.5. OSCXCN: External Oscillator Control Register...............................................164
15. FLASH MEMORY ..............................................................................................................167
Figure 15.1. FLASH Program Memory Map and Security Bytes .........................................170
Figure 15.2. FLACL: FLASH Access Limit .........................................................................171
Figure 15.3. FLSCL: FLASH Memory Control ....................................................................172
Figure 15.4. PSCTL: Program Store Read/Write Control .....................................................173
16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM.......................175
Figure 16.1. EMI0CN: External Memory Interface Control .................................................177
Figure 16.2. EMI0CF: External Memory Configuration .......................................................177
Figure 16.3. Multiplexed Configuration Example.................................................................178
Figure 16.4. Non-multiplexed Configuration Example .........................................................179
Figure 16.5. EMIF Operating Modes.....................................................................................180
Figure 16.6. EMI0TC: External Memory Timing Control ....................................................182
Figure 16.7. Non-multiplexed 16-bit MOVX Timing ...........................................................183
Figure 16.8. Non-multiplexed 8-bit MOVX without Bank Select Timing............................184
Figure 16.9. Non-multiplexed 8-bit MOVX with Bank Select Timing.................................185
Figure 16.10. Multiplexed 16-bit MOVX Timing .................................................................186
Figure 16.11. Multiplexed 8-bit MOVX without Bank Select Timing .................................187
Figure 16.12. Multiplexed 8-bit MOVX with Bank Select Timing.......................................188
17. PORT INPUT/OUTPUT .....................................................................................................191
Figure 17.1. Port I/O Cell Block Diagram.............................................................................191
Figure 17.2. Port I/O Functional Block Diagram ..................................................................192
Figure 17.3. Priority Crossbar Decode Table ........................................................................193
Figure 17.4. Crossbar Example: ............................................................................................197
Figure 17.5. XBR0: Port I/O Crossbar Register 0 .................................................................198
Figure 17.6. XBR1: Port I/O Crossbar Register 1 .................................................................199
Figure 17.7. XBR2: Port I/O Crossbar Register 2 .................................................................200
Figure 17.8. XBR3: Port I/O Crossbar Register 3 .................................................................201
Figure 17.9. P0: Port0 Data Register .....................................................................................202
Figure 17.10. P0MDOUT: Port0 Output Mode Register.......................................................202
Figure 17.11. P1: Port1 Data Register ...................................................................................203
Figure 17.12. P1MDIN: Port1 Input Mode Register .............................................................203
Figure 17.13. P1MDOUT: Port1 Output Mode Register.......................................................204
Figure 17.14. P2: Port2 Data Register ...................................................................................204
Figure 17.15. P2MDIN: Port2 Input Mode Register .............................................................205
Page 12
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Figure 17.16. P2MDOUT: Port2 Output Mode Register.......................................................205
Figure 17.17. P3: Port3 Data Register ...................................................................................206
Figure 17.18. P3MDOUT: Port3 Output Mode Register.......................................................206
Figure 17.19. P4: Port4 Data Register ...................................................................................209
Figure 17.20. P4MDOUT: Port4 Output Mode Register.......................................................209
Figure 17.21. P5: Port5 Data Register ...................................................................................210
Figure 17.22. P5MDOUT: Port5 Output Mode Register.......................................................210
Figure 17.23. P6: Port6 Data Register ...................................................................................211
Figure 17.24. P6MDOUT: Port6 Output Mode Register.......................................................211
Figure 17.25. P7: Port7 Data Register ...................................................................................212
Figure 17.26. P7MDOUT: Port7 Output Mode Register.......................................................212
18. CONTROLLER AREA NETWORK (CAN0) ..................................................................213
Figure 18.1. CAN Controller Diagram ..................................................................................214
Figure 18.2. Typical CAN Bus Configuration.......................................................................214
Figure 18.3. CAN0DATH: CAN Data Access Register High Byte ......................................220
Figure 18.4. CAN0DATL: CAN Data Access Register Low Byte .......................................220
Figure 18.5. CAN0ADR: CAN Address Index Register .......................................................221
Figure 18.6. CAN0CN: CAN Control Register .....................................................................221
Figure 18.7. CAN0TST: CAN Test Register.........................................................................222
Figure 18.8. CAN0STA: CAN Status Register .....................................................................222
19. SYSTEM MANAGEMENT BUS / I2C BUS (SMBUS0) .................................................223
Figure 19.1. SMBus0 Block Diagram ...................................................................................223
Figure 19.2. Typical SMBus Configuration ..........................................................................224
Figure 19.3. SMBus Transaction ...........................................................................................225
Figure 19.4. Typical Master Transmitter Sequence...............................................................226
Figure 19.5. Typical Master Receiver Sequence ...................................................................226
Figure 19.6. Typical Slave Transmitter Sequence .................................................................227
Figure 19.7. Typical Slave Receiver Sequence .....................................................................227
Figure 19.8. SMB0CN: SMBus0 Control Register ...............................................................229
Figure 19.9. SMB0CR: SMBus0 Clock Rate Register..........................................................230
Figure 19.10. SMB0DAT: SMBus0 Data Register ...............................................................231
Figure 19.11. SMB0ADR: SMBus0 Address Register..........................................................231
Figure 19.12. SMB0STA: SMBus0 Status Register..............................................................232
20. ENHANCED SERIAL PERIPHERAL INTERFACE (SPI0) .........................................235
Figure 20.1. SPI Block Diagram............................................................................................235
Figure 20.2. Multiple-Master Mode Connection Diagram ....................................................238
Figure 20.3. 3-Wire Single Master and 3-Wire Single Slave Mode Connection Diagram ...238
Figure 20.4. 4-Wire Single Master Mode and 4-Wire Slave Mode Connection Diagram ....238
Figure 20.5. Data/Clock Timing Diagram .............................................................................240
Figure 20.6. SPI0CFG: SPI0 Configuration Register............................................................241
Figure 20.7. SPI0CN: SPI0 Control Register ........................................................................242
Figure 20.8. SPI0CKR: SPI0 Clock Rate Register ................................................................243
Figure 20.9. SPI0DAT: SPI0 Data Register ..........................................................................244
Figure 20.10. SPI Slave Timing (CKPHA = 0) .....................................................................245
Figure 20.11. SPI Slave Timing (CKPHA = 1) .....................................................................245
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 13
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Figure 20.12. SPI Master Timing (CKPHA = 0) ...................................................................246
Figure 20.13. SPI Master Timing (CKPHA = 1) ...................................................................246
21. UART0 ..................................................................................................................................249
Figure 21.1. UART0 Block Diagram.....................................................................................249
Figure 21.2. UART0 Mode 0 Timing Diagram .....................................................................250
Figure 21.3. UART0 Mode 0 Interconnect............................................................................250
Figure 21.4. UART0 Mode 1 Timing Diagram .....................................................................251
Figure 21.5. UART0 Modes 2 and 3 Timing Diagram..........................................................252
Figure 21.6. UART0 Modes 1, 2, and 3 Interconnect Diagram ............................................253
Figure 21.7. UART Multi-Processor Mode Interconnect Diagram .......................................255
Figure 21.8. SCON0: UART0 Control Register....................................................................257
Figure 21.9. SSTA0: UART0 Status and Clock Selection Register ......................................258
Figure 21.10. SBUF0: UART0 Data Buffer Register............................................................259
Figure 21.11. SADDR0: UART0 Slave Address Register ....................................................259
Figure 21.12. SADEN0: UART0 Slave Address Enable Register ........................................259
22. UART1 ..................................................................................................................................261
Figure 22.1. UART1 Block Diagram.....................................................................................261
Figure 22.2. UART1 Baud Rate Logic ..................................................................................262
Figure 22.3. UART Interconnect Diagram ............................................................................263
Figure 22.4. 8-Bit UART Timing Diagram ...........................................................................263
Figure 22.5. 9-Bit UART Timing Diagram ...........................................................................264
Figure 22.6. UART Multi-Processor Mode Interconnect Diagram .......................................265
Figure 22.7. SCON1: Serial Port 1 Control Register.............................................................266
Figure 22.8. SBUF1: Serial (UART1) Port Data Buffer Register .........................................267
23. TIMERS................................................................................................................................271
Figure 23.1. T0 Mode 0 Block Diagram................................................................................272
Figure 23.2. T0 Mode 2 Block Diagram................................................................................273
Figure 23.3. T0 Mode 3 Block Diagram................................................................................274
Figure 23.4. TCON: Timer Control Register.........................................................................275
Figure 23.5. TMOD: Timer Mode Register...........................................................................276
Figure 23.6. CKCON: Clock Control Register......................................................................277
Figure 23.7. TL0: Timer 0 Low Byte ....................................................................................278
Figure 23.8. TL1: Timer 1 Low Byte ....................................................................................278
Figure 23.9. TH0: Timer 0 High Byte ...................................................................................278
Figure 23.10. TH1: Timer 1 High Byte .................................................................................278
Figure 23.11. T2, 3, and 4 Capture Mode Block Diagram ....................................................280
Figure 23.12. T2, 3, and 4 Auto-reload Mode Block Diagram..............................................281
Figure 23.13. TMRnCN: Timer 2, 3, and 4 Control Registers ..............................................283
Figure 23.14. TMRnCF: Timer 2, 3, and 4 Configuration Registers ....................................284
Figure 23.15. RCAPnL: Timer 2, 3, and 4 Capture Register Low Byte................................285
Figure 23.16. RCAPnH: Timer 2, 3, and 4 Capture Register High Byte ..............................285
Figure 23.17. TMRnL: Timer 2, 3, and 4 Low Byte .............................................................285
Figure 23.18. TMRnH Timer 2, 3, and 4 High Byte .............................................................286
24. PROGRAMMABLE COUNTER ARRAY .......................................................................287
Figure 24.1. PCA Block Diagram..........................................................................................287
Page 14
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Figure 24.2. PCA Counter/Timer Block Diagram .................................................................288
Figure 24.3. PCA Interrupt Block Diagram...........................................................................289
Figure 24.4. PCA Capture Mode Diagram ............................................................................290
Figure 24.5. PCA Software Timer Mode Diagram................................................................291
Figure 24.6. PCA High Speed Output Mode Diagram ..........................................................292
Figure 24.7. PCA Frequency Output Mode ...........................................................................293
Figure 24.8. PCA 8-Bit PWM Mode Diagram ......................................................................294
Figure 24.9. PCA 16-Bit PWM Mode ...................................................................................295
Figure 24.10. PCA0CN: PCA Control Register ....................................................................296
Figure 24.11. PCA0MD: PCA0 Mode Register ....................................................................297
Figure 24.12. PCA0CPMn: PCA0 Capture/Compare Mode Registers .................................298
Figure 24.13. PCA0L: PCA0 Counter/Timer Low Byte .......................................................299
Figure 24.14. PCA0H: PCA0 Counter/Timer High Byte ......................................................299
Figure 24.15. PCA0CPLn: PCA0 Capture Module Low Byte ..............................................300
Figure 24.16. PCA0CPHn: PCA0 Capture Module High Byte .............................................300
25. JTAG (IEEE 1149.1)............................................................................................................301
Figure 25.1. IR: JTAG Instruction Register ..........................................................................301
Figure 25.2. DEVICEID: JTAG Device ID Register ............................................................305
Figure 25.3. FLASHCON: JTAG Flash Control Register.....................................................307
Figure 25.4. FLASHDAT: JTAG Flash Data Register..........................................................308
Figure 25.5. FLASHADR: JTAG Flash Address Register ....................................................308
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 15
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 16
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
LIST OF TABLES
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
1. SYSTEM OVERVIEW ........................................................................................................19
Table 1.1. Product Selection Guide .......................................................................................20
2. ABSOLUTE MAXIMUM RATINGS .................................................................................34
Table 2.1. Absolute Maximum Ratings* ...............................................................................34
3. GLOBAL DC ELECTRICAL CHARACTERISTICS .....................................................35
Table 3.1. Global DC Electrical Characteristics ....................................................................35
4. PINOUT AND PACKAGE DEFINITIONS .......................................................................36
Table 4.1. Pin Definitions ......................................................................................................36
5. 16-BIT ADCS (ADC0 AND ADC1) .....................................................................................45
Table 5.1. Conversion Timing (tConv) ..................................................................................50
Table 5.2. 16-Bit ADC0 and ADC1 Electrical Characteristics .............................................68
Table 5.3. Voltage Reference 0 and 1 Electrical Characteristics ...........................................69
6. DIRECT MEMORY ACCESS INTERFACE (DMA0) ....................................................71
Table 6.1. DMA0 Instruction Set ...........................................................................................72
7. 10-BIT ADC (ADC2) ............................................................................................................83
Table 7.1. ADC2 Electrical Characteristics ...........................................................................97
8. DACS, 12-BIT VOLTAGE MODE (DAC0 AND DAC1) .................................................99
Table 8.1. DAC Electrical Characteristics ...........................................................................105
9. VOLTAGE REFERENCE 2 (C8051F060/2) ....................................................................107
Table 9.1. Voltage Reference Electrical Characteristics .....................................................108
10. VOLTAGE REFERENCE 2 (C8051F061/3) ...................................................................109
Table 10.1.Voltage Reference Electrical Characteristics .....................................................110
11. COMPARATORS ...............................................................................................................111
Table 11.1.Comparator Electrical Characteristics ................................................................116
12. CIP-51 MICROCONTROLLER .......................................................................................117
Table 12.1.CIP-51 Instruction Set Summary ........................................................................119
Table 12.2.Special Function Register (SFR) Memory Map .................................................134
Table 12.3.Special Function Registers .................................................................................135
Table 12.4.Interrupt Summary ..............................................................................................144
13. RESET SOURCES .............................................................................................................155
Table 13.1.Reset Electrical Characteristics ..........................................................................160
14. OSCILLATORS ..................................................................................................................161
Table 14.1.Internal Oscillator Electrical Characteristics ......................................................163
15. FLASH MEMORY .............................................................................................................167
Table 15.1.FLASH Electrical Characteristics .......................................................................168
16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM ......................175
Table 16.1.AC Parameters for External Memory Interface ..................................................189
17. PORT INPUT/OUTPUT ....................................................................................................191
Table 17.1.Port I/O DC Electrical Characteristics ................................................................191
18. CONTROLLER AREA NETWORK (CAN0) .................................................................213
Table 18.1.CAN Register Index and Reset Values ...............................................................217
19. SYSTEM MANAGEMENT BUS / I2C BUS (SMBUS0) ................................................223
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 17
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Table 19.1.SMB0STA Status Codes and States ...................................................................233
20. ENHANCED SERIAL PERIPHERAL INTERFACE (SPI0) ........................................235
Table 20.1.SPI Slave Timing Parameters .............................................................................247
21. UART0 .................................................................................................................................249
Table 21.1.UART0 Modes ....................................................................................................250
Table 21.2.Oscillator Frequencies for Standard Baud Rates ................................................256
22. UART1 .................................................................................................................................261
Table 22.1.Timer Settings for Standard Baud Rates Using The Internal Oscillator ............268
Table 22.2.Timer Settings for Standard Baud Rates Using an External Oscillator ..............268
Table 22.3.Timer Settings for Standard Baud Rates Using an External Oscillator ..............269
Table 22.4.Timer Settings for Standard Baud Rates Using an External Oscillator ..............269
Table 22.5.Timer Settings for Standard Baud Rates Using an External Oscillator ..............270
Table 22.6.Timer Settings for Standard Baud Rates Using an External Oscillator ..............270
23. TIMERS ...............................................................................................................................271
24. PROGRAMMABLE COUNTER ARRAY ......................................................................287
Table 24.1.PCA Timebase Input Options .............................................................................288
Table 24.2.PCA0CPM Register Settings for PCA Capture/Compare Modules ...................289
25. JTAG (IEEE 1149.1) ...........................................................................................................301
Table 25.1.Boundary Data Register Bit Definitions (C8051F060/2) ...................................302
Table 25.2.Boundary Data Register Bit Definitions (C8051F061/3) ...................................304
Page 18
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.
C8051F060/1/2/3
SYSTEM OVERVIEW
N
The C8051F06x family of devices are fully integrated mixed-signal System-on-a-Chip MCUs with 59 digital I/O pins
(C8051F060/2) or 24 digital I/O pins (C8051F061/3), and an integrated CAN 2.0B controller. Highlighted features
are listed below; refer to Table 1.1 for specific product feature selection.
IN
FO
RM
AT
IO
• High-Speed pipelined 8051-compatible CIP-51 microcontroller core (up to 25 MIPS)
• Two 16-bit 1 Msps ADCs with a Direct Memory Access controller
• Controller Area Network (CAN 2.0B) Controller with 32 message objects, each with its own indentifier mask
• In-system, full-speed, non-intrusive debug interface (on-chip)
• 10-bit 200 ksps ADC with PGA and 8-channel analog multiplexer
• Two 12-bit DACs with programmable update scheduling
• 64k bytes of in-system programmable FLASH memory
• 4352 (4096 + 256) bytes of on-chip RAM
• External Data Memory Interface with 64k byte 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 C8051F06x family of devices are truly standalone System-on-a-Chip solutions. All analog and digital peripherals are enabled/disabled and configured by user
firmware. The FLASH memory can be reprogrammed even in-circuit, providing non-volatile data storage, and also
allowing field upgrades of the 8051 firmware.
ED
On-board JTAG debug circuitry allows non-intrusive (uses no on-chip resources), full speed, in-circuit debugging
using the production MCU installed in the final application. This debug system supports 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.
AD
VA
NC
Each MCU is specified for 2.7 V to 3.6 V operation over the industrial temperature range (-45°C to +85°C). The
C8051F060/2 are available in a 100-pin TQFP package and the C8051F061/3 are available in a 64-pin TQFP package
(see block diagrams in Figure 1.1 and Figure 1.2).
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 19
Advanced
Information
C8051F060/1/2/3
Analog Comparators
C8051F061 25
64k 4352
-
! !
2
5
! 24 ±0.75 8
! !
12
2
3
C8051F062 25
64k 4352 !
! !
2
5
! 59 ±1.5
8
! !
12
2
3 100TQFP
C8051F063 25
64k 4352
! !
2
5
! 24 ±1.5
8
! !
12
2
3
AT
RM
FO
64TQFP
64TQFP
AD
VA
NC
ED
IN
-
Package
DAC Outputs
N
DAC Resolution (bits)
3 100TQFP
IO
Temperature Sensor
2
Voltage Reference
12
10-bit 200 ksps ADC Inputs
Programmable Counter Array
! !
Digital Port I/O’s
Timers (16-bit)
! 59 ±0.75 8
CAN
5
SMBus/I2C and SPI
2
External Memory Interface
! !
RAM
64k 4352 !
FLASH Memory
C8051F060 25
MIPS (Peak)
UARTS
16-bit 1 Msps ADC Typical INL (LSBs)
Table 1.1. Product Selection Guide
Page 20
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 1.1. C8051F060/2 Block Diagram
Digital Power
Boundary Scan
JTAG
Logic
Debug HW
Reset
/RST
MONEN
XTAL1
XTAL2
VDD Monitor
External Oscillator
Circuit
PCA
Timers 0,
1, 2,3,4
64kbyte
FLASH
C
o
r
e
System Clock
VREF
VREFD
DAC0
DAC1
DAC0
(12-Bit)
256 byte
RAM
4kbyte RAM
VBGAP0
CNVSTR0
AIN1
AIN1G
+
Σ
ADC1
1Msps
(16-Bit)
P2.0
P2
Drv
P2.7
P3.0
P3
Drv
P3.7
CANTX
CANRX
VREF2
Temp
Sensor
A
M
U
X
ADC2
200ksps
(10-Bit)
+
-
CP0
+
-
CP1
CP2
+
-
P2.6
P2.7
P2.2
P2.3
P2.4
P2.5
A
D
C
1
-
D
A
T
A
D
I
F
F
EMIF
Control
P4 Latch
Bus Control
Ctrl Latch
Address Bus
DMA
Interface
P5 Latch
Addr[15:8]
P6 Latch
Addr[7:0]
P7 Latch
Data Bus
Data Latch
P4
DRV
P5
DRV
P6
DRV
P7
DRV
P4.5
P4.6
P4.7
P5.0
P5.7
P6.0
P6.7
P7.0
P7.7
AD
VA
NC
ED
VBGAP1
CNVSTR1
P1.7/AIN2.7
External Data Memory Bus
A
D
C
0
D
A
T
A
AV+
AGND
VREF1
VRGND1
P1.0/AIN2.0
P1
Drv
CAN
2.0B
FO
ADC0
1Msps
(16-Bit)
IN
AIN0
C
R
O
S
S
B
A
R
P0, P1, P2,
P3 Latches
32X136
CANRAM
AVDD
AGND
AV+
AGND
VREF0
VRGND0
AIN0G
SMBus
SPI Bus
WDT
Trimmed Internal
Oscillator
VREF
SFR Bus
AT
TCK
TMS
TDI
TDO
UART1
IO
AGND
P0.7
N
8
0
5
1
Analog Power
P0.0
P0
Drv
UART0
RM
VDD
VDD
VDD
DGND
DGND
DGND
AV+
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 21
Advanced
Information
C8051F060/1/2/3
Figure 1.2. C8051F061/3 Block Diagram
Digital Power
Boundary Scan
JTAG
Logic
Debug HW
Reset
/RST
MONEN
XTAL1
XTAL2
VDD Monitor
DAC0
DAC1
SPI Bus
PCA
Timers 0,
1, 2,3,4
64kbyte
FLASH
WDT
External Oscillator
Circuit
C
o
r
e
System Clock
Trimmed Internal
Oscillator
VREF
VREF
VREF2
DAC0
(12-Bit)
256 byte
RAM
4kbyte RAM
VBGAP0
CNVSTR0
AIN1
AIN1G
+
Σ
ADC1
1Msps
(16-Bit)
P1.7/AIN2.7
P2.0
P2
Drv
P2.7
P3
Drv
CANTX
CANRX
VREF2
Temp
Sensor
A
M
U
X
ADC2
200ksps
(10-Bit)
+
-
CP0
+
-
CP1
CP2
+
-
P2.6
P2.7
P2.2
P2.3
P2.4
P2.5
A
D
C
1
-
D
A
T
A
D
I
F
F
DMA
Interface
EMIF
Control
P4 Latch
Ctrl Latch
P5 Latch
Addr[15:8]
P6 Latch
Addr[7:0]
P7 Latch
Data Latch
P4
DRV
P5
DRV
P6
DRV
P7
DRV
AD
VA
NC
ED
VBGAP1
CNVSTR1
P1.0/AIN2.0
P1
Drv
External Data Memory Bus
A
D
C
0
D
A
T
A
AV+
AGND
VREF1
VRGND1
C
R
O
S
S
B
A
R
CAN
2.0B
FO
ADC0
1Msps
(16-Bit)
IN
AIN0
P0, P1, P2,
P3 Latches
32X136
CANRAM
AVDD
AGND
AV+
AGND
VREF0
VRGND0
AIN0G
SMBus
SFR Bus
AT
TCK
TMS
TDI
TDO
UART1
IO
AGND
P0.7
N
8
0
5
1
Analog Power
P0.0
P0
Drv
UART0
RM
VDD
VDD
VDD
DGND
DGND
DGND
AV+
Page 22
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.1.
CIP-51™ Microcontroller Core
1.1.1.
Fully 8051 Compatible
C8051F060/1/2/3
Improved Throughput
AT
1.1.2.
IO
N
The C8051F06x family of devices utilizes Cygnal's proprietary CIP-51 microcontroller core. The CIP-51 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 bitaddressable I/O Ports.
RM
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.
1
2
2/3
Number of Instructions
26
50
5
3
3/4
4
4/5
5
8
14
7
3
1
2
1
FO
Clocks to Execute
ED
IN
With the CIP-51's maximum system clock at 25 MHz, it has a peak throughput of 25 MIPS. Figure 1.3 shows a comparison of peak throughputs of various 8-bit microcontroller cores with their maximum system clocks.
Figure 1.3. Comparison of Peak MCU Execution Speeds
VA
NC
25
AD
MIPS
20
15
10
5
Cygnal
Microchip
Philips
ADuC812
CIP-51
PIC17C75x
80C51
8051
(25MHz clk) (33MHz clk) (33MHz clk) (16MHz clk)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 23
Advanced
Information
C8051F060/1/2/3
1.1.3.
Additional Features
N
The C8051F06x MCU family includes several key enhancements to the CIP-51 core and peripherals to improve overall performance and ease of use in end applications.
IO
The extended interrupt handler provides 22 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.
RM
AT
There are up to seven reset sources for the MCU: an on-board VDD monitor, a Watchdog Timer, a missing clock
detector, a voltage level detection from Comparator0, a forced software reset, the CNVSTR2 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 VDD monitor and Reset Input pin may be disabled by the
user in software; the VDD monitor is enabled/disabled via the MONEN pin. The Watchdog Timer may be permanently enabled in software after a power-on reset during MCU initialization.
IN
FO
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.
Figure 1.4. On-Board Clock and Reset
CNVSTR2
Crossbar
Supply
Monitor
Comparator0
OSC
XTAL2
Missing
Clock
Detector
(oneshot)
System
Clock
Clock Select
Reset
Funnel
WDT
EN
PRE
WDT
Enable
EN
XTAL1
/RST
(wired-OR)
(CP0
reset
enable)
Internal
Clock
Generator
(wired-OR)
VDD Monitor
reset enable
+
-
AD
CP0-
Supply
Reset
Timeout
+
-
MCD
Enable
CP0+
VA
NC
(CNVSTR
reset
enable)
WDT
Strobe
(Port
I/O)
ED
VDD
Software Reset
CIP-51
Microcontroller
Core
System Reset
Extended Interrupt
Handler
Page 24
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.2.
C8051F060/1/2/3
On-Chip Memory
IO
N
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.
RM
AT
The CIP-51 in the C8051F060/1/2/3 MCUs additionally has an on-chip 4k byte RAM block. The on-chip 4k byte
block can be addressed over the entire 64k external data memory address range (overlapping 4k boundaries). The
C8051F060/2 also have an external memory interface (EMIF) for accessing off-chip data memory or memorymapped peripherals. 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 4k directed to on-chip, above 4k directed to EMIF). The EMIF is
also configurable for multiplexed or non-multiplexed address/data lines.
IN
FO
The MCU’s program memory consists of 64k bytes of FLASH. This memory may be reprogrammed in-system in
512 byte sectors, and requires no special off-chip programming voltage. The 1024 bytes from addresses 0xFC00 to
0xFFFF are reserved. There is also a single 128 byte sector at address 0x10000 to 0x1007F, which may be used by
software. See Figure 1.5 for the MCU system memory map.
Figure 1.5. On-Chip Memory Map
DATA MEMORY (RAM)
INTERNAL DATA ADDRESS SPACE
PROGRAM/DATA MEMORY
(FLASH)
0x10000
0xFFFF
0xFC00
Scrachpad Memory
(DATA only)
RESERVED
FLASH
(In-System
Programmable in 512
Byte Sectors)
AD
0x0000
0x80
0x7F
VA
NC
0xFBFF
0xFF
ED
0x1007F
0x30
0x2F
0x20
0x1F
0x00
Upper 128 RAM
(Indirect Addressing
Only)
Special Function
Registers
(Direct Addressing Only)
(Direct and Indirect
Addressing)
Bit Addressable
Lower 128 RAM
(Direct and Indirect
Addressing)
0
1
2
3
Up To
256 SFR Pages
General Purpose
Registers
EXTERNAL DATA ADDRESS SPACE
0xFFFF
Off-chip XRAM space
(C8051F060/2 Only)
0x1000
0x0FFF
0x0000
XRAM - 4096 Bytes
(accessable using MOVX
instruction)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 25
C8051F060/1/2/3
1.3.
Advanced
Information
JTAG Debug and Boundary Scan
N
The C8051F06x 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.
AT
IO
Cygnal's 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 ADCs 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.
FO
RM
The C8051F060DK development kit provides all the hardware and software necessary to develop application code
and perform in-circuit debugging with the C8051F06x MCUs. The kit includes software with a developer's studio and
debugger, an integrated 8051 assembler, and an RS-232 to JTAG serial adapter. It also has a target application board
with the associated MCU installed, plus the RS-232 and JTAG cables, and wall-mount power supply. The Development Kit requires a Windows 95/98/NT/ME computer with one available RS-232 serial port. As shown in Figure 1.6,
the PC is connected via RS-232 to the Serial Adapter. A six-inch ribbon cable connects the Serial Adapter to the
user's application board, picking up the four JTAG pins and VDD and GND. The Serial Adapter takes its power from
the application board. 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.
ED
IN
Cygnal’s 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. Cygnal's debug environment both increases ease of use and preserves the performance of the precision, on-chip analog peripherals.
Figure 1.6. Development/In-System Debug Diagram
CYGNAL Integrated
Development Environment
AD
VA
NC
WINDOWS 95/98/NT
RS-232
Serial
Adapter
JTAG (x4), VDD, GND
VDD
TARGET PCB
GND
C8051
F060
Page 26
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.4.
C8051F060/1/2/3
Programmable Digital I/O and Crossbar
N
Three standard 8051 Ports (0, 1, and 2) are available on the MCUs. The C8051F060/2 have 4 additional 8-bit ports (3,
5, 6, and 7), and a 3-bit port (port 4) for a total of 59 general-purpose I/O Pins. The Ports behave like the standard
8051 with a few enhancements.
IO
Each port pin can be configured as either a push-pull or open-drain output. Also, the "weak pull-ups" which are normally fixed on an 8051 can be globally disabled, providing additional power saving capabilities for low-power applications.
RM
AT
Perhaps the most unique enhancement is the Digital Crossbar. This is a large digital switching network that allows
mapping of internal digital system resources to Port I/O pins on P0, P1, P2, and P3. (See Figure 1.7) Unlike microcontrollers with standard multiplexed digital I/O ports, all combinations of functions are supported with all package
options offered.
FO
The on-chip counter/timers, serial buses, HW interrupts, ADC2 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.
Figure 1.7. Digital Crossbar Diagram
4
2
SMBus
2
UART1
6
PCA
2
Comptr.
Outputs
VA
NC
(Internal Digital Signals)
IN
UART0
SPI
T0, T1,
T2, T2EX,
T3, T3EX,
T4,T4EX,
/INT0,
/INT1
P0MDOUT, P1MDOUT,
P2MDOUT, P3MDOUT
Registers
External
Pins
Priority
Decoder
8
Digital
Crossbar
8
P0
I/O
Cells
P0.0
P1
I/O
Cells
P1.0
P2
I/O
Cells
P2.0
P3
I/O
Cells
P3.0
Highest
Priority
P0.7
P1.7
8
8
/SYSCLK
P2.7
CNVSTR2
AD
Lowest
Priority
XBR0, XBR1, XBR2,
XBR3 P1MDIN,
P2MDIN, P3MDIN
Registers
2
ED
Highest
Priority
P0
P1
Port
Latches
8
P3.7
Lowest
Priority
(P0.0-P0.7)
8
(P1.0-P1.7)
8
P2
8
To
ADC2
Input
C8051F060/2
Only
To
Comparators
(P2.0-P2.7)
8
P3
(P3.0-P3.7)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 27
Advanced
Information
C8051F060/1/2/3
1.5.
Programmable Counter Array
IO
N
The C8051F06x 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 6 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.
AT
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
PCA
CLOCK
MUX
16-Bit Counter/Timer
FO
SYSCLK
IN
External Clock/8
Capture/Compare
Module 1
Capture/Compare
Module 2
Capture/Compare
Module 4
Capture/Compare
Module 5
CEX5
CEX4
Crossbar
Port I/O
AD
VA
NC
Capture/Compare
Module 3
CEX3
CEX2
CEX1
CEX0
ECI
ED
Capture/Compare
Module 0
RM
Figure 1.8. PCA Block Diagram
Page 28
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.6.
C8051F060/1/2/3
Controller Area Network
IO
N
The C8051F06x 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.
RM
AT
The CAN controller can operate at bit rates up to 1 Mbit/second. Cygnal 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.
Figure 1.9. CAN Controller Overview
CANRX
C8051F060/1/2/3
FO
CANTX
C
8
0
5
1
CAN Controller
RX
IN
TX
ED
CAN
Core
Message RAM
REGISTERS
Message Handler
Interrupt
M
C
U
AD
VA
NC
(32 Message Objects)
S
F
R
's
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 29
C8051F060/1/2/3
1.7.
Advanced
Information
Serial Ports
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
The C8051F06x 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.
Page 30
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.8.
C8051F060/1/2/3
16-Bit Analog to Digital Converters
IO
N
The C8051F060/1/2/3 devices have two on-chip 16-bit SAR ADCs (ADC0 and ADC1), which can be used independently in single-ended mode, or together in differential mode. ADC0 and ADC1 can directly access on-chip or external RAM, using the DMA interface. With a maximum throughput of 1 Msps, the ADCs offer 16 bit performance with
two available linearity grades. ADC0 and ADC1 each have the capability to use dedicated, on-chip voltage reference
circuitry or an external voltage reference source.
AT
The ADCs are under full control of the CIP-51 microcontroller via the associated Special Function Registers. The
system controller can also put the ADCs into shutdown mode to save power.
RM
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. The two ADCs can operate independently, or be synchronized to perform
conversions at the same time. Conversion completions are indicated by status bits, and can generate interrupts. The
resulting 16-bit data words are latched into SFRs upon completion of a conversion. A DMA interface is also provided, which can gather conversions from the ADCs, and directly store them to on-chip or external RAM.
FO
ADC0 also contains Window Compare registers, which can be configured to interrupt the controller when ADC0 data
is within or outside of a specified range. ADC0 can monitor a key voltage continuously in background mode, and not
interrupt the controller unless the converted data is within the specified window.
REF
IN
Figure 1.10. 16-Bit ADC Block Diagram
VA
NC
AIN0G
16-Bit
SAR
ADC0
ED
AIN0
Start Conversion
16
Write to AD0BUSY
Timer 3 Overflow
CNVSTR0
Timer 2 Overflow
ADC0
Window
Compare
Logic
(DC, -0.2 to 0.6 V)
AIN1
AIN1G
(DC, -0.2 to 0.6 V)
16-Bit
SAR
ADC1
REF
AD
Configuration and Control
Registers
ADC Data
Registers
DMA
Interface
16
Start Conversion
Write to AD1BUSY
Timer 3 Overflow
CNVSTR1
Timer 2 Overflow
Write to AD0BUSY
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 31
C8051F060/1/2/3
1.9.
Advanced
Information
10-Bit Analog to Digital Converter
IO
N
The C8051F060/1/2/3 devices have an on-board 10-bit SAR ADC (ADC2) with a 9-channel input multiplexer and
programmable gain amplifier. This ADC features a 200 ksps maximum throughput and true 10-bit performance with
an INL of ±1LSB. Eight input pins are available for measurement and can be programmed as single-ended or differential inputs. Additionally, the on-chip temperature sensor can be used as an input to the ADC. 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 the external VREF2 pin. User software may put ADC2 into shutdown
mode to save power.
AT
A flexible conversion scheduling system allows ADC2 conversions to be initiated by software commands, timer
overflows, or an external input signal. Conversion completions are indicated by a status bit and an interrupt (if
enabled), and the resulting 10-bit data word is latched into two SFR locations upon completion.
RM
ADC2 also contains Window Compare registers, which can be configured to interrupt the controller when ADC2 data
is within or outside of a specified range. ADC2 can monitor a key voltage continuously in background mode, and not
interrupt the controller unless the converted data is within the specified window.
FO
Figure 1.11. 10-Bit ADC Diagram
Analog Multiplexer
Configuration and Control Registers
IN
AIN2.0
AIN2.1
AIN2.2
9-to-1
AMUX
AIN2.4
AIN2.5
AIN2.7
VA
NC
AIN2.6
10-Bit
SAR
ED
AIN2.3
10
10
ADC
TEMP
SENSOR
AGND
ADC Data
Registers
Conversion
Complete
Interrupt
Write to AD2BUSY
VREF2 Pin
VREF
Start Conversion
Timer 3 Overflow
CNVSTR2 Input
AV+
Timer 2 Overflow
AD
Single-ended or
Differential Measurement
ADC2
Window
Compare
Logic
Page 32
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
1.10.
C8051F060/1/2/3
Comparators and DACs
N
Each C8051F060/1/2/3 MCU has two 12-bit DACs and 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.
AT
IO
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.
FO
RM
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 C8051F060/2 devices or via the VREF2 pin on C8051F061/3
devices, which is shared with ADC2. The DACs are especially useful as references for the comparators or offsets for
the differential inputs of the ADCs.
Figure 1.12. Comparator and DAC Diagram
IN
CPn Output
CROSSBAR
ED
(Port I/O)
Comparator inputs
Port 2.[7:2]
VA
NC
3 Comparators
CPn+
+
CPn-
-
CPn
AD
DAC0
DAC1
SFR's
(Data
and
Cntrl)
CIP-51
and
Interrupt
Handler
VREF
DAC0
VREF
DAC1
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 33
Advanced
Information
C8051F060/1/2/3
2.
ABSOLUTE MAXIMUM RATINGS
Table 2.1. Absolute Maximum Ratings*
CONDITIONS
MIN
TYP
MAX
UNITS
125
°C
N
PARAMETER
-55
Storage Temperature
-65
150
°C
Voltage on any pin (except VDD, AV+, AVDD, and
Port 0) with respect to DGND
-0.3
VDD +
0.3
V
-0.3
5.8
V
-0.3
4.2
V
800
mA
100
mA
50
mA
100
mA
50
mA
AT
IO
Ambient temperature under bias
Voltage on any Port 0 Pin with respect to DGND.
Maximum Total current through VDD, AV+, AVDD,
DGND, and AGND
Maximum output current sunk by any Port pin
Maximum output current sunk by any other I/O pin
Maximum output current sourced by any Port pin
FO
Maximum output current sourced by any other I/O pin
RM
Voltage on VDD, AV+, or AVDD with respect to DGND
*
AD
VA
NC
ED
IN
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.
Page 34
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
3.
C8051F060/1/2/3
GLOBAL DC ELECTRICAL CHARACTERISTICS
Table 3.1. Global DC Electrical Characteristics
MIN
(Note 1)
2.7
Analog Supply Current
Internal REF, ADC, DAC, Comparators all active
Analog Supply Current with analog sub-systems inactive
Internal REF, ADC, DAC, Comparators all disabled, oscillator
disabled
RM
Analog Supply Voltage (AV+,
AVDD)
Analog-to-Digital Supply Delta
(|VDD - AV+| or |VDD - AVDD|)
MAX
UNITS
3.0
3.6
V
TBD
TBD
mA
TBD
TBD
mA
0.5
V
2.7
3.6
V
3.0
18
0.7
TBD
mA
mA
µA
IN
FO
Digital Supply Voltage (VDD)
VDD=2.7 V, Clock=25 MHz
VDD=2.7 V, Clock=1 MHz
VDD=2.7 V, Clock=32 kHz
5
0.2
10
mA
mA
µA
Oscillator not running
0.2
µA
1.5
V
VDD=2.7 V, Clock=25 MHz
VDD=2.7 V, Clock=1 MHz
VDD=2.7 V, Clock=32 kHz
Digital Supply Current with CPU
inactive (not accessing FLASH)
Digital Supply Current (shutdown)
VA
NC
ED
Digital Supply Current with CPU
active
Digital Supply RAM Data Retention Voltage
TYP
IO
CONDITIONS
AT
PARAMETER
N
-40°C to +85°C, 25 MHz System Clock unless otherwise specified.
Specified Operating Temperature
Range
-40
+85
°C
AD
Note 1: Analog Supply AV+ must be greater than 1 V for VDD monitor to operate.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 35
Advanced
Information
C8051F060/1/2/3
4.
PINOUT AND PACKAGE DEFINITIONS
Table 4.1. Pin Definitions
F060
F061
F062
F063
Type
Description
IO
Name
N
Pin Numbers
37, 64, 26, 40,
90
55
Digital Supply Voltage. Must be tied to +2.7 to +3.6 V.
DGND
38, 63, 27, 39,
89
54
Digital Ground. Must be tied to Ground.
AV+
11, 16,
24
7, 10,
18
Analog Supply Voltage. Must be tied to +2.7 to +3.6 V.
AVDD
13
23
Analog Supply Voltage. Must be tied to +2.7 to +3.6 V.
AGND
10, 14,
17, 23
6, 11,
19, 22
TMS
96
52
D In
JTAG Test Mode Select with internal pull-up.
TCK
97
53
D In
JTAG Test Clock with internal pull-up.
TDI
98
56
D In
JTAG Test Data Input with internal pull-up. TDI is latched on the
rising edge of TCK.
TDO
99
57
/RST
100
58
RM
IN
FO
Analog Ground. Must be tied to Ground.
ED
D Out JTAG Test Data Output with internal pull-up. Data is shifted out on
TDO on the falling edge of TCK. TDO output is a tri-state driver.
D I/O Device Reset. Open-drain output of internal VDD monitor. Is driven
low when VDD is <2.7 V and MONEN is high. An external source
can initiate a system reset by driving this pin low.
VA
NC
XTAL1
AT
VDD
26
20
27
21
MONEN
28
63
VREF
4
61
A Out Bandgap Voltage Reference Output for ADC2, DAC0, and DAC1.
VREF0
21
15
A I/O Bandgap Voltage Reference Output for ADC0.
ADC0 Voltage Reference Input.
VRGND0
20
14
A In
AD
XTAL2
Page 36
A In
Crystal Input. This pin is the return for the internal oscillator circuit
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.
A Out Crystal Output. This pin is the excitation driver for a crystal or
ceramic resonator.
D In
VDD Monitor Enable. When tied high, this pin enables the internal
VDD monitor, which forces a system reset when VDD is < 2.7 V.
When tied low, the internal VDD monitor is disabled.
ADC0 Voltage Reference Ground.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 4.1. Pin Definitions
Pin Numbers
F060
F061
F062
F063
VBGAP0
22
16
A Out ADC0 Bandgap Bypass Pin.
VREF1
6
2
A I/O Bandgap Voltage Reference Output for ADC1.
ADC1 Voltage Reference Input.
VRGND1
7
3
A In
VBGAP1
5
1
VREF2
2
AT
IO
N
Description
ADC1 Voltage Reference Ground.
A Out ADC1 Bandgap Bypass Pin.
A In
ADC2 Voltage Reference Input.
A In
ADC2, DAC0, and DAC1 Voltage Reference Input.
A In
DAC0 and DAC1 Voltage Reference Input.
3
AIN0
18
12
A In
ADC0 Signal Input (See ADC0 Specification for complete description).
AIN0G
19
13
A In
ADC0 DC Bias Input (See ADC0 Specification for complete
description).
AIN1
9
5
A In
ADC1 Signal Input (See ADC1 Specification for complete description).
AIN1G
8
4
A In
ADC1 DC Bias Input (See ADC1 Specification for complete
description).
CNVSTR0
15
9
CNVSTR1
12
8
IN
D In
External Conversion Start Source for ADC0
D In
External Conversion Start Source for ADC1
VA
NC
CANTX
FO
VREFD
ED
62
Type
RM
Name
94
59
95
60
25
17
A Out Digital to Analog Converter 0 Voltage Output. (See DAC Specification for complete description).
1
64
A Out Digital to Analog Converter 1 Voltage Output. (See DAC Specification for complete description).
P0.0
62
51
D I/O Port 0.0. See Port Input/Output section for complete description.
P0.1
61
50
D I/O Port 0.1. See Port Input/Output section for complete description.
P0.2
60
49
D I/O Port 0.2. See Port Input/Output section for complete description.
P0.3
59
48
D I/O Port 0.3. See Port Input/Output section for complete description.
P0.4
58
47
D I/O Port 0.4. See Port Input/Output section for complete description.
P0.5
57
46
D I/O Port 0.5. See Port Input/Output section for complete description.
CANRX
DAC0
AD
DAC1
D Out Controller Area Network Transmit Output.
D In
Controller Area Network Receive Input.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 37
Advanced
Information
C8051F060/1/2/3
Table 4.1. Pin Definitions
Pin Numbers
F060
F061
F062
F063
P0.6
56
45
D I/O Port 0.6. See Port Input/Output section for complete description.
P0.7
55
44
D I/O Port 0.7. See Port Input/Output section for complete description.
P1.0/AIN2.0
36
33
A In ADC2 Input Channel 0 (See ADC2 Specification for complete
D I/O description).
Port 1.0. See Port Input/Output section for complete description.
P1.1/AIN2.1
35
32
A In ADC2 Input Channel 1 (See ADC2 Specification for complete
D I/O description).
Port 1.1. See Port Input/Output section for complete description.
P1.2/AIN2.2
34
31
A In ADC2 Input Channel 2 (See ADC2 Specification for complete
D I/O description).
Port 1.2. See Port Input/Output section for complete description.
P1.3/AIN2.3
33
30
A In ADC2 Input Channel 3 (See ADC2 Specification for complete
D I/O description).
Port 1.3. See Port Input/Output section for complete description.
P1.4/AIN2.4
32
29
A In ADC2 Input Channel 4 (See ADC2 Specification for complete
D I/O description).
Port 1.4. See Port Input/Output section for complete description.
P1.5/AIN2.5
31
28
P1.6/AIN2.6
30
25
29
24
A In ADC2 Input Channel 7 (See ADC2 Specification for complete
D I/O description).
Port 1.7. See Port Input/Output section for complete description.
46
43
D I/O Port 2.0. See Port Input/Output section for complete description.
45
42
D I/O Port 2.1. See Port Input/Output section for complete description.
P2.2
44
41
D I/O Port 2.2. See Port Input/Output section for complete description.
P2.3
43
38
D I/O Port 2.3. See Port Input/Output section for complete description.
P2.4
42
37
D I/O Port 2.4. See Port Input/Output section for complete description.
P2.5
41
36
D I/O Port 2.5. See Port Input/Output section for complete description.
P2.6
40
35
D I/O Port 2.6. See Port Input/Output section for complete description.
P2.7
39
34
D I/O Port 2.7. See Port Input/Output section for complete description.
P1.7/AIN2.7
P2.0
AD
P2.1
Page 38
Description
ED
IN
FO
RM
AT
IO
N
Type
A In ADC2 Input Channel 5 (See ADC2 Specification for complete
D I/O description).
Port 1.5. See Port Input/Output section for complete description.
A In ADC2 Input Channel 6 (See ADC2 Specification for complete
D I/O description).
Port 1.6. See Port Input/Output section for complete description.
VA
NC
Name
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 4.1. Pin Definitions
Pin Numbers
F061
F062
F063
Type
Description
N
F060
IO
Name
54
D I/O Port 3.0. See Port Input/Output section for complete description.
P3.1
53
D I/O Port 3.1. See Port Input/Output section for complete description.
P3.2
52
D I/O Port 3.2. See Port Input/Output section for complete description.
P3.3
51
D I/O Port 3.3. See Port Input/Output section for complete description.
P3.4
50
D I/O Port 3.4. See Port Input/Output section for complete description.
P3.5
49
D I/O Port 3.5. See Port Input/Output section for complete description.
P3.6
48
D I/O Port 3.6. See Port Input/Output section for complete description.
P3.7
47
D I/O Port 3.7. See Port Input/Output section for complete description.
P4.5/ALE
93
D I/O Port 4.5. See Port Input/Output section for complete description.
ALE Strobe for External Memory Address Bus (Multiplexed mode).
P4.6/RD
92
D I/O Port 4.6. See Port Input/Output section for complete description.
/RD Strobe for External Memory Address Bus.
P4.7/WR
91
D I/O Port 4.7. See Port Input/Output section for complete description.
/WR Strobe for External Memory Address Bus.
P5.0/A8
88
D I/O Port 5.0. See Port Input/Output section for complete description.
Bit 8 External Memory Address Bus (Non-multiplexed mode).
P5.1/A9
87
P5.2/A10
86
RM
FO
IN
ED
D I/O Port 5.1. See Port Input/Output section for complete description.
D I/O Port 5.2. See Port Input/Output section for complete description.
VA
NC
P5.3/A11
AT
P3.0
85
D I/O Port 5.3. See Port Input/Output section for complete description.
84
D I/O Port 5.4. See Port Input/Output section for complete description.
83
D I/O Port 5.5. See Port Input/Output section for complete description.
82
D I/O Port 5.6. See Port Input/Output section for complete description.
81
D I/O Port 5.7. See Port Input/Output section for complete description.
P6.0/A8m/A0
80
D I/O Port 6.0. See Port Input/Output section for complete description.
Bit 8 External Memory Address Bus (Multiplexed mode).
Bit 0 External Memory Address Bus (Non-multiplexed mode).
P6.1/A9m/A1
79
D I/O Port 6.1. See Port Input/Output section for complete description.
P6.2/A10m/A2
78
D I/O Port 6.2. See Port Input/Output section for complete description.
P6.3/A11m/A3
77
D I/O Port 6.3. See Port Input/Output section for complete description.
P6.4/A12m/A4
76
D I/O Port 6.4. See Port Input/Output section for complete description.
P5.4/A12
P5.5/A13
P5.6/A14
AD
P5.7/A15
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 39
Advanced
Information
C8051F060/1/2/3
Table 4.1. Pin Definitions
Pin Numbers
F061
F062
F063
Type
Description
N
F060
IO
Name
75
D I/O Port 6.5. See Port Input/Output section for complete description.
P6.6/A14m/A6
74
D I/O Port 6.6. See Port Input/Output section for complete description.
P6.7/A15m/A7
73
D I/O Port 6.7. See Port Input/Output section for complete description.
P7.0/AD0m/D0
72
D I/O Port 7.0. See Port Input/Output section for complete description.
Bit 0 External Memory Address/Data Bus (Multiplexed mode).
Bit 0 External Memory Data Bus (Non-multiplexed mode).
P7.1/AD1m/D1
71
D I/O Port 7.1. See Port Input/Output section for complete description.
P7.2/AD2m/D2
70
D I/O Port 7.2. See Port Input/Output section for complete description.
P7.3/AD3m/D3
69
D I/O Port 7.3. See Port Input/Output section for complete description.
P7.4/AD4m/D4
68
D I/O Port 7.4. See Port Input/Output section for complete description.
P7.5/AD5m/D5
67
D I/O Port 7.5. See Port Input/Output section for complete description.
P7.6/AD6m/D6
66
D I/O Port 7.6. See Port Input/Output section for complete description.
P7.7/AD7m/D7
65
D I/O Port 7.7. See Port Input/Output section for complete description.
AD
VA
NC
ED
IN
FO
RM
AT
P6.5/A13m/A5
Page 40
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
TMS
CANRX
CANTX
P4.5/ALE
P4.6/RD
P4.7/WR
VDD
DGND
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
N
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
P6.4/A12m/A4
TDI
TCK
FO
RM
AT
IO
TDO
98
97
38
39
40
41
42
43
44
45
46
47
48
49
50
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P3.7
P3.6
P3.5
P3.4
25
P2.7
DAC0
DGND
23
24
IN
AGND
AV+
36
37
21
22
P1.0/AIN2.0
VDD
20
VREF0
VBGAP0
35
VRGND0
34
18
19
P1.1/AIN2.1
AIN0
AIN0G
P1.2/AIN2.2
16
17
ED
AV+
AGND
32
33
14
15
P1.4/AIN2.4
P1.3/AIN2.3
AGND
CNVSTR0
C8051F060/F062
31
12
13
30
CNVSTR1
AVDD
P1.5/AIN2.5
9
10
11
75
74
P6.5/A13m/A5
P6.6/A14m/A6
73
72
P6.7/A15m/A7
P7.0/AD0m/D0
71
70
P7.1/AD1m/D1
P7.2/AD2m/D2
69
68
P7.3/AD3m/D3
P7.4/AD4m/D4
67
P7.5/AD5m/D5
66
65
P7.6/AD6m/D6
P7.7/AD7m/D7
64
63
VDD
DGND
62
61
P0.0
P0.1
60
59
P0.2
P0.3
58
57
P0.4
P0.5
56
P0.6
55
54
P0.7
P3.0
53
52
P3.1
P3.2
51
P3.3
AD
AIN1
AGND
AV+
P1.6/AIN2.6
7
8
28
29
VRGND1
AIN1G
MONEN
P1.7/AIN2.7
5
6
27
VBGAP1
VREF1
26
3
4
XTAL2
VREFD
VREF
XTAL1
1
2
VA
NC
DAC1
VREF2
99
100 /RST
Figure 4.1. TQFP-100 Pinout Diagram
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 41
Advanced
Information
C8051F060/1/2/3
Figure 4.2. TQFP-100 Package Drawing
D
MIN NOM MAX
(mm) (mm) (mm)
N
D1
-
IO
A
RM
AT
A1 0.05
E
1.20
-
0.15
A2 0.95 1.00 1.05
b
0.17 0.22 0.27
D
-
16.00
-
D1
-
14.00
-
e
-
0.50
-
E
-
16.00
-
E1
-
14.00
-
IN
FO
E1
-
100
1
e
VA
NC
A2
ED
PIN 1
DESIGNATOR
A1
AD
b
A
Page 42
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
VREF1
2
VRGND1
3
AIN1G
4
AIN1
5
AGND
6
AV+
7
CNVSTR1
8
CNVSTR0
9
AV+
10
AGND
11
AIN0
12
AIN0G
13
VRGND0
14
VREF0
15
VBGAP0
16
VREF2
VREF
CANRX
CANTX
/RST
TDO
TDI
VDD
DGND
TCK
TMS
P0.0
P0.1
62
61
60
59
58
57
56
55
54
53
52
51
50
49
RM
FO
ED
IN
C8051F061/063
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
AV+
AGND
XTAL1
XTAL2
AGND
AVDD
P1.7/AIN2.7
P1.6/AIN2.6
VDD
DGND
P1.5/AIN2.5
P1.4/AIN2.4
P1.3/AIN2.3
P1.2/AIN2.2
P1.1/AIN2.1
48
P0.3
47
P0.4
46
P0.5
45
P0.6
44
P0.7
43
P2.0
42
P2.1
41
P2.2
40
VDD
39
DGND
38
P2.3
37
P2.4
36
P2.5
35
P2.6
34
P2.7
33
P1.0/AIN2.0
AD
DAC0
VA
NC
N
MONEN
63
P0.2
DAC1
IO
1
AT
VBGAP1
64
Figure 4.3. TQFP-64 Pinout Diagram
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 43
Advanced
Information
C8051F060/1/2/3
Figure 4.4. TQFP-64 Package Drawing
D
N
D1
IO
MIN NOM MAX
(mm) (mm) (mm)
E1
RM
E
FO
64
PIN 1
DESIGNATOR
IN
1
e
ED
A2
-
1.20
A1 0.05
-
0.15
A2 0.95
-
1.05
b
0.17 0.22 0.27
D
-
12.00
-
D1
-
10.00
-
e
-
0.50
-
E
-
12.00
-
E1
-
10.00
-
A1
AD
VA
NC
b
A
-
AT
A
Page 44
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
5.
C8051F060/1/2/3
16-BIT ADCS (ADC0 AND ADC1)
AT
IO
N
The ADC subsystem for the C8051F060/1/2/3 consists of two 1 Msps, 16-bit successive-approximation-register
ADCs with integrated track-and-hold, a Programmable Window Detector, and a DMA interface (see block diagrams
in Figure 5.1 and Figure 5.2). The ADCs can be configured as two separate, single-ended ADCs, or as a differential
pair. The Data Conversion Modes, Window Detector, and DMA interface are all configurable under software control
via the Special Function Registers shown in Figure 5.1 and Figure 5.2. The voltage references used by ADC0 and
ADC1 are selected as described in Section 5.2. The ADCs and their respective track-and-hold circuitry can be independently enabled or disabled with the Special Function Registers. Either ADC can be enabled by setting the ADnEN
bit in the ADC’s Control register (ADCnCN) to logic 1. The ADCs are in low power shutdown when these bits are
logic 0.
Figure 5.1. 16-Bit ADC0 and ADC1 Control Path Diagram
REF
AV+
16-Bit
SAR
ADC0
FO
AIN0
AIN0G
AIN1G
REF
VA
NC
ADC0CF
AIN1
10
11
AD1EN
ADC1 Data Bus
16
000
Start Conversion 010
100
110
xx1
AD1BUSY (W)
Timer 3 Overflow
CNVSTR1
Timer 2 Overflow
AD0BUSY (W)
AD1EN
AD1TM
AD1INT
AD1BUSY
AD1CM2
AD1CM1
AD1CM0
÷
ADC1CF
AD0BUSY (W)
Timer 3 Overflow
CNVSTR0
Timer 2 Overflow
AV+
16-Bit
SAR
ADC1
AD1SC3
AD1SC2
AD1SC1
AD1SC0
AD1SCAL
AD1GCAL
AD1LCAL
AD1OCAL
AD
00
Start Conversion 01
ADC0CN
(DC, -0.2 to 0.6 V)
SYSCLK
16
AD0EN
AD0TM
AD0INT
AD0BUSY
AD0CM1
AD0CM0
AD0WINT
ED
AD0SC3
AD0SC2
AD0SC1
AD0SC0
AD0SCAL
AD0GCAL
AD0LCAL
AD0OCAL
÷
ADC0 Data Bus
IN
(DC, -0.2 to 0.6 V)
SYSCLK
RM
AD0EN
ADC1CN
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 45
Advanced
Information
C8051F060/1/2/3
Figure 5.2. 16-bit ADC0 and ADC1 Data Path Diagram
16
8
Σ
8
ADC1H
ADC1L
16
IN
DMA
Interface
ADC0GTH
N
Single-Ended
1
Differential
8
ADC0GTL
8
ADC0H
ADC0L
16
Window
Compare
AD0WINT
32
ADC0LTH
ADC0LTL
Single-Ended or Differential Operation
ED
5.1.
0
IO
+
-
AT
AIN1G
16
RM
16-Bit
SAR
ADC1
AIN1
DIFFSEL
AIN0G
AMX0SL
FO
16-Bit
SAR
ADC0
AIN0
5.1.1.
VA
NC
ADC0 and ADC1 can be programmed to operate independently as single-ended ADCs, or together to accept a differential input. In single-ended mode, the ADCs can be configured to sample simultaneously, or to use different conversion speeds. In differential mode, ADC1 is a slave to ADC0, and its configuration is based on ADC0 settings, except
during offset or gain calibrations. The DIFFSEL bit in the Channel Select Register AMX0SL (Figure 5.6) selects
between single-ended and differential mode.
Pseudo-Differential Inputs
AD
The inputs to the ADCs are pseudo-differential. The actual voltage measured by each ADC is equal to the voltage
between the AINn pin and the AINnG pin. AINnG must be a DC signal between -0.2 and 0.6 V. In most systems,
AINnG will be connected to AGND. If not tied to AGND, the AINnG signal can be used to negate a limited amount
of fixed offset, but it is recommended that the internal offset calibration features of the device be used for this purpose. When operating in differential mode, AIN0G and AIN1G should be tied together. AINn must remain above
AINnG in both modes for accurate conversion results.
Page 46
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
5.2.
C8051F060/1/2/3
Voltage Reference
N
The voltage reference circuitries for ADC0 and ADC1 allow for many different voltage reference configurations.
Each ADC has the capability to use its own dedicated, on-chip voltage reference, or an off-chip reference circuit. A
block diagram of the reference circuitry for one ADC is shown in Figure 5.3.
AT
IO
The internal voltage reference circuit for each ADC consists of an independent, temperature stable 1.25 V bandgap
voltage reference generator, with an output buffer amplifier which multiplies the bandgap reference by 2. The maximum load seen by the VREFn (VREF0 or VREF1) pin must be less than 100 µA to AGND. Bypass capacitors of
0.1 µF and 47 µF are recommended from the VREFn pin to VRGNDn.
FO
RM
The voltage reference circuitry for each ADC is controlled in the Reference Control Registers. REF0CN (defined in
Figure 5.11) is the Reference Control Register for ADC0, and REF1CN (defined in Figure 5.12) is the Reference
Control Register for ADC1. The REFnCN registers are used to enable/disable the internal reference and bias generator circuitry for each ADC independently. The BIASEn bits enable the on-board bias generators for each ADC, while
the REFBEn bits enable the 2x buffer amplifiers which drive the VREFn pins. When disabled, the supply current
drawn by the bandgap and buffer amplifier falls to less than 1 µA (typical) and the output of the buffer amplifier
enters a high impedance state (approximately 25 k Ohms). If the internal voltage reference for an ADC is used, the
BIASEn and REFBEn bits for that ADC must both be set to logic 1. If an external reference is used, the REFBEn bit
should be set to logic 0. Note that the BIASEn bit for an ADC must be set to logic 1 to enable that ADC, regardless of
the voltage reference that is used. If an ADC is not being used, the BIASEn bit can be set to logic 0 to conserve
power. The electrical specifications for the Voltage References are given in Table 5.3.
IN
Figure 5.3. Voltage Reference Block Diagram
ADCn
External
Voltage
Reference
47µF
Bias
x2
VA
NC
VREFn
ED
Ref
0.1µF
VRGNDn
1.25V
Band-Gap
EN
0.1µF
REFnCN
AD
Recommended
Bypass Capacitors
BIASEn
REFBEn
VBGAPn
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 47
C8051F060/1/2/3
5.3.
Advanced
Information
ADC Modes of Operation
Starting a Conversion
IO
5.3.1.
N
ADC0 and ADC1 have a maximum conversion speed of 1 Msps. The conversion clocks for the ADCs are derived
from the system clock. The ADCnSC bits in the ADCnCF register determine how many system clocks (from 1 to 16)
are used for each conversion clock.
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).
RM
1.
2.
3.
4.
AT
For ADC0, conversions 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. For ADC0, conversions may be initiated by:
ADC1 conversions can be initiated in five different ways, according to the ADC1 Start of Conversion Mode bits
(AD1CM2-AD1CM0) in ADC1CN. For ADC1, conversions may be initiated by:
FO
Writing a ‘1’ to the AD1BUSY bit of ADC1CN;
A Timer 3 overflow (i.e. timed continuous conversions);
A rising edge detected on the external ADC convert start signal, CNVSTR1;
A Timer 2 overflow (i.e. timed continuous conversions);
Writing a ‘1’ to the AD0BUSY bit of ADC0CN.
IN
1.
2.
3.
4.
5.
ED
The ADnBUSY bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete. The falling edge of ADnBUSY triggers an interrupt (when enabled) and sets the ADnINT interrupt flag (ADCnCN.5). In single-ended mode, the converted data for ADCn is available in the ADCn data word MSB and LSB registers, ADCnH,
ADCnL. In differential mode, the converted data (combined from ADC0 and ADC1) is available in the ADC0 data
word MSB and LSB registers, ADC0H, ADC0L.
Step 1.
Step 2.
Step 3.
Step 4.
VA
NC
When initiating conversions by writing a ‘1’ to ADnBUSY, the ADnINT bit should be polled to determine when a
conversion has completed (ADCn interrupts may also be used). The recommended polling procedure is shown below.
Write a ‘0’ to ADnINT;
Write a ‘1’ to ADnBUSY;
Poll ADnINT for ‘1’;
Process ADCn data.
AD
When an external start-of-conversion source is required in differential mode the two pins (CNVSTR0 and
CNVSTR1) should be tied together.
Page 48
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
5.3.2.
C8051F060/1/2/3
Tracking Modes
AT
IO
N
The ADnTM bit in register ADCnCN controls the ADCn track-and-hold mode. When the ADC is enabled, the ADC
input is continuously tracked when a conversion is not in progress. When the ADnTM bit is logic 1, each conversion
is preceded by a tracking period of 18 SAR clocks (after the start-of-conversion signal). When the CNVSTRn signal
is used to initiate conversions, the ADC will track until a rising edge occurs on the CNVSTRn pin (see Figure 5.4 and
Table 5.1 for conversion timing parameters). Setting ADnTM to 1 can be useful to ensure that settling time requirements are met when an external multiplexer is used on the analog input (see Section “5.3.3. Settling Time Requirements” on page 51).
Figure 5.4. ADC Track and Conversion Example Timing
RM
A. ADC Timing for External Trigger Source
CNVSTRn
FO
tConv
Convert
Track
IN
Track
B. ADC Timing for Internal Trigger Sources
Track
VA
NC
ADCnTM=1
ED
Timer 2, Timer 3 Overflow;
Write '1' to ADnBUSY
Track
Track
Convert
Track
tConv
Convert
Track
AD
ADCnTM=0
tConv
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 49
Advanced
Information
C8051F060/1/2/3
Table 5.1. Conversion Timing (tConv)
ADCnTM = 0
ADCnTM = 1
ADnSC3-0
ADCnTM = 0
ADCnTM = 1
0000
21*SYSCLK
38*SYSCLK
1000
171*SYSCLK
315*SYSCLK
0001
40*SYSCLK
72*SYSCLK
1001
189*SYSCLK
349*SYSCLK
0010
58*SYSCLK
106*SYSCLK
1010
208*SYSCLK
384*SYSCLK
0011
78*SYSCLK
142*SYSCLK
1011
0100
97*SYSCLK
177*SYSCLK
1100
0101
115*SYSCLK
211*SYSCLK
1101
0110
134*SYSCLK
246*SYSCLK
0111
152*SYSCLK
280*SYSCLK
AT
IO
N
ADnSC3-0
418*SYSCLK
245*SYSCLK
453*SYSCLK
263*SYSCLK
487*SYSCLK
1110
282*SYSCLK
522*SYSCLK
1111
300*SYSCLK
556*SYSCLK
AD
VA
NC
ED
IN
FO
RM
226*SYSCLK
Page 50
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
5.3.3.
C8051F060/1/2/3
Settling Time Requirements
AT
IO
N
If the input to the ADC is changed rapidly (such as an external multiplexer change or any other form of step input), a
minimum tracking time is required before an accurate conversion can be performed. This tracking time is determined
by the ADC input resistance, the ADC sampling capacitance, any external source resistance, and the accuracy
required for the conversion. Figure 5.5 shows the equivalent ADC input circuits for both Differential and Singleended 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.1. An absolute minimum settling time of
280 ns is required after any step change on the input.
Equation 5.1. ADC0 Settling Time Requirements
n
RM
2
t = ln  ------- × R TOTAL C SAMPLE
 SA
IN
FO
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the ADC input resistance and any external source resistance.
n is the ADC resolution in bits (16).
ED
Figure 5.5. ADC0 and ADC1 Equivalent Input Circuits
AIN0
VA
NC
Differential Mode
RAIN = 30 Ω
Single-Ended Mode
AIN0
or
AIN1
RAIN = 30 Ω
CSAMPLE = 80pF
RCInput= RAIN * CSAMPLE
CSAMPLE = 80pF
RCInput= RAIN * CSAMPLE
AD
CSAMPLE = 80pF
AIN1
RAIN = 30 Ω
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 51
Advanced
Information
C8051F060/1/2/3
SFR Page:
SFR Address:
0
0xBB
N
Figure 5.6. AMX0SL: AMUX Configuration Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
-
DIFFSEL
-
-
-
-
-
-
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
For single-ended mode, the ADC0 Data Word is stored in ADC0H and ADC0L, while the ADC1
Data Word is stored in ADC1H and ADC1L.
In differential mode, the combined ADC Data Word is stored in ADC0H and ADC0L, and is a 2’s
complement number. ADC1’s Data Word (single-ended) is also stored in ADC1H and ADC1L.
AD
VA
NC
ED
IN
FO
NOTE:
AT
Bit 5-0:
RESERVED. Write to 0b.
DIFFSEL: Fully Differential Conversion Mode Select Bit.
0: Operate In Single-Ended Mode.
1: Operate In Differential Mode.
RESERVED. Write to 000000b.
RM
Bit 7:
Bit 6:
IO
R/W
Page 52
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
0
0xBC
R/W
R/W
R/W
AD0SC3
AD0SC2
AD0SC1
Bit7
Bit6
Bit5
Bit 3:
R/W
R/W
R/W
Reset Value
Bit4
Bit3
Bit2
Bit1
Bit0
AT
AD0SC3-0: ADC0 SAR Conversion Clock Period Bits.
SAR Conversion clock is divided down from the system clock according to the AD0SC bits
(AD0SC3-0). The number of system clocks used for each SAR conversion clock is equal to
AD0SC + 1. (Note: the ADC0 SAR Conversion Clock should be less than or equal to 25 MHz).
See Table 5.1 for conversion timing details.
AD0SCAL: System Calibration Enable.
0: Internal ground and reference voltage are used during offset and gain calibration.
1: External voltages can be used during offset and gain calibration.
AD0GCAL: Gain Calibration.
Read:
0: Gain Calibration is completed or not yet started.
1: Gain Calibration is in progress.
Write:
0: No Effect.
1: Initiates a gain calibration if ADC0 is idle.
AD0LCAL: Linearity Calibration
Read
0: Linearity Calibration is completed or not yet started
1: Linearity Calibration is in progress
Write
0: No Effect
1: Initiates a linearity calibration if ADC0 is idle
AD0OCAL: Offset Calibration.
Read:
0: Offset Calibration is completed or not yet started.
1: Offset Calibration is in progress.
Write:
0: No Effect.
1: Initiates an offset calibration if ADC0 is idle.
ED
AD
Bit 0:
VA
NC
Bit 1:
IN
FO
Bit 2:
R/W
AD0SC0 AD0SCAL AD0GCAL AD0LCAL AD0OCAL 11110000
RM
Bits 7-4:
R/W
IO
SFR Page:
SFR Address:
N
Figure 5.7. ADC0CF: ADC0 Configuration Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 53
C8051F060/1/2/3
Advanced
Information
1
0xBC
R/W
R/W
R/W
AD1SC3
AD1SC2
AD1SC1
Bit7
Bit6
Bit5
Bit 3:
R/W
R/W
R/W
Reset Value
Bit4
Bit3
Bit2
Bit1
Bit0
AT
AD1SC3-0: ADC1 SAR Conversion Clock Period Bits.
SAR Conversion clock is divided down from the system clock according to the AD1SC bits
(AD1SC3-0). The number of system clocks used for each SAR conversion clock is equal to
AD1SC + 1. (Note: the ADC1 SAR Conversion Clock should be less than or equal to 25 MHz).
See Table 5.1 for conversion timing details.
AD1SCAL: System Calibration Enable.
0: Internal ground and reference voltage are used for offset and gain calibration.
1: External voltages can be used for offset and gain calibration.
AD1GCAL: Gain Calibration.
Read:
0: Gain Calibration is completed or not yet started.
1: Gain Calibration is in progress.
Write:
0: No Effect.
1: Initiates a gain calibration if ADC1 is idle.
AD1LCAL: Linearity Calibration
Read
0: Linearity Calibration is completed or not yet started
1: Linearity Calibration is in progress
Write
0: No Effect
1: Initiates a linearity calibration if ADC1 is idle
AD1OCAL: Offset Calibration.
Read:
0: Offset Calibration is completed or not yet started.
1: Offset Calibration is in progress.
Write:
0: No Effect.
1: Initiates an offset calibration if ADC1 is idle.
ED
AD
Bit 0:
VA
NC
Bit 1:
IN
FO
Bit 2:
R/W
AD1SC0 AD1SCAL AD1GCAL AD1LCAL AD1OCAL 11110000
RM
Bits 7-4:
R/W
IO
SFR Page:
SFR Address:
N
Figure 5.8. ADC1CF: ADC1 Configuration Register
Page 54
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Bit 6:
Bit 5:
R/W
Bit6
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
AD0CM0
AD0WINT
-
00000000
Bit2
Bit1
Bit0
AD0EN: ADC0 Enable Bit.
0: ADC0 Disabled. ADC0 is in low-power shutdown.
1: ADC0 Enabled. ADC0 is active and ready for data conversions or calibrations.
AD0TM: ADC Track Mode Bit.
0: When the ADC is enabled, tracking is continuous unless a conversion is in process.
1: Tracking Defined by AD0CM1-0 bits.
AD0INT: ADC0 Conversion Complete Interrupt Flag.
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.
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 AD0CM1-0 = 00b.
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 16 SAR clocks, followed by conversion.
01: Tracking started by the overflow of Timer 3 and lasts for 16 SAR clocks, followed by conversion.
10: ADC0 conversion starts on rising CNVSTR0 edge.
11: Tracking started by the overflow of Timer 2 and lasts for 16 SAR clocks, followed by conversion.
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.
RESERVED: Write to 0b.
AD
Bit 1:
VA
NC
Bits 3-2:
ED
IN
Bit 4:
R/W
AT
Bit 7:
R/W
AD0TM AD0INT AD0BUSY AD0CM1
RM
Bit7
R/W
(bit addressable)
FO
R/W
AD0EN
0
0xE8
IO
SFR Page:
SFR Address:
N
Figure 5.9. ADC0CN: ADC0 Control Register
Bit 0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 55
Advanced
Information
C8051F060/1/2/3
Bit 6:
Bit 5:
R/W
Bit6
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
AD1CM1
AD1CM0
-
00000000
Bit2
Bit1
Bit0
AD1EN: ADC1 Enable Bit.
0: ADC1 Disabled. ADC1 is in low-power shutdown.
1: ADC1 Enabled. ADC1 is active and ready for data conversions or calibrations.
AD1TM: ADC Track Mode Bit.
0: When the ADC is enabled, tracking is continuous unless a conversion is in process.
1: Tracking Defined by AD1CM2-0 bits.
AD1INT: ADC1 Conversion Complete Interrupt Flag.
This flag must be cleared by software.
0: ADC1 has not completed a data conversion since the last time this flag was cleared.
1: ADC1 has completed a data conversion.
AD1BUSY: ADC1 Busy Bit.
Read:
0: ADC1 Conversion is complete or a conversion is not currently in progress. AD1INT is set to
logic 1 on the falling edge of AD1BUSY.
1: ADC1 Conversion is in progress.
Write:
0: No Effect.
1: Initiates ADC1 Conversion if AD1CM2-0 = 000b.
AD1CM2-0: ADC1 Start of Conversion Mode Select.
If AD1TM = 0:
000: ADC1 conversion initiated on every write of ‘1’ to AD1BUSY.
010: ADC1 conversion initiated on overflow of Timer 3.
100: ADC1 conversion initiated on rising edge of external CNVSTR1.
110: ADC1 conversion initiated on overflow of Timer 2.
xx1: ADC1 conversion initiated on every write of ‘1’ to AD0BUSY in ADC0CN
If AD1TM = 1:
000: Tracking starts with the write of ‘1’ to AD1BUSY and lasts for 16 SAR clocks, followed by conversion.
010: Tracking started by the overflow of Timer 3 and lasts for 16 SAR clocks, followed by conversion.
100: ADC1 conversion starts on rising CNVSTR1 edge.
110: Tracking started by the overflow of Timer 2 and lasts for 16 SAR clocks, followed by conversion.
xx1: Tracking starts with the write of ‘1’ to AD0BUSY and lasts for 16 SAR clocks, followed by conversion.
RESERVED: Write to 0b.
AD
VA
NC
Bits 3-1:
ED
IN
Bit 4:
R/W
AT
Bit 7:
R/W
AD1TM AD1INT AD1BUSY AD1CM2
RM
Bit7
R/W
(bit addressable)
FO
R/W
AD1EN
1
0xE8
IO
SFR Page:
SFR Address:
N
Figure 5.10. ADC1CN: ADC1 Control Register
Bit 0:
Page 56
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 5.11. REF0CN: Reference Control Register 0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
REFBE0
00000000
-
-
-
-
-
-
BIASE0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
RM
Bit0:
RESERVED. Read = 000000b; Write = 000000b.
BIASE0: ADC0 Bias Generator Enable Bit. (Must be ‘1’ if using ADC0).
0: ADC0 Internal Bias Generator Off.
1: ADC0 Internal Bias Generator On.
REFBE0: Internal Reference Buffer for ADC0 Enable Bit.
0: Internal Reference Buffer for ADC0 Off. External voltage reference can be used.
1: Internal Reference Buffer for ADC0 On. Internal voltage reference is driven on the VREF0 pin.
AT
Bits7-2:
Bit1:
IO
SFR Address: 0xD1
SFR Page: 0
R/W
R/W
R/W
R/W
-
-
-
Bit6
Bit5
Bit4
R/W
R/W
Reset Value
-
BIASE1
REFBE1
00000000
Bit2
Bit1
Bit0
SFR Address: 0xD1
SFR Page: 1
RESERVED. Read = 000000b; Write = 000000b.
BIASE1: ADC1 Bias Generator Enable Bit. (Must be ‘1’ if using ADC1).
0: ADC1 Internal Bias Generator Off.
1: ADC1 Internal Bias Generator On.
REFBE1: Internal Reference Buffer for ADC1 Enable Bit.
0: Internal Reference Buffer for ADC1 Off. External voltage reference can be used.
1: Internal Reference Buffer for ADC1 On. Internal voltage reference is driven on the VREF1 pin.
AD
VA
NC
Bit0:
-
Bit3
R/W
ED
Bits7-2:
Bit1:
R/W
IN
Bit7
FO
Figure 5.12. REF1CN: Reference Control Register 1
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 57
C8051F060/1/2/3
Advanced
Information
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
ADC0 Data Word High-Order Bits.
R/W
Bit1
Reset Value
00000000
Bit0
AT
Bits 7-0:
0
0xBF
IO
SFR Page:
SFR Address:
N
Figure 5.13. ADC0H: ADC0 Data Word MSB Register
R/W
Bit7
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
ADC0 Data Word Low-Order Bits.
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
AD
VA
NC
ED
IN
Bits 7-0:
0
0xBE
FO
SFR Page:
SFR Address:
RM
Figure 5.14. ADC0L: ADC0 Data Word LSB Register
Page 58
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 5.15. ADC0 Data Word Example
N
16-bit ADC0 Data Word appears in the ADC0 Data Word Registers as follows:
AT
IO
Example: ADC0 Data Word Conversion Map, AIN0 Input in Single-Ended Mode
(AMX0SL = 0x00)
AIN0-AIN0G (Volts)
ADC0H:ADC0L
VREF * (65535/65536)
0xFFFF
VREF / 2
0x8000
VREF * (32767/65536)
0x7FFF
0
0x0000
IN
FO
RM
Example: ADC0 Data Word Conversion Map, AIN0-AIN1 Differential Input Pair
(AMX0SL = 0x40)
AIN0-AIN1 (Volts)
ADC0H:ADC0L
VREF * (32767/32768)
0x7FFF
VREF / 2
0x4000
VREF * (1/32768)
0x0001
0
0x0000
-VREF * (1/32768)
0xFFFF
-VREF / 2
0xC000
-VREF
0x8000
; ‘n’ = 16 for Single-Ended; ‘n’=15 for Differential.
AD
VA
NC
ED
Gain
Code = Vin × --------------- × 2 n
VREF
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 59
C8051F060/1/2/3
Advanced
Information
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
ADC1 Data Word High-Order Bits.
R/W
Bit1
Reset Value
00000000
Bit0
AT
Bits 7-0:
1
0xBF
IO
SFR Page:
SFR Address:
N
Figure 5.16. ADC1H: ADC1 Data Word MSB Register
R/W
Bit7
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
ADC1 Data Word Low-Order Bits.
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
IN
Bits 7-0:
1
0xBE
FO
SFR Page:
SFR Address:
RM
Figure 5.17. ADC1L: ADC1 Data Word LSB Register
Figure 5.18. ADC1 Data Word Example
ED
16-bit ADC1 Data Word appears in the ADC1 Data Word Registers as follows:
VA
NC
Example: ADC1 Data Word Conversion Map, AIN1 Input in Single-Ended Mode
(AMX1SL = 0x00)
AIN1-AIN1G (Volts)
ADC1H:ADC1L
VREF * (65535/65536)
0xFFFF
VREF / 2
0x8000
VREF * (32767/65536)
0x7FFF
0
0x0000
; ‘n’ = 16
AD
Gain
Code = Vin × --------------- × 2 n
VREF
For differential mode, the differential data word appears in ADC0H and ADC0L. The single-ended
ADC1 results are always present in ADC1H and ADC1L, regardless of the operating mode.
Page 60
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
5.4.
C8051F060/1/2/3
Calibration
IO
N
The ADCs are calibrated for linearity, offset, and gain in production. ADC0 and ADC1 can also be independently calibrated for each of these parameters in-system. Calibrations are initiated using bits in the ADC0 or ADC1 Configuration Register. The calibration coefficients can be accessed using the ADC Calibration Pointer Register (ADC0CPT,
Figure 5.22) and the ADC Calibration Coefficient Register (ADC0CCF, Figure 5.23). The CPTR bits in ADC0CPT
allow the ADC0CCF register to read and write specific calibration coefficients. Figure 5.19 shows the Calibration
Coefficient locations.
ADC0CCF
Bit6
Bit5
Bit4
Bit3
RM
Bit7
Bit2
Bit1
Bit0
Linearity Calibration Coefficients (locations 0x00 through 0x12)
Offset6
Gain7
Gain6
Offset5
Offset13
Gain5
Offset4
Offset12
Gain4
Gain12
Offset3
Offset11
Gain3
Gain11
FO
Offset7
Offset2
Offset10
Gain2
Gain10
Offset1
Offset9
Gain1
Gain9
Offset0
Offset8
Gain0
Gain8
IN
ADC0CPT
Bits 5-0
0x00
.
.
0x12
0x13
0x14
0x15
0x16
AT
Figure 5.19. Calibration Coefficient Locations
VA
NC
ED
The ADCs are calibrated for linearity in production. Under normal circumstances, no additional linearity calibration
is necessary. If linearity calibrations are desired, they can be initiated by setting the ADCnLCAL bit to ‘1’. When the
calibration is finished, the ADCnLCAL bit will be set to ‘0’ by the hardware. Linearity Calibration Coefficients are
stored in the “trim” locations shown in Equation 5.19.
AD
Offset and gain calibrations can be performed using either internal or external voltages as calibration sources. The
ADCnSCAL bit determines whether the internal or external voltages are used in the calibration process. To ensure
accuracy, offset calibration should be done prior to a gain calibration. The offset and gain calibration coefficients are
decoded in Figure 5.20. Offset calibration is initiated by setting the ADCnOCAL bit to ‘1’. When the calibration is
finished, the ADCnOCAL bit will be set to ‘0’ by the hardware. Offset calibration can compensate for offset errors of
approximately ±3.125% of full scale. The offset value is added to the AINnG input prior to digitization by the ADC.
Gain calibration is initiated by setting the ADCnGCAL bit to ‘1’. When the calibration is finished, the ADCnGCAL
bit will be set to ‘0’ by the hardware. Gain calibration can compensate for slope errors of approximately ±3.125%.
The gain value is added to the ADC’s VREF path to change the slope of the converter’s transfer function. Figure 5.21
shows how the offset and gain values affect the analog signals used by the ADC.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 61
Advanced
Information
C8051F060/1/2/3
Figure 5.20. Offset and Gain Register Mapping
Approximate Offset Change (V)
-3.125% * VREF
0
+3.125% * VREF
AT
IO
Offset Register (14 Bits)
0x3FFF
0x2000
0x0000
N
The offset register value affects the offset at the analog input as follows:
RM
0x2000 – Offset Register
Offset Change ≅ ------------------------------------------------------------ × 3.125% × VREF
8192
The gain register value affects the slope of the ADC transfer function as follows:
Approximate Slope Change
+3.125%
0
-3.125%
IN
FO
Gain Register (13 Bits)
0x1FFF
0x1000
0x0000
Gain Register – 0x1000
Slope Change ≅ --------------------------------------------------------- × 3.125%
4096
VA
NC
ED
Figure 5.21. Offset and Gain Calibration Block Diagram
VREF
+
Gain
Offset
AINn
+
16
ADCn
ADCn Data
AD
AINnG
Page 62
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
SFR Page:
SFR Address:
F
0xBA
R/W
R/W
R/W
R/W
R/W
R/W
ADCSEL
CPTR5
CPTR4
CPTR3
CPTR2
CPTR1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bits 5-0:
Bit0
AT
INCR: Pointer Address Automatic Increment.
0: Disable Auto-Increment.
1: Enable Auto-Increment. CPTR5-0 will automatically be incremented after each read or write to
ADC0CCF.
ADCSEL: ADC Calibration Coefficient Select.
0: Reads and Writes of ADC0CCF will access ADC0 Calibration Coefficients.
1: Reads and Writes of ADC0CCF will access ADC1 Calibration Coefficients.
CPTR5-0: Calibration Coefficent Pointer.
Select which Calibration Coefficient location will be accessed when ADC0CCF is read or written.
RM
Bit 6:
Reset Value
00000000
FO
Bit 7:
R/W
CPTR0
IO
R/W
INCR
N
Figure 5.22. ADC0CPT: ADC Calibration Pointer Register
SFR Page:
SFR Address:
Bit7
Bit6
R/W
R/W
Bit4
Bit2
R/W
Bit5
R/W
Bit3
R/W
R/W
Reset Value
00000000
Bit1
Bit0
Calibration Coefficients at the location specified in ADC0CPT. See Table 5.19.
AD
VA
NC
Bits 7-0:
R/W
ED
R/W
F
0xBB
IN
Figure 5.23. ADC0CCF: ADC Calibration Coefficient Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 63
C8051F060/1/2/3
5.5.
Advanced
Information
ADC0 Programmable Window Detector
RM
AT
IO
N
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). The Window Detector can be used in single-ended or differential mode. In signle-ended mode, the
Window Detector compares the ADC0GTx and ADC0LTx registers to the output of ADC0. In differential mode, the
combined output of ADC0 and ADC1 (contained in the ADC0 data registers) is used for the comparison. Reference
comparisons are shown starting on page 66. 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.
Figure 5.24. ADC0GTH: ADC0 Greater-Than Data High Byte Register
R/W
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
R/W
R/W
R/W
Reset Value
11111111
Bit2
Bit1
Bit0
IN
Bit7
Bits 7-0:
0
0xC5
FO
SFR Page:
SFR Address:
High byte of ADC0 Greater-Than Data Word.
R/W
Bit7
R/W
R/W
Bit6
Bit5
R/W
R/W
R/W
R/W
R/W
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
11111111
Low byte of ADC0 Greater-Than Data Word.
AD
Bits 7-0:
0
0xC4
VA
NC
SFR Page:
SFR Address:
ED
Figure 5.25. ADC0GTL: ADC0 Greater-Than Data Low Byte Register
Page 64
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
R/W
Reset Value
00000000
Bit0
AT
High byte of ADC0 Less-Than Data Word.
Bit1
RM
Bits 7-0:
0
0xC7
IO
SFR Page:
SFR Address:
N
Figure 5.26. ADC0LTH: ADC0 Less-Than Data High Byte Register
Figure 5.27. ADC0LTL: ADC0 Less-Than Data Low Byte Register
Bit7
Bit6
R/W
R/W
Bit5
Bit4
R/W
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
Low byte of ADC0 Less-Than Data Word.
AD
VA
NC
ED
Bits 7-0:
R/W
IN
R/W
0
0xC6
FO
SFR Page:
SFR Address:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 65
Advanced
Information
C8051F060/1/2/3
Figure 5.28. 16-Bit ADC0 Window Interrupt Example: Single-Ended Data
ADC0 Data
Word
Input Voltage
(AIN0 - AIN0G)
ADC0 Data
Word
REF x (65535/65536)
0xFFFF
REF x (65535/65536)
0xFFFF
IO
AD0WINT
not affected
0x2000
0x1FFF
REF x (8192/65536)
ADC0LTH:ADC0LTL
AD0WINT=1
0x1001
0x1000
REF x (4096/65536)
ADC0GTH:ADC0GTL
RM
REF x (4096/65536)
0x0FFF
0x0000
0
0x2000
0x1FFF
0x1001
0x1000
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
0x0FFF
AD0WINT=1
0x0000
Given:
AMX0SL = 0x00,
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 > 0x2000 or
< 0x1000.
AD
VA
NC
ED
IN
Given:
AMX0SL = 0x00,
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.
FO
AD0WINT
not affected
0
AD0WINT=1
0x2001
AT
0x2001
REF x (8192/65536)
N
Input Voltage
(AIN0 - AIN0G)
Page 66
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 5.29. 16-Bit ADC0 Window Interrupt Example: Differential Data
ADC0 Data
Word
Input Voltage
(AIN0 - AIN1)
ADC0 Data
Word
REF x (32767/32768)
0x7FFF
REF x (32767/32768)
0x7FFF
IO
AD0WINT
not affected
0x1000
ADC0LTH:ADC0LTL
REF x (4096/32768)
0x0FFF
AD0WINT=1
0x0000
ADC0GTH:ADC0GTL
REF x (-1/32768)
RM
0xFFFF
0xFFFE
0x8000
-REF
0xFFFF
ADC0GTH:ADC0GTL
AD0WINT
not affected
ADC0LTH:ADC0LTL
0xFFFE
AD0WINT=1
0x8000
Given:
AMX0SL = 0x40,
ADC0LTH:ADC0LTL = 0xFFFF,
ADC0GTH:ADC0GTL = 0x1000.
An ADC0 End of Conversion will cause an ADC0
Window Compare Interrupt (AD0WINT = ‘1’) if
the resulting ADC0 Data Word is < 0xFFFF or
> 0x1000. (In two’s-complement math,
0xFFFF = -1.)
AD
VA
NC
ED
IN
Given:
AMX0SL = 0x40,
ADC0LTH:ADC0LTL = 0x1000,
ADC0GTH:ADC0GTL = 0xFFFF.
An ADC0 End of Conversion will cause an ADC0
Window Compare Interrupt (AD0WINT = ‘1’) if
the resulting ADC0 Data Word is < 0x1000 and
> 0xFFFF. (In two’s-complement math,
0xFFFF = -1.)
FO
AD0WINT
not affected
-REF
0x1000
0x0FFF
0x0000
REF x (-1/32768)
AD0WINT=1
0x1001
AT
0x1001
REF x (4096/32768)
N
Input Voltage
(AIN0 - AIN1)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 67
C8051F060/1/2/3
Advanced
Information
Table 5.2. 16-Bit ADC0 and ADC1 Electrical Characteristics
PARAMETER
CONDITIONS
MIN
MAX
IO
DC ACCURACY
TYP
N
VDD = 3.0V, AV+ = 3.0V, AVDD = 3.0V, VREF = 2.50V (REFBE=0), -40°C to +85°C unless otherwise specified
16
Single-Ended
Differential
Integral Nonlinearity
(C8051F062/3)
Single-Ended
Differential
Differential Nonlinearity
Guaranteed Monotonic
Offset Error
Full Scale Error
Gain Temperature Coefficient
FO
DYNAMIC PERFORMANCE
RM
Integral Nonlinearity
(C8051F060/1)
bits
±0.75
±0.5
±2
±1
LSB
±1.5
±1
±4
±2
LSB
AT
Resolution
UNITS
±0.5
LSB
0.1
mV
0.008
%F.S.
TBD
ppm/°C
Fin = 10 kHz, Single-Ended
Fin = 100 kHz, Single-Ended
Fin = 10 kHz, Differential
Fin = 100 kHz, Differential
86
TBD
89
TBD
dB
dB
dB
dB
Total Harmonic Distortion
Fin = 10 kHz, Single-Ended
Fin = 100 kHz, Single-Ended
Fin = 10 kHz, Differential
Fin = 100 kHz, Differential
96
TBD
103
TBD
dB
dB
dB
dB
Fin = 10 kHz, Single-Ended
Fin = 100 kHz, Single-Ended
Fin = 10 kHz, Differential
Fin = 100 kHz, Differential
97
TBD
104
TBD
dB
dB
dB
dB
86
dB
100
dB
CMRR
ED
VA
NC
Spurious-Free Dynamic Range
IN
Signal-to-Noise Plus Distortion
Fin = 10 kHz
Channel Isolation
TIMING
SAR Clock Frequency
25
MHz
Conversion Time in SAR Clocks
18
clocks
Track/Hold Acquisition Time
280
ns
AD
Throughput Rate
1
Msps
Aperture Delay
External CNVST Signal
1.5
ns
RMS Aperture Jitter
External CNVST Signal
5
ps
ANALOG INPUTS
Input Voltage Range
Input Capacitance
Page 68
Single-Ended (AINn - AINnG)
Differential (AIN0 - AIN1)
0
-VREF
VREF
VREF
80
V
V
pF
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 5.2. 16-Bit ADC0 and ADC1 Electrical Characteristics
VDD = 3.0V, AV+ = 3.0V, AVDD = 3.0V, VREF = 2.50V (REFBE=0), -40°C to +85°C unless otherwise specified
MIN
AIN0 or AIN1
AIN0G or AIN1G (DC Only)
-0.2
-0.2
POWER SPECIFICATIONS
MAX
UNITS
AV+
0.6
V
V
4.0
1.5
1
mA
mA
µA
±0.5
LSB
AT
Power Supply Current (each ADC) Operating Mode, 1 Msps
AV+
AVDD
Shutdown Mode
VDD ± 5%
RM
Power Supply Rejection
TYP
IO
Operating Input Range
CONDITIONS
N
PARAMETER
Table 5.3. Voltage Reference 0 and 1 Electrical Characteristics
PARAMETER
CONDITIONS
INTERNAL REFERENCE
25°C ambient
VREF Temperature Coefficient
Power Supply Current (each Volt- AV+
age Reference)
Input Voltage Range
ADC throughput = 1 Msps
TYP
MAX
UNITS
2.45
V
15
ppm/°C
1.5
mA
2.0
(AV+ + 0.3)
450
V
µA
AD
VA
NC
Input Current
ED
EXTERNAL REFERENCE
MIN
IN
Output Voltage
FO
VDD = 3.0 V, AV+ = 3.0 V, AVDD = 3.0V, -40°C to +85°C unless otherwise specified
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 69
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 70
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
6.
C8051F060/1/2/3
DIRECT MEMORY ACCESS INTERFACE (DMA0)
AT
IO
N
The DMA interface works in conjunction with ADC0 and ADC1 to write ADC outputs directly to a specified region
of XRAM. The DMA interface is configured by software using the Special Function Registers shown in Figure 6.1.
Up to 64 instructions can be programmed into the Instruction Buffer to designate a sequence of DMA operations. The
Instruction Buffer is accessed by the DMA Control Logic, which gathers the appropriate data from the ADCs and
controls writes to XRAM. The DMA instructions tell the DMA Control Logic which ADC(s) to expect results from,
but do not initiate the actual conversions. It is important to configure the ADCs for the desired start-of-conversion
source, voltage reference, and SAR clock frequency prior to starting the DMA interface. For information on setting
up the ADCs, refer to Section “5. 16-Bit ADCs (ADC0 and ADC1)” on page 45.
Figure 6.1. DMA0 Block Diagram
Write Logic
DMA0ISW
Start Address
FO
Current Address
Instruction
Buffer
(64 Bytes)
IN
CCNV
DIFFSEL
ADC1EN
ADC0EN
AIN1
ADC1
VA
NC
AIN1G
DMA0CTH
6.1.
XRAM
(on-chip or
off-chip)
Data Bus
DMA0DSH
DMA0DSL
Current XRAM Address
ED
ADC0
AIN0G
Address Bus
DMA
Control Logic
DMA0BND
AIN0
DMA0EN
DMA0INT
DMA0MD
DMA0DE1
DMA0DE0
DMA0DOE
DMA0DO1
DMA0DO0
DMA0IDT
RM
DMA0IPT
DMA0CN
DMA0CIE
DMA0CI
DMA0EOE
DMA0EO
Instruction Data
DMA0HLT
DMA0XBY
DMA0CF
Address
DMA0DAH
DMA0DAL
Beginning XRAM Address
DMA0CTL
Repeat Counter Limit
DMA0CSH
DMA0CSL
Current Repeat Counter Value
Writing to the Instruction Buffer
AD
The Instruction Buffer has 64 8-bit locations that can be programmed with a sequence of DMA instructions. Filling
the Instruction Buffer is done with the Special Function Registers DMA0IPT (DMA Instruction Write Address Register, Figure 6.6) and DMA0IDT (DMA Instruction Write Data Register, Figure 6.7). Instructions are written to the
Instruction Buffer at address DMA0IPT when the instruction word is written to DMA0IDT. Reading the register
DMA0IDT will return the instruction word at location DMA0IPT. After a write or read operation on DMA0IDT, the
DMA0IPT register is automatically incremented to the next Instruction Buffer location.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 71
Advanced
Information
C8051F060/1/2/3
6.2.
DMA0 Instruction Format
AT
Table 6.1. DMA0 Instruction Set
Instruction
Description
Word
10000000b End-Of-Operation with Continuous Conversion
x0010000b Retrieve ADC0 Data
FO
x0100000b Retrieve ADC1 Data
Retrieve ADC0 and ADC1 Data
Retrieve Differential and ADC1 Data
Second Data Written
to XRAM (2 bytes)
none
none
none
none
ADC0H:ADC0L
none
ADC1H:ADC1L
none
ADC0H:ADC0L
ADC1H:ADC1L
ADC0H:ADC0L
(differential result
from both ADCs)
none
ADC0H:ADC0L
(differential result
from both ADCs)
ADC1H:ADC1L
ED
x11x0000b
IN
x10x0000b Retrieve Differential Data
First Data Written
to XRAM (2 bytes)
RM
00000000b End-Of-Operation
x0110000b
IO
N
DMA instructions can request single-ended data from both ADC0 and ADC1, as well as the differential combination
of the two ADC inputs. The instruction format is identical to the DMA0IDT register, shown in Figure 6.7. Depending
on which bits are set to ‘1’ in the instruction word, either 2 or 4 bytes of data will be written to XRAM for each DMA
instruction cycle (excluding End-Of-Operation instructions). Table 6.1 details all of the valid DMA instructions.
Instructions not listed in the table are not valid DMA instructions, and should not be used. Note that the ADCs can be
independently controlled by the microcontroller when their outputs are not requested by the DMA.
6.3.
XRAM Addressing and Setup
VA
NC
The DMA Interface can be configured to access either on-chip or off-chip XRAM. Any writes to on-chip XRAM by
the DMA Control Logic occur when the processor core is not accessing the on-chip XRAM. This ensures that the
DMA will not interfere with processor instruction timing.
AD
Off-chip XRAM access (only available on the C8051F060/2) is controlled by the DMA0HLT bit in DMA0CF (DMA
Configuration Register, Figure 6.5). The DMA will have full access to off-chip XRAM when this bit is ‘0’, and the
processor core will have full access to off-chip XRAM when this bit is ‘1’. The DMA0HLT bit should be controlled
in software when both the processor core and the DMA Interface require access to off-chip XRAM data space. Before
setting DMA0HLT to ‘1’, the software should check the DMA0XBY bit to ensure that the DMA is not currently
accessing off-chip XRAM. The processor core cannot access off-chip XRAM while DMA0HLT is ‘0’. The processor
will continue as though it was able to perform the desired memory access, but the data will not be written to or read
from off-chip XRAM. When the processor core is finished accessing off-chip XRAM, DMA0HLT should be set back
to ‘0’in software to return control to the DMA Interface. The DMA Control Logic will wait until DMA0HLT is ‘0’
before writing data to off-chip XRAM. If new data becomes available to the DMA Interface before the previous data
has been written, an overflow condition will occur, and the new data word may be lost.
The Data Address Pointer Registers (DMA0DSH and DMA0DSL) contain the 16-bit XRAM address location where
the DMA interface will write data. When the DMA is initially enabled, the DMA Data Address Pointer Registers are
initialized to the values contained in the DMA Data Address Beginning Registers (DMA0DAH and DMA0DAL).
The Data Address Pointer Registers are automatically incremented by 2 or 4 after each data write by the DMA interface.
Page 72
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
6.4.
C8051F060/1/2/3
Instruction Execution in Mode 0
AT
IO
N
When the DMA interface begins an operation cycle, the DMA Instruction Status Register (DMA0ISW, Figure 6.9) is
loaded with the address contained in the DMA Instruction Boundary Register (DMA0BND, Figure 6.8). The instruction is fetched from the Instruction Buffer, and the DMA Control Logic waits for data from the appropriate ADC(s).
The DMA will execute each instruction once, and then increment DMA0ISW to the next instruction address. When
the current DMA instruction is an End of Operation instruction, the Instruction Status Register is reset to the Instruction Boundary Register. If the Continuous Conversion bit (bit 7, CCNV) in the End of Operation instruction word is
set to ‘1’, the Repeat Counter is ignored, and the DMA will continue to execute instructions indefinitely. When
CCNV is set to ‘0’, the Repeat Counter (registers DMA0CSH and DMA0CSL) is decremented, and the DMA will
continue to execute instructions until the Repeat Counter reaches 0x0000. The Repeat Counter is initialized with the
Repeat Counter Limit value (registers DMA0CTH and DMA0CTL) at the beginning of the DMA operation. An
example of Mode 0 operation is shown in Figure 6.2.
RM
Figure 6.2. DMA Mode 0 Operation
XRAM
FO
ADC1L
ADC1H
ADC0L
IN
INSTRUCTION
BUFFER
(64 Bytes)
0x3F
...
ED
00000000
00110000
01000000
00010000
DMA0CSH:L = DMA0CTH:L - 1
DMA0CSH:L = DMA0CTH:L
AD
VA
NC
DMA0BND
0x03
0x02
0x01
0x00
ADC0H (Diff.)
ADC0L
ADC0H
ADC1L
ADC1H
ADC0L
ADC0H
ADC0L (Diff.)
ADC0H (Diff.)
ADC0L
ADC0H
DMA0CSH:L = 0x0000
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 73
C8051F060/1/2/3
6.5.
Advanced
Information
Instruction Execution in Mode 1
AT
IO
N
When the DMA interface begins an operation cycle, the DMA Instruction Status Register (DMA0ISW, Figure 6.9) is
loaded with the address contained within the DMA Instruction Boundary Register (DMA0BND, Figure 6.8). The
instruction is fetched from the Instruction Buffer, and the DMA Control Logic waits for data from the appropriate
ADC(s). At the end of an instruction, the Repeat Counter (Registers DMA0CSH and DMA0CSL) is decremented,
and the instruction will be repeated until the Repeat Counter reaches 0x0000. The Repeat Counter is then reset to the
Repeat Counter Limit value (Registers DMA0CTH and DMA0CTL), and the DMA will increment DMA0ISW to the
next instruction address. When the current DMA instruction is an End of Operation instruction, the Instruction Status
Register is reset to the Instruction Boundary Register. If the Continuous Conversion bit (bit 7, CCNV) in the End of
Operation instruction word is set to ‘1’, the DMA will continue to execute instructions. When CCNV is set to ‘0’, the
DMA will stop executing instructions at this point. An example of Mode 1 operation is shown in Figure 6.3.
RM
Figure 6.3. DMA Mode 1 Operation
XRAM
DMA0CSH:L = 0x0000
0x3F
...
VA
NC
00000000
00110000
01000000
00010000
ADC1L
ADC1H
ADC0L
ADC0H
ADC0L (Diff.)
ADC0H (Diff.)
ADC0L (Diff.)
ADC0H (Diff.)
ADC0L
ADC0H
ADC0L
ADC0H
ADC0L
ADC0H
DMA0CSH:L = DMA0CTH:L
DMA0CSH:L = 0x0000
DMA0CSH:L = DMA0CTH:L
DMA0CSH:L = 0x0000
DMA0CSH:L = DMA0CTH:L - 1
DMA0CSH:L = DMA0CTH:L
AD
DMA0BND
0x03
0x02
0x01
0x00
ED
INSTRUCTION
BUFFER
(64 Bytes)
IN
FO
ADC1L
ADC1H
ADC0L
ADC0H
Page 74
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
6.6.
C8051F060/1/2/3
Interrupt Sources
IO
N
The DMA contains multiple interrupt sources. Some of these can be individually enabled to generate interrupts as
necessary. The DMA Control Register (DMA0CN, Figure 6.4) and DMA Configuration Register (DMA0CF,
Figure 6.5) contain the enable bits and flags for the DMA interrupt sources. When an interrupt is enabled and the
interrupt condition occurs, a DMA interrupt will be generated (EIE2.7 is set to ‘1’).
The DMA flags that can generate a DMA0 interrupt are:
6.7.
ED
IN
FO
RM
AT
1. DMA Operations Complete (DMA0CN.6, DMA0INT) occurs when all DMA operations have been
completed, and the DMA interface is idle.
2. ADC1 Data Overflow Error (DMA0CN.4, DMA0DE1) occurs when the DMA interface cannot access
XRAM for two conversion cycles of ADC1. This flag indicates that at least one conversion result from
ADC1 has been discarded.
3. ADC0 Data Overflow Error (DMA0CN.3, DMA0DE0) occurs when the DMA interface cannot access
XRAM for two conversion cycles of ADC0. This flag indicates that at least one conversion result from
ADC0 has been discarded.
4. ADC1 Data Overflow Warning (DMA0CN.1, DMA0DO1) occurs when data from ADC0 becomes
available and the DMA has not yet written the previous results to XRAM. This interrupt source can be
enabled and disabled with the Data Overflow Warning Enable bit (DMA0CN.2, DMA0DOE).
5. ADC0 Data Overflow Warning (DMA0CN.0, DMA0DO0) occurs when data from ADC1 becomes
available and the DMA has not yet written the previous results to XRAM. This interrupt source can be
enabled and disabled with the Data Overflow Warning Enable bit (DMA0CN.2, DMA0DOE).
6. Repeat Counter Overflow (DMA0CF.2, DMA0CI) occurs when the Repeat Counter reaches the Repeat
Counter Limit. This interrupt source can be enabled and disabled with the Repeat Counter Overflow Interrupt Enable bit (DMA0CF.3, DMA0CIE).
7. End Of Operation (DMA0CF.0, DMA0EO) occurs when an End Of Operation instruction is reached in
the Instruction Buffer. This interrupt source can be enabled and disabled with the End Of Operation Interrupt
Enable bit (DMA0CF.1, DMA0EOE).
Data Buffer Overflow Warnings and Errors
AD
VA
NC
The data paths from the ADCs to XRAM are double-buffered when using the DMA interface. When a conversion is
completed by the ADC, it first enters the ADCs data register. If the DMA’s data buffer is empty, the conversion
results will immediately be written into the DMA’s internal data buffer for that ADC. Data in the DMA’s internal data
buffer is written to XRAM at the first available opportunity (see Section “6.3. XRAM Addressing and Setup” on
page 72). Conversion results from the ADC’s data registers are not copied into the DMA’s data buffer until data in the
buffer has been written to XRAM. When a conversion is completed and the DMA’s data buffer is not empty, an overflow warning flag is generated. If a second conversion data word becomes available before the DMA’s data buffer is
written to XRAM, the data in the ADC’s data registers is over-written with the new data word, and a data overflow
error flag is generated.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 75
Advanced
Information
C8051F060/1/2/3
SFR Page:
SFR Address:
R/W
0x03
0xD8
R/W
(bit addressable)
R/W
R/W
R/W
R/W
R/W
N
Figure 6.4. DMA0CN: DMA0 Control Register
R/W
Reset Value
Bit7
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
DMA0EN: DMA0 Enable.
Write:
0: Stop DMA0 Operations.
1: Begin DMA0 Operations.
Read:
0: DMA0 is Idle.
1: DMA0 Operation is in Progress.
DMA0INT: DMA0 Operations Complete Flag.
0: DMA0 has not completed all operations.
1: DMA0 operations are complete. This bit must be cleared by software.
DMA0MD: DMA0 Mode Select.
0: DMA0 will operate in Mode 0.
1: DMA0 will operate in Mode 1.
DMA0DE1: ADC1 Data Overflow Error Flag.
0: ADC1 Data Overflow has not occured.
1: ADC1 Data Overflow has occured, and data from ADC1 has been lost. This bit must be cleared by
software.
DMA0DE0: ADC0 Data Overflow Error Flag.
0: ADC0 Data Overflow has not occured.
1: ADC0 Data Overflow has occured, and data from ADC0 has been lost. This bit must be cleared by
software.
DMA0DOE: Data Overflow Warning Interrupt Enable.
0: Disable Data Overflow Warning interrupts.
1: Enable Data Overflow Warning interrups.
DMA0DO1: ADC1 Data Overflow Warning Flag.
0: No ADC1 Data Buffer Warnings have been issued.
1: ADC1 Data Buffer is full, and the DMA has not written previous data to XRAM. This bit must be
cleared by software.
DMA0DO0: ADC0 Data Overflow Warning Flag.
0: No ADC0 Data Buffer Warnings have been issued.
1: ADC0 Data Buffer is full, and the DMA has not written previous data to XRAM. This bit must be
cleared by software.
Bit 3:
Bit 2:
Bit 1:
FO
AD
Bit 0:
IN
Bit 4:
ED
Bit 5:
VA
NC
Bit 6:
RM
AT
Bit 7:
Bit6
IO
DMA0EN DMA0INT DMA0MD DMA0DE1 DMA0DE0 DMA0DOE DMA0DO1 DMA0DO0 00000000
Page 76
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 6.5. DMA0CF: DMA0 Configuration Register
(bit addressable)
R
DMA0HLT DMA0XBY
Bits 5-4:
Bit 3:
Bit 2:
Bit 1:
Bit4
R/W
R/W
R/W
Reset Value
Bit3
Bit2
Bit1
Bit0
AT
DMA0HLT: Halt DMA0 Off-Chip XRAM Access (C8051F060/2 Only).
0: DMA0 has complete access to off-chip XRAM.
1: Processor core has complete access to off-chip XRAM. DMA0 will wait until this bit is ‘0’ before
writing to off-chip XRAM locations.
DMA0XBY: Off-chip XRAM Busy Flag (C8051F060/2 Only).
0: DMA0 is not accessing off-chip XRAM.
1: DMA0 is accessing off-chip XRAM.
RESERVED. Write to 00b.
DMA0CIE: Repeat Counter Overflow Interrupt Enable.
0: Disable Repeat Counter Overflow Interrupt.
1: Enable Repeat Counter Overflow Interrupt.
DMA0CI: Repeat Counter Overflow Flag.
0: Repeat Counter Overflow has not occured.
1: Repeat Counter Overflow has occured. This bit must be cleared by software.
DMA0EOE: End-Of-Operation Interrupt Enable.
0: Disable End-Of-Operation Interrupt.
1: Enable End-Of-Operation Interrupt.
DMA0EO: End-Of-Operation Flag.
0: End-Of-Operation Instruction has not been received.
1: End-Of-Operation Instruction has been received. This bit must be cleared by software.
AD
VA
NC
ED
Bit 0:
Bit5
R/W
DMA0CIE DMA0CI DMA0EOE DMA0EO 00000000
RM
Bit 6:
-
FO
Bit 7:
Bit6
R/W
-
IN
Bit7
R/W
N
R/W
0x03
0xF8
IO
SFR Page:
SFR Address:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 77
C8051F060/1/2/3
Advanced
Information
0x03
0xDD
R
R
-
-
Bit7
Bit6
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
R/W
Bit2
Bit1
Reset Value
00000000
Bit0
Unused.
DMA0 instruction address to write (or read). When DMA0IDT is written or read, this register will be
incremented to point to the next instruction address.
AT
Bits 7-6:
Bits 5-0:
R/W
IO
SFR Page:
SFR Address:
N
Figure 6.6. DMA0IPT: DMA0 Instruction Write Address Register
0x03
0xDE
R/W
R/W
R/W
R/W
CCNV
DIFFSEL
ADC1EN
ADC0EN
Bit7
Bit6
Bit5
Bit4
Bit 5:
Bit 4:
Bits 3-0:
R/W
R/W
Reset Value†
-
-
-
xxxxxxxx
Bit3
Bit2
Bit1
Bit0
IN
CCNV: Continuous Conversion.
0: Disable Continuous Conversion.
1: Enable Continuous Conversion. Repeat Counter value is ignored, and conversions will continue.
DIFFSEL: Wait for data in differential mode.
0: Differential Data will not be collected.
1: Wait for differential data, and store to XRAM.
ADC1EN: Wait for data from ADC1.
0: ADC1 Data will not be collected.
1: Wait for ADC1 data, and store to XRAM.
ADC0EN: Wait for data from ADC0.
0: ADC0 Data will not be collected.
1: Wait for ADC0 data, and store to XRAM. If DIFFSEL is also ‘1’, only the differential data will be
stored.
RESERVED. Write to 0000b.
ED
Bit 6:
R/W
-
VA
NC
Bit 7:
R/W
FO
SFR Page:
SFR Address:
RM
Figure 6.7. DMA0IDT: DMA0 Instruction Write Data Register
For more details on DMA instruction words, see Section “6.2. DMA0 Instruction Format” on page 72.
AD
† This register points to a dedicated RAM location and its reset value is indeterminate.
Page 78
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
3
0xFD
R/W
R/W
-
-
Bit7
Bit6
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
R/W
Bit2
Bit1
Reset Value
00000000
Bit0
Unused.
DMA0 instruction address to begin with when executing DMA instructions.
AT
Bits 7-6:
Bits 5-0:
R/W
IO
SFR Page:
SFR Address:
N
Figure 6.8. DMA0BND: DMA0 Instruction Boundary Register
3
0xFE
R/W
R/W
-
-
Bit7
Bit6
R/W
Bit5
Bit4
R/W
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
IN
Unused.
Contains the address of the current DMA0 Instruction to be executed.
AD
VA
NC
ED
Bits 7-6:
Bits 5-0:
R/W
FO
SFR Page:
SFR Address:
RM
Figure 6.9. DMA0ISW: DMA0 Instruction Status Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 79
C8051F060/1/2/3
Advanced
Information
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
DMA0 Address Beginning High-Order Bits.
R/W
Bit1
Reset Value
00000000
Bit0
AT
Bits 7-0:
3
0xDA
IO
SFR Page:
SFR Address:
N
Figure 6.10. DMA0DAH: DMA0 Data Address Beginning MSB Register
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
DMA0 Address Beginning Low-Order Bits.
IN
Bits 7-0:
3
0xD9
FO
SFR Page:
SFR Address:
RM
Figure 6.11. DMA0DAL: DMA0 Data Address Beginning LSB Register
SFR Page:
SFR Address:
3
0xDC
R/W
R/W
Bit7
Bit6
Bit5
Bits 7-0:
VA
NC
R/W
ED
Figure 6.12. DMA0DSH: DMA0 Data Address Pointer MSB Register
R/W
R/W
R/W
R/W
R/W
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
00000000
DMA0 Address Pointer High-Order Bits.
Figure 6.13. DMA0DSL: DMA0 Data Address Pointer LSB Register
3
0xDB
AD
SFR Page:
SFR Address:
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bits 7-0:
Page 80
Reset Value
00000000
DMA0 Address Pointer Low-Order Bits.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
DMA0 Repeat Counter Limit High-Order Bits.
R/W
Bit1
Reset Value
00000000
Bit0
AT
Bits 7-0:
3
0xFA
IO
SFR Page:
SFR Address:
N
Figure 6.14. DMA0CTH: DMA0 Repeat Counter Limit MSB Register
R/W
R/W
Bit7
Bit6
R/W
R/W
Bit5
Bit4
R/W
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
DMA0 Repeat Counter Limit Low-Order Bits.
IN
Bits 7-0:
3
0xF9
FO
SFR Page:
SFR Address:
RM
Figure 6.15. DMA0CTL: DMA0 Repeat Counter Limit LSB Register
SFR Page:
SFR Address:
3
0xFC
R/W
R/W
Bit7
Bit6
Bit5
Bits 7-0:
VA
NC
R/W
ED
Figure 6.16. DMA0CSH: DMA0 Repeat Counter MSB Register
R/W
R/W
R/W
R/W
R/W
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
00000000
DMA0 Repeat Counter High-Order Bits.
Figure 6.17. DMA0CSL: DMA0 Repeat Counter LSB Register
3
0xFB
AD
SFR Page:
SFR Address:
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bits 7-0:
Reset Value
00000000
DMA0 Repeat Counter Low-Order Bits.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 81
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 82
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
7.
C8051F060/1/2/3
10-BIT ADC (ADC2)
AT
IO
N
The ADC2 subsystem for the C8051F060/1/2/3 consists of an analog multiplexer (referred to as AMUX2), and a
200 ksps, 10-bit successive-approximation-register ADC with integrated track-and-hold and programmable window
detector (see block diagram in Figure 7.1). The AMUX2, data conversion modes, and window detector can all be
configured from within software via the Special Function Registers shown in Figure 7.1. ADC2 operates in both Single-ended and Differential modes, and may be configured to measure any of the pins on Port 1, or the Temperature
Sensor output. The ADC2 subsystem 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.
Figure 7.1. ADC2 Functional Block Diagram
ADC2GTL
ADC2LTH
ADC2LTL
RM
20
IN
AIN2.6
AIN2.7
AMX2AD3
AMX2AD2
AMX2AD1
AMX2AD0
VA
NC
AIN67IC
AIN45IC
AIN23IC
AIN01IC
AGND
ED
TEMP
SENSOR
AMX2SL
ADC2CF
ADC2CN
10
00
Start Conversion 01
AD2BUSY (W)
Timer 3 Overflow
10
CNVSTR2
11
Timer 2 Overflow
AD
AMX2CF
ADC
AD2CM
AIN2.5
10-Bit
SAR
AD2SC4
AD2SC3
AD2SC2
AD2SC1
AD2SC0
AIN2.4
ADC2H
9-to-1
AMUX
(SE or
DIFF)
AD2EN
AD2TM
AD2INT
AD2BUSY
AD2CM1
AD2CM0
AD2WINT
AD2LJST
AIN2.3
FO
AIN2.2
ADC2L
AD2EN
AIN2.1
AD2WINT
10
SYSCLK
REF
AV+
AIN2.0
Comb.
Logic
AD2CM
ADC2GTH
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 83
C8051F060/1/2/3
7.1.
Advanced
Information
Analog Multiplexer
AT
IO
N
The analog multiplexer (AMUX2) selects the inputs to the ADC, allowing any of the pins on Port 1 to be measured in
single-ended mode, or as a differential pair. Additionally, the on-chip temperature sensor may be selected as a singleended input. The ADC2 input channels are configured and selected in the AMX2CF and AMX2SL registers as
described in Figure 7.5 and Figure 7.6, respectively. In Single-ended Mode, the selected pin is measured with respect
to AGND. In Differential Mode, the selected differential pair is measured with respect to one another. The polarity of
the differential measurement depends on the setting of the AMX2AD3-0 bits in the AMX2SL register. For example,
if pins AIN2.0 and AIN2.1 are configured for differential measurement (AIN01IC = 1), and AMX2AD3-0 = 0000b,
the ADC will measure the voltage (AIN2.0 - AIN2.1). If AMX2AD3-0 is changed to 0001b, the ADC will measure
the same voltage, with opposite polarity (AIN2.1 - AIN2.0).
Left-Justified ADC2H:ADC2L
(AD2LJST = 1)
0xFFC0
0x8000
0x4000
0x0000
FO
VREF * 1023/1024
VREF * 512/1024
VREF * 256/1024
0
Right-Justified ADC2H:ADC2L
(AD2LJST = 0)
0x03FF
0x0200
0x0100
0x0000
IN
Input Voltage
RM
The conversion code format differs between Single-ended and Differential modes. The registers ADC2H and ADC2L
contain the high and low bytes of the output conversion code from the ADC at the completion of each conversion.
Data can be right-justified or left-justified, depending on the setting of the AD2LJST bit (ADC2CN.0). When in Single-ended Mode, conversion codes are represented as 10-bit unsigned integers. Inputs are measured from ‘0’ to
VREF * 1023/1024. Example codes are shown below for both right-justified and left-justified data. Unused bits in the
ADC2H and ADC2L registers are set to ‘0’.
Right-Justified ADC2H:ADC2L
(AD2LJST = 0)
0x01FF
0x0100
0x0000
0xFF00
0xFE00
VA
NC
Input Voltage
ED
When in Differential Mode, conversion codes are represented as 10-bit signed 2’s complement numbers. Inputs are
measured from -VREF to VREF * 511/512. Example codes are shown below for both right-justified and left-justified
data. For right-justified data, the unused MSBs of ADC2H are a sign-extension of the data word. For left-justified
data, the unused LSBs in the ADC2L register are set to ‘0’.
VREF * 511/512
VREF * 256/512
0
-VREF * 256/512
- VREF
Left-Justified ADC2H:ADC2L
(AD2LJST = 1)
0x7FC0
0x4000
0x0000
0xC000
0x8000
AD
Important Note About ADC2 Input Configuration: Port 1 pins selected as ADC2 inputs should be configured as
analog inputs. To configure a Port 1 pin for analog input, set to ‘1’ the corresponding bit in register P1MDIN. Port 1
pins used as ADC2 inputs will be skipped by the crossbar for peripheral assignments. See Section “17. PORT
INPUT/OUTPUT” on page 191 for more Port I/O configuration details.
The Temperature Sensor transfer function is shown in Figure 7.2 on Page 85. The output voltage (VTEMP) is a singleended input to ADC2 when the Temperature Sensor is selected by bits AMX2AD3-0 in register AMX2SL.
Page 84
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 7.2. Typical Temperature Sensor Transfer Function
N
(Volts)
IO
1.200
AT
1.100
1.000
0.900
RM
VTEMP = 0.0033*(TEMPC) + 0.89
0.800
-50
Modes of Operation
50
100
(Celsius)
IN
7.2.
0
FO
0.700
7.2.1.
Starting a Conversion
ED
ADC2 has a maximum conversion speed of 200 ksps. The ADC2 conversion 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 ADC2 conversion clock should be no more than 3 MHz.
1.
2.
3.
4.
VA
NC
A conversion can be initiated in one of four ways, depending on the programmed states of the ADC2 Start of Conversion Mode bits (AD2CM1-0) in register ADC2CN. Conversions may be initiated by one of the following:
Writing a ‘1’ to the AD2BUSY bit of register ADC2CN
A Timer 3 overflow (i.e. timed continuous conversions)
A rising edge on the CNVSTR2 input signal (Assigned by the crossbar)
A Timer 2 overflow
AD
When CNVSTR2 is used as a conversion start source, it must be enabled in the crossbar, and the corresponding pin
must be set to open-drain, high-impedance mode (see Section “17. PORT INPUT/OUTPUT” on page 191 for more
details on Port I/O configuration).
Writing a ‘1’ to AD2BUSY provides software control of ADC2 whereby conversions are performed "on-demand".
During conversion, the AD2BUSY bit is set to logic 1 and reset to logic 0 when the conversion is complete. The falling edge of AD2BUSY triggers an interrupt (when enabled) and sets the ADC2 interrupt flag (AD2INT). Note: When
polling for ADC conversion completions, the ADC2 interrupt flag (AD2INT) should be used. Converted data is available in the ADC2 data registers, ADC2H and ADC2L, when bit AD2INT is logic 1. Note that when Timer 2 or
Timer 3 overflows are used as the conversion source, low byte overflows are used if the timer is in 8-bit mode; and
high byte overflows are used if the timer is in 16-bit mode. See Section “23. TIMERS” on page 271 for timer configuration.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 85
Advanced
Information
C8051F060/1/2/3
7.2.2.
Tracking Modes
AT
IO
N
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 track-and-hold 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 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.3). Tracking can also be disabled (shutdown) when the device is in low power standby or sleep modes. Lowpower track-and-hold mode is also useful when AMUX settings are frequently changed, due to the settling time
requirements described in Section “7.2.3. Settling Time Requirements” on page 87.
RM
Figure 7.3. 10-Bit ADC Track and Conversion Example Timing
A. ADC2 Timing for External Trigger Source
CNVSTR2
(AD2CM[1:0]=10)
FO
1
SAR Clocks
Low Power
or Convert
AD2TM=0
3
4
Track
IN
AD2TM=1
2
Track or Convert
5
6
7
8
9
10 11
Convert
Low Power
Mode
Convert
Track
ED
B. ADC2 Timing for Internal Trigger Source
VA
NC
Write '1' to AD2BUSY,
Timer 3, Timer 2 Overflow
(AD2CM[1:0]=00, 01, 11)
1
2
3
4
5
6
7
8
9
10 11 12 13 14
SAR Clocks
AD2TM=1
Low Power
or Convert
Track
1
2
3
Convert
4
5
6
7
8
9
Low Power Mode
10 11
AD
SAR Clocks
Page 86
AD2TM=0
Track or
Convert
Convert
Track
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
7.2.3.
C8051F060/1/2/3
Settling Time Requirements
IO
N
When the ADC2 input configuration is changed (i.e., a different AMUX2 selection is made, or an external multiplexer is switched), a minimum tracking time is required before an accurate conversion can be performed. This tracking time is determined by the AMUX2 resistance, the ADC2 sampling capacitance, any external source resistance,
and the accuracy required for the conversion. Note that in 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 minimum tracking time requirements.
AT
Figure 7.4 shows the equivalent ADC2 input circuits for both Differential and Single-ended modes. Notice that the
equivalent time constant for both input circuits is the same. The required ADC2 settling time for a given settling
accuracy (SA) may be approximated by Equation 7.1. When measuring the Temperature Sensor output, RTOTAL
reduces to RMUX. See Table 7.1 for ADC2 minimum settling time requirements.
RM
Equation 7.1. ADC2 Settling Time Requirements
n
FO
2
t = ln  ------- × R TOTAL C SAMPLE
 SA
IN
Where:
SA is the settling accuracy, given as a fraction of an LSB (for example, 0.25 to settle within 1/4 LSB)
t is the required settling time in seconds
RTOTAL is the sum of the AMUX2 resistance and any external source resistance.
n is the ADC resolution in bits (10).
ED
Figure 7.4. ADC2 Equivalent Input Circuits
VA
NC
Differential Mode
Single-Ended Mode
MUX Select
MUX Select
P1.x
P1.x
RMUX = 5k
RMUX = 5k
CSAMPLE = 5pF
AD
RCInput= RMUX * CSAMPLE
CSAMPLE = 5pF
RCInput= RMUX * CSAMPLE
CSAMPLE = 5pF
P1.y
RMUX = 5k
MUX Select
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 87
Advanced
Information
C8051F060/1/2/3
SFR Page:
SFR Address:
R/W
2
0xBA
R/W
R/W
R/W
R/W
R/W
R/W
-
-
-
AIN67IC
AIN45IC
AIN23IC
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit 0:
AT
The ADC2 Data Word is in the 2’s complement format for channels configured as differential. The
polarity of a differential measurement is determined by the AMX2SL setting. See Figure 7.5 for
more details on multiplexer channel selection.
AD
VA
NC
ED
NOTE:
00000000
Bit0
RM
Bit 1:
AIN01IC
FO
Bit 2:
UNUSED. Read = 0000b; Write = don’t care.
AIN67IC: AIN2.6, AIN2.7 Input Pair Configuration Bit.
0: AIN2.6 and AIN2.7 are independent, single-ended inputs.
1: AIN2.6 and AIN2.7 are a differential input pair.
AIN45IC: AIN2.4, AIN2.5 Input Pair Configuration Bit.
0: AIN2.4 and AIN2.5 are independent, single-ended inputs.
1: AIN2.4 and AIN2.5 are a differential input pair.
AIN23IC: AIN2.2, AIN2.3 Input Pair Configuration Bit.
0: AIN2.2 and AIN2.3 are independent, single-ended inputs.
1: AIN2.2 and AIN2.3 are a differential input pair.
AIN01IC: AIN2.0, AIN2.1 Input Pair Configuration Bit.
0: AIN2.0 and AIN2.1 are independent, single-ended inputs.
1: AIN2.0 and AIN2.1 are a differential input pair.
Reset Value
IN
Bits 7-4:
Bit 3:
R/W
IO
Bit7
N
Figure 7.5. AMX2CF: AMUX2 Configuration Register
Page 88
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 7.6. AMX2SL: AMUX2 Channel Select Register
R/W
R/W
R/W
R/W
-
-
-
-
Bit7
Bit6
Bit5
Bit4
R/W
R/W
R/W
Reset Value
AMX2AD3 AMX2AD2 AMX2AD1 AMX2AD0 00000000
Bit3
Bit2
Bit1
Bit0
Single-Ended Measurement
0000
AIN2.0
0001
AIN2.1
0010
AIN2.2
0011
AIN2.3
0100
AIN2.4
0101
AIN2.5
0110
AIN2.6
0111
AIN2.7
1xxx
Temperature
Sensor
AMX2AD3-0
AIN01IC = 0
AIN45IC = 0
AIN67IC = 0
+(AIN2.0) -(AIN2.1)
0001
+(AIN2.1) -(AIN2.0)
0010
+(AIN2.2) -(AIN2.3)
0011
+(AIN2.3) -(AIN2.2)
0100
+(AIN2.4) -(AIN2.5)
0101
+(AIN2.5) -(AIN2.4)
0110
+(AIN2.6) -(AIN2.7)
0111
+(AIN2.7) -(AIN2.6)
1xxx
-
FO
AIN23IC = 0
0000
Differential Measurement
RM
AMX2AD3-0
AT
UNUSED. Read = 0000b; Write = don’t care.
AMX2AD3-0: AMX2 Address Bits.
0000-1111b: ADC input multiplexer channel selected per chart below.
AIN01IC = 1
AIN23IC = 1
AIN45IC = 1
AIN67IC = 1
AD
VA
NC
ED
IN
Bits 7-4:
Bits 3-0:
R/W
N
2
0xBB
IO
SFR Page:
SFR Address:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 89
Advanced
Information
C8051F060/1/2/3
2
0xBC
R/W
R/W
R/W
R/W
R/W
R/W
AD2SC4
AD2SC3
AD2SC2
AD2SC1
AD2SC0
AD2LJST
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
11111000
RM
FO
AD2LJST: ADC2 Left Justify Select.
0: Data in ADC2H:ADC2L registers are right-justified.
1: Data in ADC2H:ADC2L registers are left-justified.
UNUSED. Read = 00b; Write = don’t care.
AD
VA
NC
ED
IN
Bits1-0:
-
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 bits AD2SC4-0. SAR Conversion clock requirements are given in Table 7.1.
SYSCLK
AD2SC = ---------------------- – 1
CLK SAR
Bit2:
R/W
-
AT
Bits7-3:
R/W
IO
SFR Page:
SFR Address:
N
Figure 7.7. ADC2CF: ADC2 Configuration Register
Page 90
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
Bit6
R/W
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
R/W
Bit2
Bit1
Reset Value
00000000
Bit0
AT
Bit7
ADC2 Data Word High-Order Bits.
For AD2LJST = 0: Bits 7-2 are the sign extension of Bit 1. Bits 1-0 are the upper 2 bits of the 10-bit
ADC2 Data Word.
For AD2LJST = 1: Bits 7-0 are the most-significant bits of the 10-bit ADC2 Data Word.
RM
Bits7-0:
2
0xBF
IO
SFR Page:
SFR Address:
N
Figure 7.8. ADC2H: ADC2 Data Word MSB Register
R/W
Bit7
R/W
Bit6
R/W
R/W
R/W
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
ADC2 Data Word Low-Order Bits.
For AD2LJST = 0: Bits 7-0 are the lower 8 bits of the 10-bit Data Word.
For AD2LJST = 1: Bits 7-6 are the lower 2 bits of the 10-bit Data Word. Bits 5-0 will always read ‘0’.
AD
VA
NC
ED
Bits7-0:
2
0xBE
IN
SFR Page:
SFR Address:
FO
Figure 7.9. ADC2L: ADC2 Data Word LSB Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 91
Advanced
Information
C8051F060/1/2/3
2
0xE8
R/W
R/W
AD2EN
AD2TM
Bit7
Bit6
Bit5:
R/W
R/W
Bit5
Bit4
R/W
R/W
Reset Value
AD2CM0 AD2WINT AD2LJST 00000000
Bit3
Bit2
Bit1
Bit0
AT
AD2EN: ADC2 Enable Bit.
0: ADC2 Disabled. ADC2 is in low-power shutdown.
1: ADC2 Enabled. ADC2 is active and ready for data conversions.
AD2TM: ADC2 Track Mode Bit.
0: Normal Track Mode: When ADC2 is enabled, tracking is continuous unless a conversion is in
progress.
1: Low-power Track Mode: Tracking Defined by AD2CM2-0 bits (see below).
AD2INT: ADC2 Conversion Complete Interrupt Flag.
0: ADC2 has not completed a data conversion since the last time AD2INT was cleared.
1: ADC2 has completed a data conversion.
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 AD2CM2-0 = 000b
AD2CM1-0: ADC2 Start of Conversion Mode Select.
When AD2TM = 0:
00: ADC2 conversion initiated on every write of ‘1’ to AD2BUSY.
01: ADC2 conversion initiated on overflow of Timer 3.
10: ADC2 conversion initiated on rising edge of external CNVSTR2 pin.
11: ADC2 conversion initiated on overflow of Timer 2.
When AD2TM = 1:
00: Tracking initiated on write of ‘1’ to AD2BUSY and lasts 3 SAR clocks, followed by conversion.
01: Tracking initiated on overflow of Timer 3 and lasts 3 SAR clocks, followed by conversion.
10: ADC2 tracks only when CNVSTR2 input is logic low; conversion starts on rising CNVSTR2
edge.
11: Tracking initiated on overflow of Timer 2 and lasts 3 SAR clocks, followed by conversion.
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.
AD2LJST: ADC2 Left Justify Select.
0: Data in ADC2H:ADC2L registers are right-justified.
1: Data in ADC2H:ADC2L registers are left-justified.
AD
Bit 1:
VA
NC
Bits 3-2:
ED
IN
Bit 4:
R/W
RM
Bit6:
R/W
AD2INT AD2BUSY AD2CM1
FO
Bit 7:
(bit addressable)
IO
SFR Page:
SFR Address:
N
Figure 7.10. ADC2CN: ADC2 Control Register
Bit 0:
Page 92
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
7.3.
C8051F060/1/2/3
Programmable Window Detector
AT
IO
N
The ADC Programmable Window Detector continuously compares the ADC2 output registers to user-programmed
limits, and notifies the system when a desired 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 register ADC2CN) can also be used in polled mode. The ADC2 Greater-Than
(ADC2GTH, ADC2GTL) and Less-Than (ADC2LTH, ADC2LTL) registers hold the comparison values. The window
detector flag can be programmed to indicate when measured data is inside or outside of the user-programmed limits,
depending on the contents of the ADC2 Less-Than and ADC2 Greater-Than registers.
SFR Page:
SFR Address:
2
0xC5
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
R/W
R/W
R/W
Bit2
Bit1
Bit0
Reset Value
11111111
FO
R/W
RM
Figure 7.11. ADC2GTH: ADC2 Greater-Than Data High Byte Register
Bits7-0: High byte of ADC2 Greater-Than Data Word.
SFR Page:
SFR Address:
IN
Figure 7.12. ADC2GTL: ADC2 Greater-Than Data Low Byte Register
2
0xC4
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
ED
R/W
Reset Value
11111111
AD
VA
NC
Bits7-0: Low byte of ADC2 Greater-Than Data Word.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 93
C8051F060/1/2/3
Advanced
Information
Bit7
R/W
Bit6
R/W
Bit5
R/W
R/W
Bit4
R/W
Bit3
R/W
R/W
IO
R/W
2
0xC7
Bit2
Bit1
Reset Value
00000000
Bit0
AT
SFR Page:
SFR Address:
N
Figure 7.13. ADC2LTH: ADC2 Less-Than Data High Byte Register
Bits7-0: High byte of ADC2 Less-Than Data Word.
2
0xC6
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
R/W
FO
SFR Page:
SFR Address:
Bit3
R/W
R/W
R/W
Bit2
Bit1
Bit0
Reset Value
00000000
AD
VA
NC
ED
IN
Bits7-0: Low byte of ADC2 Less-Than Data Word.
RM
Figure 7.14. ADC2LTL: ADC2 Less-Than Data Low Byte Register
Page 94
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
7.3.1.
C8051F060/1/2/3
Window Detector In Single-Ended Mode
AT
IO
N
Figure 7.15 shows two example window comparisons for right-justified, single-ended data, with
ADC2LTH:ADC2LTL = 0x0080 (128d) and ADC2GTH:ADC2GTL = 0x0040 (64d). In single-ended mode, the input
voltage can range from ‘0’ to VREF * (1023/1024) with respect to AGND, and is represented by a 10-bit unsigned
integer value. In the left example, an AD2WINT interrupt will be generated if the ADC2 conversion word
(ADC2H:ADC2L) is within the range defined by ADC2GTH:ADC2GTL and ADC2LTH:ADC2LTL
(if 0x0040 < ADC2H:ADC2L < 0x0080). In the right example, and AD2WINT interrupt will be generated if the
ADC2 conversion word is outside of the range defined by the ADC2GT and ADC2LT registers
(if ADC2H:ADC2L < 0x0040 or ADC2H:ADC2L > 0x0080). Figure 7.16 shows an example using left-justified data
with the same comparison values.
Figure 7.15. ADC Window Compare Example: Right-Justified Single-Ended Data
ADC2H:ADC2L
RM
ADC2H:ADC2L
Input Voltage
(P1.x - AGND)
VREF x (1023/1024)
Input Voltage
(P1.x - AGND)
VREF x (1023/1024)
0x03FF
0x0081
VREF x (128/1024)
0x0080
ADC2LTH:ADC2LTL
0x007F
FO
AD2WINT
not affected
VREF x (128/1024)
0x03FF
0x0081
0x0080
0x007F
AD2WINT=1
0x0041
0x0040
ADC2GTH:ADC2GTL
IN
VREF x (64/1024)
0x003F
VREF x (64/1024)
AD2WINT=1
0x0041
0x0040
ADC2GTH:ADC2GTL
AD2WINT
not affected
ADC2LTH:ADC2LTL
0x003F
AD2WINT=1
0
0x0000
ED
AD2WINT
not affected
0
0x0000
VA
NC
Figure 7.16. ADC Window Compare Example: Left-Justified Single-Ended Data
ADC2H:ADC2L
Input Voltage
(P1.x - AGND)
VREF x (1023/1024)
ADC2H:ADC2L
Input Voltage
(P1.x - AGND)
VREF x (1023/1024)
0xFFC0
0xFFC0
AD2WINT
not affected
AD2WINT=1
0x2040
VREF x (128/1024)
0x2000
0x2040
ADC2LTH:ADC2LTL
VREF x (128/1024)
AD
0x1FC0
0x1FC0
AD2WINT=1
0x1040
VREF x (64/1024)
0x1000
0x1040
ADC2GTH:ADC2GTL
VREF x (64/1024)
0x0FC0
0
0x0000
0x2000
0x1000
ADC2GTH:ADC2GTL
AD2WINT
not affected
ADC2LTH:ADC2LTL
0x0FC0
AD2WINT=1
AD2WINT
not affected
0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
0x0000
Page 95
Advanced
Information
C8051F060/1/2/3
7.3.2.
Window Detector In Differential Mode
AT
IO
N
Figure 7.17 shows two example window comparisons for right-justified, differential data, with
ADC2LTH:ADC2LTL = 0x0040 (+64d) and ADC2GTH:ADC2GTH = 0xFFFF (-1d). In differential mode, the measurable voltage between the input pins is between -VREF and VREF*(511/512). Output codes are represented as 10bit 2’s complement signed integers. In the left example, an AD2WINT interrupt will be generated if the ADC2 conversion word (ADC2H:ADC2L) is within the range defined by ADC2GTH:ADC2GTL and ADC2LTH:ADC2LTL
(if 0xFFFF (-1d) < ADC2H:ADC2L < 0x0040 (64d)). In the right example, an AD2WINT interrupt will be generated
if the ADC2 conversion word is outside of the range defined by the ADC2GT and ADC2LT registers
(if ADC2H:ADC2L < 0xFFFF (-1d) or ADC2H:ADC2L > 0x0040 (+64d)). Figure 7.18 shows an example using
left-justified data with the same comparison values.
Figure 7.17. ADC Window Compare Example: Right-Justified Differential Data
ADC2H:ADC2L
ADC2H:ADC2L
VREF x (511/512)
Input Voltage
(P1.x - P1.y)
RM
Input Voltage
(P1.x - P1.y)
VREF x (511/512)
0x01FF
0x0041
VREF x (64/512)
0x0040
ADC2LTH:ADC2LTL
FO
AD2WINT
not affected
VREF x (64/512)
0x003F
0x01FF
0x0041
0x0040
0x003F
AD2WINT=1
0x0000
0xFFFF
ADC2GTH:ADC2GTL
IN
VREF x (-1/512)
0xFFFE
VREF x (-1/512)
AD2WINT=1
0x0000
0xFFFF
ADC2GTH:ADC2GTL
AD2WINT
not affected
ADC2LTH:ADC2LTL
0xFFFE
AD2WINT=1
-VREF
0x0200
ED
AD2WINT
not affected
-VREF
0x0200
VA
NC
Figure 7.18. ADC Window Compare Example: Left-Justified Differential Data
ADC2H:ADC2L
Input Voltage
(P1.x - P1.y)
VREF x (511/512)
ADC2H:ADC2L
Input Voltage
(P1.x - P1.y)
VREF x (511/512)
0x7FC0
0x7FC0
AD2WINT
not affected
AD2WINT=1
0x1040
VREF x (64/512)
0x1000
0x1040
ADC2LTH:ADC2LTL
VREF x (64/512)
AD
0x0FC0
AD2WINT=1
0x0000
VREF x (-1/512)
0xFFC0
0x0000
ADC2GTH:ADC2GTL
VREF x (-1/512)
0xFF80
-VREF
Page 96
0x8000
0x1000
0x0FC0
0xFFC0
ADC2GTH:ADC2GTL
AD2WINT
not affected
ADC2LTH:ADC2LTL
0xFF80
AD2WINT=1
AD2WINT
not affected
-VREF
0x8000
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 7.1. ADC2 Electrical Characteristics
VDD = 3.0 V, VREF = 2.40 V (REFSL=0), PGA Gain = 1, -40°C to +85°C unless otherwise specified
CONDITIONS
MIN
TYP
DC ACCURACY
10
Integral Nonlinearity
Differential Nonlinearity
Guaranteed Monotonic
-12
Full Scale Error
Differential mode
-15
Offset Temperature Coefficient
UNITS
bits
±0.5
±1
LSB
±0.5
±1
LSB
1
12
LSB
-5
5
LSB
AT
Offset Error
IO
Resolution
MAX
N
PARAMETER
3.6
ppm/°C
Signal-to-Noise Plus Distortion
Total Harmonic Distortion
53
Up to the 5th harmonic
Spurious-Free Dynamic Range
FO
CONVERSION RATE
SAR Conversion Clock
Conversion Time in SAR Clocks
IN
Track/Hold Acquisition Time
Throughput Rate
ANALOG INPUTS
POWER SPECIFICATIONS
Operating Mode, 200 ksps
VA
NC
Power Supply Current (VDD supplied to ADC2)
ED
Input Voltage Range
Input Capacitance
RM
DYNAMIC PERFORMANCE (10 kHz sine-wave Differential input, 1 dB below Full Scale, 200 ksps)
dB
-67
dB
78
dB
3
MHz
10
clocks
300
ns
0
200
ksps
VREF
V
5
400
±0.3
pF
900
µA
mV/V
AD
Power Supply Rejection
55.5
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 97
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 98
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
8.
C8051F060/1/2/3
DACS, 12-BIT VOLTAGE MODE (DAC0 AND DAC1)
IN
FO
RM
AT
IO
N
Each C8051F06x device includes two on-chip 12-bit voltage-mode Digital-to-Analog Converters (DACs). Each
DAC has an output swing of 0 V to (VREF-1LSB) for a corresponding input code range of 0x000 to 0xFFF. The
DACs may be enabled/disabled via their corresponding control registers, DAC0CN and DAC1CN. While disabled,
the DAC output is maintained in a high-impedance state, and the DAC supply current falls to 1 µA or less. The voltage reference for each DAC is supplied at the VREFD pin (C8051F060/2 devices) or the VREF2 pin (C8051F061/3
devices). See Section “9. VOLTAGE REFERENCE 2 (C8051F060/2)” on page 107 or Section “10. VOLTAGE
REFERENCE 2 (C8051F061/3)” on page 109 for more information on configuring the voltage reference for the
DACs. Note that the BIASE bit described in the voltage reference sections must be set to ‘1’ to use the DACs.
Dig. MUX
8
AV+
12
DAC0
DAC0
8
AGND
Timer 2
DAC0H
Latch
Latch
Timer 4
Timer 3
8
DAC1H
DAC0L
8
REF
DAC1MD1
DAC1MD0
DAC1DF2
DAC1DF1
DAC1DF0
REF
8
8
Dig. MUX
Latch
8
Latch
DAC1H
AV+
DAC1L
DAC1CN
AD
DAC1EN
Timer 2
Timer 4
ED
DAC0H
DAC0MD1
DAC0MD0
DAC0DF2
DAC0DF1
DAC0DF0
VA
NC
DAC0CN
DAC0EN
Timer 3
Figure 8.1. DAC Functional Block Diagram
12
DAC1
DAC1
8
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
AGND
Page 99
C8051F060/1/2/3
8.1.
Advanced
Information
DAC Output Scheduling
Update Output On-Demand
IO
8.1.1.
N
Each DAC features a flexible output update mechanism which allows for seamless full-scale changes and supports
jitter-free updates for waveform generation. The following examples are written in terms of DAC0, but DAC1 operation is identical.
8.1.2.
Update Output Based on Timer Overflow
RM
AT
In its default mode (DAC0CN.[4:3] = ‘00’) the DAC0 output is updated “on-demand” on a write to the high-byte of
the DAC0 data register (DAC0H). It is important to note that writes to DAC0L are held, and have no effect on the
DAC0 output until a write to DAC0H takes place. If writing a full 12-bit word to the DAC data registers, the 12-bit
data word is written to the low byte (DAC0L) and high byte (DAC0H) data registers. Data is latched into DAC0 after
a write to the corresponding DAC0H register, so the write sequence should be DAC0L followed by DAC0H if the
full 12-bit resolution is required. The DAC can be used in 8-bit mode by initializing DAC0L to the desired value (typically 0x00), and writing data to only DAC0H (also see Section 8.2 for information on formatting the 12-bit DAC
data word within the 16-bit SFR space).
8.2.
IN
FO
Similar to the ADC operation, in which an ADC conversion can be initiated by a timer overflow independently of the
processor, the DAC outputs can use a Timer overflow to schedule an output update event. This feature is useful in
systems where the DAC is used to generate a waveform of a defined sampling rate by eliminating the effects of variable interrupt latency and instruction execution on the timing of the DAC output. When the DAC0MD bits
(DAC0CN.[4:3]) are set to ‘01’, ‘10’, or ‘11’, writes to both DAC data registers (DAC0L and DAC0H) are held until
an associated Timer overflow event (Timer 3, Timer 4, or Timer 2, respectively) occurs, at which time the
DAC0H:DAC0L contents are copied to the DAC input latches allowing the DAC output to change to the new value.
DAC Output Scaling/Justification
VA
NC
ED
In some instances, input data should be shifted prior to a DAC0 write operation to properly justify data within the
DAC input registers. This action would typically require one or more load and shift operations, adding software overhead and slowing DAC throughput. To alleviate this problem, the data-formatting feature provides a means for the
user to program the orientation of the DAC0 data word within data registers DAC0H and DAC0L. The three
DAC0DF bits (DAC0CN.[2:0]) allow the user to specify one of five data word orientations as shown in the DAC0CN
register definition.
AD
DAC1 is functionally the same as DAC0 described above. The electrical specifications for both DAC0 and DAC1 are
given in Table 8.1.
Page 100
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 8.2. DAC0H: DAC0 High Byte Register
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
N
R/W
Reset Value
00000000
Bit0
DAC0 Data Word Most Significant Byte.
AT
Bits7-0:
IO
SFR Address: 0xD3
SFR Page: 0
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
SFR Address: 0xD2
SFR Page: 0
DAC0 Data Word Least Significant Byte.
AD
VA
NC
ED
IN
Bits7-0:
R/W
FO
R/W
RM
Figure 8.3. DAC0L: DAC0 Low Byte Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 101
Advanced
Information
C8051F060/1/2/3
Figure 8.4. DAC0CN: DAC0 Control Register
R/W
R/W
DAC0EN
-
-
Bit7
Bit6
Bit5
R/W
R/W
R/W
R/W
R/W
Reset Value
DAC0MD1 DAC0MD0 DAC0DF2 DAC0DF1 DAC0DF0 00000000
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
AT
RM
Bits2-0:
000:
The most significant nibble of the DAC0 Data Word is in DAC0H[3:0], while the least
significant byte is in DAC0L.
DAC0H
DAC0L
MSB
The most significant 5-bits of the DAC0 Data Word is in DAC0H[4:0], while the least
significant 7-bits are in DAC0L[7:1].
DAC0H
DAC0L
MSB
LSB
The most significant 6-bits of the DAC0 Data Word is in DAC0H[5:0], while the least
significant 6-bits are in DAC0L[7:2].
DAC0H
DAC0L
VA
NC
010:
LSB
ED
001:
FO
Bits6-5:
Bits4-3:
DAC0EN: DAC0 Enable Bit.
0: DAC0 Disabled. DAC0 Output pin is disabled; DAC0 is in low-power shutdown mode.
1: DAC0 Enabled. DAC0 Output pin is active; DAC0 is operational.
UNUSED. Read = 00b; Write = don’t care.
DAC0MD1-0: DAC0 Mode Bits.
00: DAC output updates occur on a write to DAC0H.
01: DAC output updates occur on Timer 3 overflow.
10: DAC output updates occur on Timer 4 overflow.
11: DAC output updates occur on Timer 2 overflow.
DAC0DF2-0: DAC0 Data Format Bits:
IN
Bit7:
IO
SFR Address: 0xD4
SFR Page: 0
MSB
011:
MSB
AD
1xx:
MSB
Page 102
LSB
The most significant 7-bits of the DAC0 Data Word is in DAC0H[6:0], while the least
significant 5-bits are in DAC0L[7:3].
DAC0H
DAC0L
LSB
The most significant 8-bits of the DAC0 Data Word is in DAC0H[7:0], while the least
significant 4-bits are in DAC0L[7:4].
DAC0H
DAC0L
LSB
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 8.5. DAC1H: DAC1 High Byte Register
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
N
R/W
Reset Value
00000000
Bit0
IO
R/W
SFR Address: 0xD3
SFR Page: 1
DAC1 Data Word Most Significant Byte.
AT
Bits7-0:
Bit7
Bit6
R/W
R/W
Bit5
Bit4
R/W
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
SFR Address: 0xD2
SFR Page: 1
DAC1 Data Word Least Significant Byte.
AD
VA
NC
ED
IN
Bits7-0:
R/W
FO
R/W
RM
Figure 8.6. DAC1L: DAC1 Low Byte Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 103
Advanced
Information
C8051F060/1/2/3
Figure 8.7. DAC1CN: DAC1 Control Register
R/W
R/W
DAC1EN
-
-
Bit7
Bit6
Bit5
R/W
R/W
R/W
R/W
R/W
Reset Value
DAC1MD1 DAC1MD0 DAC1DF2 DAC1DF1 DAC1DF0 00000000
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
AT
RM
Bits2-0:
000:
The most significant nibble of the DAC1 Data Word is in DAC1H[3:0], while the least
significant byte is in DAC1L.
DAC1H
DAC1L
MSB
The most significant 5-bits of the DAC1 Data Word is in DAC1H[4:0], while the least
significant 7-bits are in DAC1L[7:1].
DAC1H
DAC1L
MSB
LSB
The most significant 6-bits of the DAC1 Data Word is in DAC1H[5:0], while the least
significant 6-bits are in DAC1L[7:2].
DAC1H
DAC1L
VA
NC
010:
LSB
ED
001:
FO
Bits6-5:
Bits4-3:
DAC1EN: DAC1 Enable Bit.
0: DAC1 Disabled. DAC1 Output pin is disabled; DAC1 is in low-power shutdown mode.
1: DAC1 Enabled. DAC1 Output pin is active; DAC1 is operational.
UNUSED. Read = 00b; Write = don’t care.
DAC1MD1-0: DAC1 Mode Bits:
00: DAC output updates occur on a write to DAC1H.
01: DAC output updates occur on Timer 3 overflow.
10: DAC output updates occur on Timer 4 overflow.
11: DAC output updates occur on Timer 2 overflow.
DAC1DF2: DAC1 Data Format Bits:
IN
Bit7:
IO
SFR Address: 0xD4
SFR Page: 1
MSB
011:
MSB
AD
1xx:
MSB
Page 104
LSB
The most significant 7-bits of the DAC1 Data Word is in DAC1H[6:0], while the least
significant 5-bits are in DAC1L[7:3].
DAC1H
DAC1L
LSB
The most significant 8-bits of the DAC1 Data Word is in DAC1H[7:0], while the least
significant 4-bits are in DAC1L[7:4].
DAC1H
DAC1L
LSB
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
.
Table 8.1. DAC Electrical Characteristics
PARAMETER
CONDITIONS
MIN
Resolution
Integral Nonlinearity
No Output Filter
100 kHz Output Filter
10 kHz Output Filter
Offset Error
Data Word = 0x014
Offset Tempco
Gain-Error Tempco
VDD Power Supply Rejection
Ratio
Output Sink Current
Output Short-Circuit Current
LSB
±1
±20
Data Word = 0xFFF
LSB
µVrms
±30
6
IN
DACnEN = 0
±1.5
±3
FO
Gain Error
UNITS
bits
250
128
41
RM
Output Noise
MAX
12
AT
Differential Nonlinearity
Output Impedance in Shutdown
Mode
TYP
IO
STATIC PERFORMANCE
N
VDD = 3.0 V, AV+ = 3.0 V, VREF = 2.40 V (REFBE = 0), No Output Load unless otherwise specified
mV
ppm/°C
±60
mV
10
ppm/°C
-60
dB
100
kΩ
300
µA
15
mA
0.44
V/µs
10
µs
Voltage Output Slew Rate
Output Settling Time to 1/2 LSB
Startup Time
Load = 40pF
Load = 40pF, Output swing from code
0xFFF to 0x014
VA
NC
Output Voltage Swing
ED
DYNAMIC PERFORMANCE
0
VREF1LSB
V
10
µs
60
ppm
ANALOG OUTPUTS
Load Regulation
IL = 0.01mA to 0.3mA at code 0xFFF
POWER CONSUMPTION (each DAC)
Data Word = 0x7FF
300
500
µA
AD
Power Supply Current (AV+ supplied to DAC)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 105
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 106
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
9.
C8051F060/1/2/3
VOLTAGE REFERENCE 2 (C8051F060/2)
IO
N
The voltage reference circuitry offers full flexibility in operating the ADC2 and DAC modules. Two voltage reference input pins allow ADC2 and the two DACs to reference an external voltage reference or the on-chip voltage reference output. ADC2 may also reference the analog power supply voltage, via the VREF multiplexer shown in
Figure 9.1.
AT
The internal voltage reference circuit consists of a 1.2 V, temperature stable bandgap voltage reference generator and
a gain-of-two output buffer amplifier. The internal reference may be routed via the VREF pin to external system components or to the voltage reference input pins shown in Figure 9.1. The maximum load seen by the VREF pin must be
less than 200 µA to AGND. Bypass capacitors of 0.1 µF and 4.7 µF are recommended from the VREF pin to AGND,
as shown in Figure 9.1.
IN
FO
RM
The Reference Control Register 2, REF2CN (defined in Figure 9.2) enables/disables the internal reference generator
and selects the reference input for ADC2. The BIASE bit in REF2CN enables the on-board reference generator while
the REFBE bit enables the gain-of-two buffer amplifier which drives the VREF pin. When disabled, the supply current drawn by the bandgap and buffer amplifier falls to less than 1 µA (typical) and the output of the buffer amplifier
enters a high impedance state. If the internal bandgap is used as the reference voltage generator, BIASE and REFBE
must both be set to logic 1. If the internal reference is not used, REFBE may be set to logic 0. Note that the BIASE bit
must be set to logic 1 if ADC2 or either DAC is used, regardless of the voltage reference used. If neither ADC2 nor
the DACs are being used, both of these bits can be set to logic 0 to conserve power. Bit AD2VRS selects between
VREF2 and AV+ for the ADC2 voltage reference source. The electrical specifications for the Voltage Reference are
given in Table 9.1.
VA
NC
VDD
AD
External
Voltage
Reference
Circuit
R
REF2CN
AD2VRS
TEMPE
BIASE
REFBE
ED
Figure 9.1. Voltage Reference Functional Block Diagram
ADC2
AV+
1
Ref
VREF2
0
DAC0
VREFD
Ref
DAC1
BIASE
EN
VREF
x2
+
4.7µF
0.1µF
Bias to
ADC2,
DACs
1.2V
Band-Gap
REFBE
Recommended Bypass
Capacitors
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 107
Advanced
Information
C8051F060/1/2/3
N
The temperature sensor connects to the highest order input of the ADC2 input multiplexer (see Section “7. 10-Bit
ADC (ADC2)” on page 83). The TEMPE bit within REF2CN enables and disables the temperature sensor. While disabled, the temperature sensor defaults to a high impedance state, and any A/D measurements performed on the sensor
while disabled result in meaningless data.
IO
Figure 9.2. REF2CN: Reference Control Register 2
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
-
-
-
-
AD2VRS
TEMPE
BIASE
REFBE
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit1:
AT
IN
Bit0:
RM
Bit2:
UNUSED. Read = 0000b; Write = don’t care.
AD2VRS: ADC2 Voltage Reference Select.
0: ADC2 voltage reference from VREF2 pin.
1: ADC2 voltage reference from AV+.
TEMPE: Temperature Sensor Enable Bit.
0: Internal Temperature Sensor Off.
1: Internal Temperature Sensor On.
BIASE: ADC/DAC Bias Generator Enable Bit. (Must be ‘1’ if using ADC2 or DACs).
0: Internal Bias Generator Off.
1: Internal Bias Generator On.
REFBE: Internal Reference Buffer Enable Bit.
0: Internal Reference Buffer Off.
1: Internal Reference Buffer On. Internal voltage reference is driven on the VREF pin.
FO
Bits7-4:
Bit3:
Bit0
SFR Address: 0xD1
SFR Page: 2
ED
Table 9.1. Voltage Reference Electrical Characteristics
VDD = 3.0 V, AV+ = 3.0 V, -40°C to +85°C unless otherwise specified
PARAMETER
CONDITIONS
MIN
TYP
MAX
UNITS
2.36
2.43
2.48
V
30
mA
Output Voltage
VA
NC
INTERNAL REFERENCE (REFBE = 1)
25°C ambient
VREF Short-Circuit Current
VREF Temperature Coefficient
15
ppm/°C
0.5
ppm/µA
Load = 0 to 200 µA to AGND
VREF Turn-on Time 1
4.7µF tantalum, 0.1µF ceramic bypass
2
ms
VREF Turn-on Time 2
0.1µF ceramic bypass
20
µs
VREF Turn-on Time 3
no bypass cap
10
µs
AD
Load Regulation
EXTERNAL REFERENCE (REFBE = 0)
Input Voltage Range
Input Current
Page 108
1.00
0
(AV+) 0.3
V
1
µA
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
10.
C8051F060/1/2/3
VOLTAGE REFERENCE 2 (C8051F061/3)
IO
N
The internal voltage reference circuit consists of a 1.2 V, temperature stable bandgap voltage reference generator and
a gain-of-two output buffer amplifier. The internal reference may be routed via the VREF pin to external system components or to the VREF2 input pin shown in Figure 10.1. The maximum load seen by the VREF pin must be less than
200 µA to AGND. Bypass capacitors of 0.1 µF and 4.7 µF are recommended from the VREF pin to AGND, as shown
in Figure 10.1.
AT
The VREF2 pin provides a voltage reference input for ADC2 and the DACs. ADC2 may also reference the analog
power supply voltage, via the VREF multiplexers shown in Figure 10.1.
FO
RM
The Reference Control Register 2, REF2CN (defined in Figure 10.2) enables/disables the internal reference generator
and selects the reference input for ADC2. The BIASE bit in REF2CN enables the on-board reference generator while
the REFBE bit enables the gain-of-two buffer amplifier which drives the VREF pin. When disabled, the supply current drawn by the bandgap and buffer amplifier falls to less than 1 µA (typical) and the output of the buffer amplifier
enters a high impedance state. If the internal bandgap is used as the reference voltage generator, BIASE and REFBE
must both be set to logic 1. If the internal reference is not used, REFBE may be set to logic 0. Note that the BIASE bit
must be set to logic 1 if ADC2 or either DAC is used, regardless of the voltage reference used. If neither ADC2 nor
the DACs are being used, both of these bits can be set to logic 0 to conserve power. Bit AD2VRS selects between
VREF2 and AV+ for the ADC2 voltage reference source. The electrical specifications for the Voltage Reference are
given in Table 10.1.
VDD
R
AD
VA
NC
External
Voltage
Reference
Circuit
AD2VRS
TEMPE
BIASE
REFBE
REF2CN
ED
IN
Figure 10.1. Voltage Reference Functional Block Diagram
ADC2
AV+
1
Ref
0
VREF2
DAC0
Ref
DAC1
BIASE
EN
VREF
x2
+
4.7µF
0.1µF
Bias to
ADC2,
DACs
1.2V
Band-Gap
REFBE
Recommended Bypass
Capacitors
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 109
Advanced
Information
C8051F060/1/2/3
N
The temperature sensor connects to the highest order input of the ADC2 input multiplexer (see Section “7. 10-Bit
ADC (ADC2)” on page 83). The TEMPE bit within REF2CN enables and disables the temperature sensor. While disabled, the temperature sensor defaults to a high impedance state, and any A/D measurements performed on the sensor
while disabled result in meaningless data.
IO
Figure 10.2. REF2CN: Reference Control Register 2
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
-
-
-
-
AD2VRS
TEMPE
BIASE
REFBE
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit1:
AT
IN
Bit0:
RM
Bit2:
UNUSED. Read = 0000b; Write = don’t care.
AD2VRS: ADC2 Voltage Reference Select.
0: ADC2 voltage reference from VREF2 pin.
1: ADC2 voltage reference from AV+.
TEMPE: Temperature Sensor Enable Bit.
0: Internal Temperature Sensor Off.
1: Internal Temperature Sensor On.
BIASE: ADC/DAC Bias Generator Enable Bit. (Must be ‘1’ if using ADC2 or DACs).
0: Internal Bias Generator Off.
1: Internal Bias Generator On.
REFBE: Internal Reference Buffer Enable Bit.
0: Internal Reference Buffer Off.
1: Internal Reference Buffer On. Internal voltage reference is driven on the VREF pin.
FO
Bits7-4:
Bit3:
Bit0
SFR Address: 0xD1
SFR Page: 2
ED
Table 10.1. Voltage Reference Electrical Characteristics
VDD = 3.0 V, AV+ = 3.0 V, -40°C to +85°C unless otherwise specified
PARAMETER
CONDITIONS
MIN
TYP
MAX
UNITS
2.36
2.43
2.48
V
30
mA
Output Voltage
VA
NC
INTERNAL REFERENCE (REFBE = 1)
25°C ambient
VREF Short-Circuit Current
VREF Temperature Coefficient
15
ppm/°C
0.5
ppm/µA
Load = 0 to 200 µA to AGND
VREF Turn-on Time 1
4.7µF tantalum, 0.1µF ceramic bypass
2
ms
VREF Turn-on Time 2
0.1µF ceramic bypass
20
µs
VREF Turn-on Time 3
no bypass cap
10
µs
AD
Load Regulation
EXTERNAL REFERENCE (REFBE = 0)
Input Voltage Range
Input Current
Page 110
1.00
0
(AV+) 0.3
V
1
µA
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
11.
C8051F060/1/2/3
COMPARATORS
IO
N
C8051F06x family of devices include three on-chip programmable voltage comparators, shown in Figure 11.1. Each
comparator offers programmable response time and hysteresis. When assigned to a Port pin, the Comparator output
may be configured as open drain or push-pull, and Comparator inputs should be configured as analog inputs (see Section “17.1.5. Configuring Port 1 and 2 pins as Analog Inputs” on page 195). The Comparator may also be used as
a reset source (see Section “13.5. Comparator0 Reset” on page 157).
RM
AT
The output of a Comparator can be polled by software, used as an interrupt source, used as a reset source, and/or
routed to a Port pin. Each comparator can be individually enabled and disabled (shutdown). When disabled, the Comparator output (if assigned to a Port I/O pin via the Crossbar) defaults to the logic low state, and its supply current
falls to less than 1 µA. See Section “17.1.1. Crossbar Pin Assignment and Allocation” on page 193 for details on
configuring the Comparator output via the digital Crossbar. The Comparator inputs can be externally driven from
-0.25 V to (VDD) + 0.25 V without damage or upset. The complete electrical specifications for the Comparator are
given in Table 11.1.
FO
Figure 11.1. Comparator Functional Block Diagram
VDD
CPnFIF
CPnHYP1
CPnHYP0
P2.4
P2.5
AD
CP2 +
CP2 -
P2.2
P2.3
CPn +
CPn -
CPTnMD
CP1 +
CP1 -
P2.6
P2.7
VA
NC
CP0 +
CP0 -
CPn
Rising-edge
Interrupt Flag
ED
CPnHYN1
CPnHYN0
Comparator Pin Assignments
CPn
Interrupt
IN
CPTnCN
CPnEN
CPnOUT
CPnRIF
CPn
Falling-edge
Interrupt Flag
Interrupt
Logic
+
D
-
SET
CLR
Q
Q
D
SET
CLR
Q
Q
CPn
Crossbar
(SYNCHRONIZER)
GND
Reset
Decision
Tree
CPnRIE
CPnFIE
CPnMD1
CPnMD0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 111
C8051F060/1/2/3
Advanced
Information
VIN-
CPn+
CPn-
+
CPn
_
AT
VIN+
IO
Figure 11.2. Comparator Hysteresis Plot
OUT
RM
CIRCUIT CONFIGURATION
Positive Hysteresis Voltage
(Programmed with CPnHYP Bits)
VIN-
FO
INPUTS
VOH
Negative Hysteresis Voltage
(Programmed by CPnHYN Bits)
IN
VIN+
OUTPUT
N
The Comparator response time may be configured in software using the CPnMD1-0 bits in register CPTnMD (see
Figure 11.4). Selecting a longer response time reduces the amount of power consumed by the comparator. See
Table 11.1 for complete timing and current consumption specifications.
ED
VOL
Maximum
Negative Hysteresis
Maximum
Positive Hysteresis
VA
NC
Positive Hysteresis
Disabled
Negative Hysteresis
Disabled
The hysteresis of the Comparator is software-programmable via its Comparator Control register (CPTnCN). The
user can program both the amount of hysteresis voltage (referred to the input voltage) and the positive and negativegoing symmetry of this hysteresis around the threshold voltage.
AD
The Comparator hysteresis is programmed using Bits3-0 in the Comparator Control Register CPTnCN (shown in
Figure 11.3). The amount of negative hysteresis voltage is determined by the settings of the CPnHYN bits. As shown
in Figure 11.2, the negative hysteresis can be programmed to three different settings, or negative hysteresis can be
disabled. In a similar way, the amount of positive hysteresis is determined by the setting the CPnHYP bits.
Page 112
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Comparator Inputs
RM
11.1.
AT
IO
N
Comparator interrupts can be generated on either rising-edge and falling-edge output transitions. (For Interrupt
enable and priority control, see Section “12.3. Interrupt Handler” on page 143). The rising and/or falling -edge
interrupts are enabled using the comparator’s Rising/Falling Edge Interrupt Enable Bits (CPnRIE and CPnFIE) in
their respective Comparator Mode Selection Register (CPTnMD), shown in Figure 11.4. These bits allow the user to
control which edge (or both) will cause a comparator interrupt. However, the comparator interrupt must also be
enabled in the Extended Interrupt Enable Register (EIE1). The CPnFIF flag is set to logic 1 upon a Comparator falling-edge interrupt, and the CPnRIF flag is set to logic 1 upon the Comparator rising-edge interrupt. Once set, these
bits remain set until cleared by software. The output state of a Comparator can be obtained at any time by reading the
CPnOUT bit. A Comparator is enabled by setting its respective CPnEN bit to logic 1, and is disabled by clearing this
bit to logic 0.Upon enabling a comparator, the output of the comparator is not immediately valid. Before using a comparator as an interrupt or reset source, software should wait for a minimum of the specified “Power-up time” as specified in Table 11.1, “Comparator Electrical Characteristics,” on page 116.
The Port pins selected as comparator inputs should be configured as analog inputs in the Port 2 Input Configuration
Register (for details on Port configuration, see Section “17.1.3. Configuring Port Pins as Digital Inputs” on
page 195). The inputs for Comparator are on Port 2 as follows:
PORT PIN
CP0 +
P2.6
CP0 -
P2.7
CP1 +
P2.2
IN
FO
COMPARATOR INPUT
CP1 -
P2.3
CP2 +
P2.4
P2.5
AD
VA
NC
ED
CP2 -
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 113
C8051F060/1/2/3
Advanced
Information
Figure 11.3. CPTnCN: Comparator 0, 1, and 2 Control Register
R/W
R/W
CPnRIF
CPnFIF
R/W
Bit7
Bit6
Bit5
Bit4
R/W
R/W
Bit3
Bit2
Bit1
Bit4:
RM
CPnEN: Comparator Enable Bit. (Please see note below.)
0: Comparator Disabled.
1: Comparator Enabled.
CPnOUT: Comparator Output State Flag.
0: Voltage on CPn+ < CPn-.
1: Voltage on CPn+ > CPn-.
CPnRIF: Comparator Rising-Edge Interrupt Flag.
0: No Comparator Rising Edge Interrupt has occurred since this flag was last cleared.
1: Comparator Rising Edge Interrupt has occurred. Must be cleared by software.
CPnFIF: Comparator Falling-Edge Interrupt Flag.
0: No Comparator Falling-Edge Interrupt has occurred since this flag was last cleared.
1: Comparator Falling-Edge Interrupt has occurred. Must be cleared by software.
CPnHYP1-0: Comparator Positive Hysteresis Control Bits.
00: Positive Hysteresis Disabled.
01: Positive Hysteresis = 5 mV.
10: Positive Hysteresis = 10 mV.
11: Positive Hysteresis = 20 mV.
CPnHYN1-0: Comparator Negative Hysteresis Control Bits.
00: Negative Hysteresis Disabled.
01: Negative Hysteresis = 5 mV.
10: Negative Hysteresis = 10 mV.
11: Negative Hysteresis = 20 mV.
Upon enabling a comparator, the output of the comparator is not immediately valid. Before using a
comparator as an interrupt or reset source, software should wait for a minimum of the specified
“Power-up time” as specified in Table 11.1, “Comparator Electrical Characteristics,” on page 116.
AD
NOTE:
VA
NC
Bits1-0:
ED
IN
Bits3-2:
Bit
Addressable
FO
Bit5:
Bit0
AT
SFR Pages: CPT0CN: page 1; CPT1CN: page 2; CPT2CN: page 3
Bit6:
Reset Value
CPnHYP1 CPnHYP0 CPnHYN1 CPnHYN0 00000000
SFR Address: CPT0CN: 0x88; CPT1CN: 0x88; CPT2CN: 0x88
Bit7:
R/W
N
R/W
CPnOUT
IO
R/W
CPnEN
Page 114
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 11.4. CPTnMD: Comparator Mode Selection Register
R/W
R/W
R
R
R/W
-
CPnRIE
CPnFIE
-
-
CPnMD1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
SFR Address: CPT0MD: 0x89; CPT1MD: 0x89; CPT2MD: 0x89
Bit0
RM
CPnMD1
0
0
1
1
CPnMD0
Notes
0
Fastest Response Time
1
0
1
Lowest Power Consumption
AD
VA
NC
ED
Mode
0
1
2
3
FO
Bits3-2:
Bits1-0:
Reset Value
00000000
IN
Bit 4:
UNUSED. Read = 00b, Write = don’t care.
CPnRIE: Comparator Rising-Edge Interrupt Enable Bit.
0: Comparator rising-edge interrupt disabled.
1: Comparator rising-edge interrupt enabled.
CPnFIE: Comparator Falling-Edge Interrupt Enable Bit.
0: Comparator falling-edge interrupt disabled.
1: Comparator falling-edge interrupt enabled.
UNUSED. Read = 00b, Write = don’t care.
CPnMD1-CPnMD0: Comparator Mode Select
These bits select the response time for the Comparator.
CPnMD0
AT
SFR Page: CPT0MD: page 1; CPT1MD: page 2; CPT2MD: page 3
Bits7-6:
Bit 5:
R/W
N
R/W
-
IO
R/W
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 115
C8051F060/1/2/3
Advanced
Information
Table 11.1. Comparator Electrical Characteristics
CONDITIONS
Response Time,
Mode 0
CPn+ - CPn- = 100 mV
Response Time,
Mode 1
CPn+ - CPn- = 100 mV
Response Time,
Mode 2
CPn+ - CPn- = 100 mV
Response Time,
Mode 3
CPn+ - CPn- = 100 mV
MIN
CPn+ - CPn- = 10 mV
UNITS
100
µs
250
µs
175
µs
500
µs
320
µs
1100
µs
1050
µs
5200
µs
1.5
4
mV/V
0
1
mV
3
5
7
mV
7
10
15
mV
15
20
25
mV
0
1
mV
CPnHYP1-0 = 00
Positive Hysteresis 2
CPnHYP1-0 = 01
Positive Hysteresis 3
CPnHYP1-0 = 10
Positive Hysteresis 4
CPnHYP1-0 = 11
Negative Hysteresis 1
CPnHYN1-0 = 00
Negative Hysteresis 2
CPnHYN1-0 = 01
3
5
7
mV
Negative Hysteresis 3
CPnHYN1-0 = 10
7
10
15
mV
Negative Hysteresis 4
CPnHYN1-0 = 11
15
20
25
mV
-0.25
VDD +
0.25
V
Inverting or Non-Inverting Input
Voltage Range
Input Capacitance
IN
VA
NC
Input Bias Current
FO
Positive Hysteresis 1
ED
RM
CPn+ - CPn- = 10 mV
Common-Mode Rejection Ratio
MAX
AT
CPn+ - CPn- = 10 mV
CPn+ - CPn- = 10 mV
TYP
IO
PARAMETER
N
VDD = 3.0 V, -40°C to +85°C unless otherwise specified.
Input Offset Voltage
7
-5
0.001
-5
pF
+5
nA
+5
mV
1
mV/V
POWER SUPPLY
Power Supply Rejection
0.1
Power-up Time
10
µs
Mode 0
7.6
µA
Mode 1
3.2
µA
Mode 2
1.3
µA
Mode 3
0.4
µA
AD
Supply Current at DC
Page 116
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
12.
C8051F060/1/2/3
CIP-51 MICROCONTROLLER
AT
IO
N
The MCU system controller core is the CIP-51 microcontroller. The CIP-51 is fully compatible with the MCS-51™
instruction set; standard 803x/805x assemblers and compilers can be used to develop software. The MCU family has
a superset of all the peripherals included with a standard 8051. Included are five 16-bit counter/timers (see description in Section 23), two full-duplex UARTs (see description in Section 21 and Section 22), 256 bytes of internal
RAM, 128 byte Special Function Register (SFR) address space (see Section 12.2.6), and 59/24 General-Purpose I/O
Pins (see description in Section 17). The CIP-51 also includes on-chip debug hardware (see description in Section
25), and interfaces directly with the MCU’s analog and digital subsystems providing a complete data acquisition or
control-system solution in a single integrated circuit.
The CIP-51 Microcontroller core implements the standard 8051 organization and peripherals as well as additional
custom peripherals and functions to extend its capability (see Figure 12.1 for a block diagram). The CIP-51 includes
the following features:
Extended Interrupt Handler
Reset Input
Power Management Modes
On-chip Debug Logic
Program and Data Memory Security
RM
-
Fully Compatible with MCS-51 Instruction Set
25 MIPS Peak Throughput with 25 MHz Clock
0 to 25 MHz Clock Frequency
256 Bytes of Internal RAM
59/24 General-Purpose I/O Pins
FO
-
Figure 12.1. CIP-51 Block Diagram
D8
D8
STACK POINTER
TMP2
SRAM
ADDRESS
REGISTER
PSW
ALU
D8
D8
VA
NC
SRAM
(256 X 8)
D8
TMP1
ED
B REGISTER
D8
DATA BUS
ACCUMULATOR
D8
IN
D8
D8
DATA BUS
DATA BUS
SFR_ADDRESS
BUFFER
D8
DATA POINTER
D8
D8
SFR
BUS
INTERFACE
SFR_CONTROL
SFR_WRITE_DATA
SFR_READ_DATA
DATA BUS
PC INCREMENTER
AD
PROGRAM COUNTER (PC)
PRGM. ADDRESS REG.
MEM_ADDRESS
D8
MEM_CONTROL
A16
MEMORY
INTERFACE
MEM_WRITE_DATA
MEM_READ_DATA
PIPELINE
RESET
D8
CONTROL
LOGIC
SYSTEM_IRQs
CLOCK
D8
STOP
IDLE
POWER CONTROL
REGISTER
INTERRUPT
INTERFACE
DEBUG_IRQ
D8
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 117
Advanced
Information
C8051F060/1/2/3
N
Performance
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, and usually have a maximum system clock of 12 MHz. By contrast, the CIP-51 core executes 70% of its instructions in one or two system clock cycles, with no instructions taking more than eight system clock cycles.
1
2
2/3
3
3/4
Number of Instructions
26
50
5
14
7
4
AT
Clocks to Execute
IO
With the CIP-51's maximum system clock at 25 MHz, it has a peak throughput of 25 MIPS. The CIP-51 has a total of
109 instructions. The table below shows the total number of instructions that require each execution time.
3
4/5
5
8
1
2
1
RM
Programming and Debugging Support
A JTAG-based serial interface is provided for in-system programming of the FLASH program memory and communication with on-chip debug support logic. The re-programmable FLASH can also be read and changed a single byte
at a time by the application software using the MOVC and MOVX instructions. This feature allows program memory
to be used for non-volatile data storage as well as updating program code under software control.
IN
FO
The on-chip debug support logic facilitates full speed in-circuit debugging, allowing the setting of hardware breakpoints and watch points, starting, stopping and single stepping through program execution (including interrupt service
routines), examination of the program's call stack, and reading/writing the contents of registers and memory. This
method of on-chip debug is completely non-intrusive and non-invasive, requiring no RAM, Stack, timers, or other
on-chip resources.
12.1.
Instruction Set
ED
The CIP-51 is supported by development tools from Cygnal Integrated Products and third party vendors. Cygnal provides an integrated development environment (IDE) including editor, macro assembler, debugger and programmer.
The IDE's debugger and programmer interface to the CIP-51 via its JTAG interface to provide fast and efficient insystem device programming and debugging. Third party macro assemblers and C compilers are also available.
VA
NC
The instruction set of the CIP-51 System Controller is fully compatible with the standard MCS-51™ instruction set;
standard 8051 development tools can be used to develop software for the CIP-51. All CIP-51 instructions are the
binary and functional equivalent of their MCS-51™ counterparts, including opcodes, addressing modes and effect on
PSW flags. However, instruction timing is different than that of the standard 8051.
12.1.1. Instruction and CPU Timing
AD
In many 8051 implementations, a distinction is made between machine cycles and clock cycles, with machine cycles
varying from 2 to 12 clock cycles in length. However, the CIP-51 implementation is based solely on clock cycle timing. All instruction timings are specified in terms of clock cycles.
Due to the pipelined architecture of the CIP-51, most instructions execute in the same number of clock cycles as there
are program bytes in the instruction. Conditional branch instructions take one less clock cycle to complete when the
branch is not taken as opposed to when the branch is taken. Table 12.1 is the CIP-51 Instruction Set Summary, which
includes the mnemonic, number of bytes, and number of clock cycles for each instruction.
12.1.2. MOVX Instruction and Program Memory
In the CIP-51, the MOVX instruction serves three purposes: accessing on-chip XRAM, accessing off-chip XRAM,
and accessing on-chip program FLASH memory. The FLASH access feature provides a mechanism for user software
to update program code and use the program memory space for non-volatile data storage (see Section “15. FLASH
Page 118
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Description
AT
RM
FO
IN
VA
NC
ADD A, Rn
ADD A, direct
ADD A, @Ri
ADD A, #data
ADDC A, Rn
ADDC A, direct
ADDC A, @Ri
ADDC A, #data
SUBB A, Rn
SUBB A, direct
SUBB A, @Ri
SUBB A, #data
INC A
INC Rn
INC direct
INC @Ri
DEC A
DEC Rn
DEC direct
DEC @Ri
INC DPTR
MUL AB
DIV AB
DA A
ARITHMETIC OPERATIONS
Add register to A
Add direct byte to A
Add indirect RAM to A
Add immediate to A
Add register to A with carry
Add direct byte to A with carry
Add indirect RAM to A with carry
Add immediate to A with carry
Subtract register from A with borrow
Subtract direct byte from A with borrow
Subtract indirect RAM from A with borrow
Subtract immediate from A with borrow
Increment A
Increment register
Increment direct byte
Increment indirect RAM
Decrement A
Decrement register
Decrement direct byte
Decrement indirect RAM
Increment Data Pointer
Multiply A and B
Divide A by B
Decimal adjust A
LOGICAL OPERATIONS
AND Register to A
AND direct byte to A
AND indirect RAM to A
AND immediate to A
AND A to direct byte
AND immediate to direct byte
OR Register to A
OR direct byte to A
OR indirect RAM to A
OR immediate to A
OR A to direct byte
OR immediate to direct byte
Exclusive-OR Register to A
Exclusive-OR direct byte to A
Exclusive-OR indirect RAM to A
ED
Mnemonic
AD
ANL A, Rn
ANL A, direct
ANL A, @Ri
ANL A, #data
ANL direct, A
ANL direct, #data
ORL A, Rn
ORL A, direct
ORL A, @Ri
ORL A, #data
ORL direct, A
ORL direct, #data
XRL A, Rn
XRL A, direct
XRL A, @Ri
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Bytes
Clock
Cycles
1
2
1
2
1
2
1
2
1
2
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
2
2
2
1
2
2
2
1
2
2
2
1
1
2
2
1
1
2
2
1
4
8
1
1
2
1
2
2
3
1
2
1
2
2
3
1
2
1
1
2
2
2
2
3
1
2
2
2
2
3
1
2
2
IO
Table 12.1. CIP-51 Instruction Set Summary
N
MEMORY” on page 167). The External Memory Interface provides a fast access to off-chip XRAM (or memorymapped peripherals) via the MOVX instruction. Refer to Section “16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM” on page 175 for details.
Page 119
C8051F060/1/2/3
Advanced
Information
Table 12.1. CIP-51 Instruction Set Summary
Exclusive-OR immediate to A
Exclusive-OR A to direct byte
Exclusive-OR immediate to direct byte
Clear A
Complement A
Rotate A left
Rotate A left through Carry
Rotate A right
Rotate A right through Carry
Swap nibbles of A
DATA TRANSFER
Move Register to A
Move direct byte to A
Move indirect RAM to A
Move immediate to A
Move A to Register
Move direct byte to Register
Move immediate to Register
Move A to direct byte
Move Register to direct byte
Move direct byte to direct byte
Move indirect RAM to direct byte
Move immediate to direct byte
Move A to indirect RAM
Move direct byte to indirect RAM
Move immediate to indirect RAM
Load DPTR with 16-bit constant
Move code byte relative DPTR to A
Move code byte relative PC to A
Move external data (8-bit address) to A
Move A to external data (8-bit address)
Move external data (16-bit address) to A
Move A to external data (16-bit address)
Push direct byte onto stack
Pop direct byte from stack
Exchange Register with A
Exchange direct byte with A
Exchange indirect RAM with A
Exchange low nibble of indirect RAM with A
BOOLEAN MANIPULATION
Clear Carry
Clear direct bit
Set Carry
Set direct bit
Complement Carry
AD
RM
FO
IN
ED
VA
NC
MOV A, Rn
MOV A, direct
MOV A, @Ri
MOV A, #data
MOV Rn, A
MOV Rn, direct
MOV Rn, #data
MOV direct, A
MOV direct, Rn
MOV direct, direct
MOV direct, @Ri
MOV direct, #data
MOV @Ri, A
MOV @Ri, direct
MOV @Ri, #data
MOV DPTR, #data16
MOVC A, @A+DPTR
MOVC A, @A+PC
MOVX A, @Ri
MOVX @Ri, A
MOVX A, @DPTR
MOVX @DPTR, A
PUSH direct
POP direct
XCH A, Rn
XCH A, direct
XCH A, @Ri
XCHD A, @Ri
CLR C
CLR bit
SETB C
SETB bit
CPL C
Page 120
2
2
3
1
1
1
1
1
1
1
1
2
1
2
1
2
2
2
2
3
2
3
1
2
2
3
1
1
1
1
1
1
2
2
1
2
1
1
1
2
2
2
1
2
2
2
2
3
2
3
2
2
2
3
3
3
3
3
3
3
2
2
1
2
2
2
1
2
1
2
1
1
2
1
2
1
N
XRL A, #data
XRL direct, A
XRL direct, #data
CLR A
CPL A
RL A
RLC A
RR A
RRC A
SWAP A
Clock
Cycles
2
2
3
1
1
1
1
1
1
1
Bytes
IO
Description
AT
Mnemonic
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 12.1. CIP-51 Instruction Set Summary
CPL bit
ANL C, bit
ANL C, /bit
ORL C, bit
ORL C, /bit
MOV C, bit
MOV bit, C
JC rel
JNC rel
JB bit, rel
JNB bit, rel
JBC bit, rel
Complement direct bit
AND direct bit to Carry
AND complement of direct bit to Carry
OR direct bit to carry
OR complement of direct bit to Carry
Move direct bit to Carry
Move Carry to direct bit
Jump if Carry is set
Jump if Carry is not set
Jump if direct bit is set
Jump if direct bit is not set
Jump if direct bit is set and clear bit
PROGRAM BRANCHING
Absolute subroutine call
Long subroutine call
Return from subroutine
Return from interrupt
Absolute jump
Long jump
Short jump (relative address)
Jump indirect relative to DPTR
Jump if A equals zero
Jump if A does not equal zero
Compare direct byte to A and jump if not equal
Compare immediate to A and jump if not equal
Compare immediate to Register and jump if not equal
Compare immediate to indirect and jump if not equal
Decrement Register and jump if not zero
Decrement direct byte and jump if not zero
No operation
2
3
1
1
2
3
2
1
2
2
3
3
3
3
2
3
1
3
4
5
5
3
4
3
3
2/3
2/3
3/4
3/4
3/4
4/5
2/3
3/4
1
AT
RM
FO
IN
ED
AD
VA
NC
ACALL addr11
LCALL addr16
RET
RETI
AJMP addr11
LJMP addr16
SJMP rel
JMP @A+DPTR
JZ rel
JNZ rel
CJNE A, direct, rel
CJNE A, #data, rel
CJNE Rn, #data, rel
CJNE @Ri, #data, rel
DJNZ Rn, rel
DJNZ direct, rel
NOP
2
2
2
2
2
2
2
2
2
3
3
3
Clock
Cycles
2
2
2
2
2
2
2
2/3
2/3
3/4
3/4
3/4
Bytes
N
Description
IO
Mnemonic
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 121
C8051F060/1/2/3
Advanced
Information
Notes on Registers, Operands and Addressing Modes:
N
Rn - Register R0-R7 of the currently selected register bank.
IO
@Ri - Data RAM location addressed indirectly through R0 or R1.
AT
rel - 8-bit, signed (two’s complement) offset relative to the first byte of the following instruction. Used by SJMP
and all conditional jumps.
direct - 8-bit internal data location’s address. This could be a direct-access Data RAM location (0x00-0x7F) or an
SFR (0x80-0xFF).
RM
#data - 8-bit constant
#data16 - 16-bit constant
FO
bit - Direct-accessed bit in Data RAM or SFR
addr11 - 11-bit destination address used by ACALL and AJMP. The destination must be within the same 2K-byte
page of program memory as the first byte of the following instruction.
IN
addr16 - 16-bit destination address used by LCALL and LJMP. The destination may be anywhere within the 64Kbyte program memory space.
AD
VA
NC
ED
There is one unused opcode (0xA5) that performs the same function as NOP.
All mnemonics copyrighted © Intel Corporation 1980.
Page 122
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
12.2.
C8051F060/1/2/3
Memory Organization
IO
N
The memory organization of the CIP-51 System Controller is similar to that of a standard 8051. There are two separate memory spaces: program memory and data memory. Program and data memory share the same address space but
are accessed via different instruction types. There are 256 bytes of internal data memory and 64k bytes of internal
program memory address space implemented within the CIP-51. The CIP-51 memory organization is shown in
Figure 12.2.
Figure 12.2. Memory Map
Upper 128 RAM
(Indirect Addressing
Only)
0x80
0x7F
RESERVED
Special Function
Registers
(Direct Addressing Only)
RM
0xFC00
0xFBFF
0xFF
Scrachpad Memory
(DATA only)
(Direct and Indirect
Addressing)
0x30
0x2F
0x20
0x1F
0x00
FLASH
(In-System
Programmable in 512
Byte Sectors)
Bit Addressable
Lower 128 RAM
(Direct and Indirect
Addressing)
0
1
2
3
Up To
256 SFR Pages
FO
0x1007F
0x10000
0xFFFF
AT
DATA MEMORY (RAM)
INTERNAL DATA ADDRESS SPACE
PROGRAM/DATA MEMORY
(FLASH)
General Purpose
Registers
EXTERNAL DATA ADDRESS SPACE
IN
0x0000
ED
0xFFFF
Off-chip XRAM space
(C8051F060/2 Only)
0x1000
VA
NC
0x0FFF
0x0000
XRAM - 4096 Bytes
(accessable using MOVX
instruction)
12.2.1. Program Memory
AD
The CIP-51 has a 64k byte program memory space. The MCU implements 65536 bytes of this program memory
space as in-system re-programmed FLASH memory, organized in a contiguous block from addresses 0x0000 to
0xFFFF. Note: 1024 bytes (0xFC00 to 0xFFFF) of this memory are reserved, and are not available for user program
storage.
Program memory is normally assumed to be read-only. However, the CIP-51 can write to program memory by setting
the Program Store Write Enable bit (PSCTL.0) and using the MOVX instruction. This feature provides a mechanism
for the CIP-51 to update program code and use the program memory space for non-volatile data storage. Refer to Section “15. FLASH MEMORY” on page 167 for further details.
12.2.2. Data Memory
The CIP-51 implements 256 bytes of internal RAM mapped into the data memory space from 0x00 through 0xFF.
The lower 128 bytes of data memory are used for general purpose registers and scratch pad memory. Either direct or
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 123
C8051F060/1/2/3
Advanced
Information
N
indirect addressing may be used to access the lower 128 bytes of data memory. Locations 0x00 through 0x1F are
addressable as four banks of general purpose registers, each bank consisting of eight byte-wide registers. The next
16 bytes, locations 0x20 through 0x2F, may either be addressed as bytes or as 128 bit locations accessible with the
direct addressing mode.
AT
IO
The upper 128 bytes of data memory are accessible only by indirect addressing. This region occupies the same
address space as the Special Function Registers (SFR) but is physically separate from the SFR space. The addressing
mode used by an instruction when accessing locations above 0x7F determines whether the CPU accesses the upper
128 bytes of data memory space or the SFR’s. Instructions that use direct addressing will access the SFR space.
Instructions using indirect addressing above 0x7F access the upper 128 bytes of data memory. Figure 12.2 illustrates
the data memory organization of the CIP-51.
12.2.3. General Purpose Registers
RM
The lower 32 bytes of data memory, locations 0x00 through 0x1F, may be addressed as four banks of general-purpose
registers. Each bank consists of eight byte-wide registers designated R0 through R7. Only one of these banks may be
enabled at a time. Two bits in the program status word, RS0 (PSW.3) and RS1 (PSW.4), select the active register bank
(see description of the PSW in Figure 12.16). This allows fast context switching when entering subroutines and interrupt service routines. Indirect addressing modes use registers R0 and R1 as index registers.
FO
12.2.4. Bit Addressable Locations
IN
In addition to direct access to data memory organized as bytes, the sixteen data memory locations at 0x20 through
0x2F are also accessible as 128 individually addressable bits. Each bit has a bit address from 0x00 to 0x7F. Bit 0 of
the byte at 0x20 has bit address 0x00 while bit 7 of the byte at 0x20 has bit address 0x07. Bit 7 of the byte at 0x2F has
bit address 0x7F. A bit access is distinguished from a full byte access by the type of instruction used (bit source or
destination operands as opposed to a byte source or destination).
MOV
C, 22.3h
ED
The MCS-51™ assembly language allows an alternate notation for bit addressing of the form XX.B where XX is the
byte address and B is the bit position within the byte. For example, the instruction:
12.2.5. Stack
VA
NC
moves the Boolean value at 0x13 (bit 3 of the byte at location 0x22) into the Carry flag.
AD
A programmer's stack can be located anywhere in the 256 byte data memory. The stack area is designated using the
Stack Pointer (SP, address 0x81) SFR. The SP will point to the last location used. The next value pushed on the stack
is placed at SP+1 and then SP is incremented. A reset initializes the stack pointer to location 0x07; therefore, the first
value pushed on the stack is placed at location 0x08, which is also the first register (R0) of register bank 1. Thus, if
more than one register bank is to be used, the SP should be initialized to a location in the data memory not being used
for data storage. The stack depth can extend up to 256 bytes.
The MCUs also have built-in hardware for a stack record which is accessed by the debug logic. The stack record is a
32-bit shift register, where each PUSH or increment SP pushes one record bit onto the register, and each CALL
pushes two record bits onto the register. (A POP or decrement SP pops one record bit, and a RET pops two record
bits, also.) The stack record circuitry can also detect an overflow or underflow on the 32-bit shift register, and can
notify the debug software even with the MCU running at speed.
Page 124
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
12.2.6. Special Function Registers
IO
N
The direct-access data memory locations from 0x80 to 0xFF constitute the special function registers (SFR’s). The
SFR’s provide control and data exchange with the CIP-51's resources and peripherals. The CIP-51 duplicates the
SFR’s found in a typical 8051 implementation as well as implementing additional SFR’s used to configure and access
the sub-systems unique to the MCU. This allows the addition of new functionality while retaining compatibility with
the MCS-51™ instruction set. Table 12.2 lists the SFR’s implemented in the CIP-51 System Controller.
AT
The SFR registers are accessed whenever the direct addressing mode is used to access memory locations from 0x80
to 0xFF. SFR’s with addresses ending in 0x0 or 0x8 (e.g. P0, TCON, P1, SCON, IE, etc.) are bit-addressable as well
as byte-addressable. All other SFR’s are byte-addressable only. Unoccupied addresses in the SFR space are reserved
for future use. Accessing these areas will have an indeterminate effect and should be avoided. Refer to the corresponding pages of the datasheet, as indicated in Table 12.3, for a detailed description of each register.
RM
12.2.6.1. SFR Paging
Select the appropriate SFR page number using the SFRPAGE register.
Use direct accessing mode to read or write the special function register (MOV instruction).
12.2.6.2. Interrupts and SFR Paging
IN
1.
2.
FO
The CIP-51 features SFR paging, allowing the device to map many SFR’s into the 0x80 to 0xFF memory address
space. The SFR memory space has 256 pages. In this way, each memory location from 0x80 to 0xFF can access up to
256 SFR’s. The C8051F06x family of devices utilizes five SFR pages: 0, 1, 2, 3, and F. SFR pages are selected using
the Special Function Register Page Selection register, SFRPAGE (see Figure 12.10). The procedure for reading and
writing an SFR is as follows:
AD
VA
NC
ED
When an interrupt occurs, the SFR Page Register will automatically switch to the SFR page containing the flag bit
that caused the interrupt. The automatic SFR Page switch function conveniently removes the burden of switching
SFR pages from the interrupt service routine. Upon execution of the RETI instruction, the SFR page is automatically
restored to the SFR Page in use prior to the interrupt. This is accomplished via a three-byte SFR Page Stack. The top
byte of the stack is SFRPAGE, the current SFR Page. The second byte of the SFR Page Stack is SFRNEXT. The third,
or bottom byte of the SFR Page Stack is SFRLAST. On interrupt, the current SFRPAGE value is pushed to the SFRNEXT byte, and the value of SFRNEXT is pushed to SFRLAST. Hardware then loads SFRPAGE with the SFR Page
containing the flag bit associated with the interrupt. On a return from interrupt, the SFR Page Stack is popped resulting in the value of SFRNEXT returning to the SFRPAGE register, thereby restoring the SFR page context without
software intervention. The value in SFRLAST (0x00 if there is no SFR Page value in the bottom of the stack) of the
stack is placed in SFRNEXT register. If desired, the values stored in SFRNEXT and SFRLAST may be modified during an interrupt, enabling the CPU to return to a different SFR Page upon execution of the RETI instruction (on interrupt exit). Modifying registers in the SFR Page Stack does not cause a push or pop of the stack. Only interrupt calls
and returns will cause push/pop operations on the SFR Page Stack.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 125
Advanced
Information
C8051F060/1/2/3
Figure 12.3. SFR Page Stack
Interrupt
Logic
AT
SFRPAGE
IO
N
SFRPGCN Bit
RM
CIP-51
SFRNEXT
FO
SFRLAST
IN
Automatic hardware switching of the SFR Page on interrupts may be enabled or disabled as desired using the SFR
Automatic Page Control Enable Bit located in the SFR Page Control Register (SFRPGCN). This function defaults to
‘enabled’ upon reset. In this way, the autoswitching function will be enabled unless disabled in software.
AD
VA
NC
ED
A summary of the SFR locations (address and SFR page) is provided in Table 12.2. in the form of an SFR memory
map. Each memory location in the map has an SFR page row, denoting the page in which that SFR resides. Note that
certain SFR’s are accessible from ALL SFR pages, and are denoted by the “(ALL PAGES)” designation. For example, the Port I/O registers P0, P1, P2, and P3 all have the “(ALL PAGES)” designation, indicating these SFR’s are
accessible from all SFR pages regardless of the SFRPAGE register value.
Page 126
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
12.2.6.3. SFR Page Stack Example
The following is an example that shows the operation of the SFR Page Stack during interrupts.
AT
IO
N
In this example, the SFR Page Control is left in the default enabled state (i.e., SFRPGEN = 1), and the CIP-51 is executing in-line code that is writing values to Port 5 (SFR “P5”, located at address 0xD8 on SFR Page 0x0F). The
device is also using the Programmable Counter Array (PCA) and the 10-bit ADC (ADC2) window comparator to
monitor a voltage. The PCA is timing a critical control function in its interrupt service routine (ISR), so its interrupt is
enabled and is set to high priority. The ADC2 is monitoring a voltage that is less important, but to minimize the software overhead its window comparator is being used with an associated ISR that is set to low priority. At this point, the
SFR page is set to access the Port 5 SFR (SFRPAGE = 0x0F). See Figure 12.4 below.
RM
Figure 12.4. SFR Page Stack While Using SFR Page 0x0F To Access Port 5
SFR Page
Stack SFR's
SFRPAGE
SFRNEXT
SFRLAST
AD
VA
NC
ED
IN
(Port 5)
FO
0x0F
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 127
C8051F060/1/2/3
Advanced
Information
IO
N
While CIP-51 executes in-line code (writing values to Port 5 in this example), ADC2 Window Comparator Interrupt
occurs. The CIP-51 vectors to the ADC2 Window Comparator ISR and pushes the current SFR Page value (SFR Page
0x0F) into SFRNEXT in the SFR Page Stack. The SFR page needed to access ADC2’s SFR’s is then automatically
placed in the SFRPAGE register (SFR Page 0x02). SFRPAGE is considered the “top” of the SFR Page Stack. Software can now access the ADC2 SFR’s. Software may switch to any SFR Page by writing a new value to the
SFRPAGE register at any time during the ADC2 ISR to access SFR’s that are not on SFR Page 0x02. See Figure 12.5
below.
FO
0x02
RM
SFR Page 0x02
Automatically
pushed on stack in
SFRPAGE on ADC2
interrupt
AT
Figure 12.5. SFR Page Stack After ADC2 Window Comparator Interrupt Occurs
SFRPAGE
(ADC2)
SFRPAGE
pushed to
SFRNEXT
IN
0x0F
SFRNEXT
SFRLAST
AD
VA
NC
ED
(Port 5)
Page 128
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
AT
IO
N
While in the ADC2 ISR, a PCA interrupt occurs. Recall the PCA interrupt is configured as a high priority interrupt,
while the ADC2 interrupt is configured as a low priority interrupt. Thus, the CIP-51 will now vector to the high priority PCA ISR. Upon doing so, the CIP-51 will automatically place the SFR page needed to access the PCA’s special
function registers into the SFRPAGE register, SFR Page 0x00. The value that was in the SFRPAGE register before
the PCA interrupt (SFR Page 2 for ADC2) is pushed down the stack into SFRNEXT. Likewise, the value that was in
the SFRNEXT register before the PCA interrupt (in this case SFR Page 0x0F for Port 5) is pushed down to the SFRLAST register, the “bottom” of the stack. Note that a value stored in SFRLAST (via a previous software write to the
SFRLAST register) will be overwritten. See Figure 12.6 below.
SFR Page 0x00
Automatically
pushed on stack in
SFRPAGE on PCA
interrupt
FO
0x00
SFRPAGE
(PCA)
SFRPAGE
pushed to
SFRNEXT
IN
0x02
SFRNEXT
(ADC2)
0x0F
ED
SFRNEXT
pushed to
SFRLAST
RM
Figure 12.6. SFR Page Stack Upon PCA Interrupt Occurring During an ADC2 ISR
SFRLAST
AD
VA
NC
(Port 5)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 129
C8051F060/1/2/3
Advanced
Information
IO
N
On exit from the PCA interrupt service routine, the CIP-51 will return to the ADC2 Window Comparator ISR. On
execution of the RETI instruction, SFR Page 0x00 used to access the PCA registers will be automatically popped off
of the SFR Page Stack, and the contents of the SFRNEXT register will be moved to the SFRPAGE register. Software
in the ADC2 ISR can continue to access SFR’s as it did prior to the PCA interrupt. Likewise, the contents of SFRLAST are moved to the SFRNEXT register. Recall this was the SFR Page value 0x0F being used to access Port 5
before the ADC2 interrupt occurred. See Figure 12.7 below.
0x02
FO
(ADC2)
RM
SFR Page 0x00
Automatically
popped off of the
stack on return from
interrupt
AT
Figure 12.7. SFR Page Stack Upon Return From PCA Interrupt
SFRNEXT
popped to
SFRPAGE
SFRPAGE
0x0F
IN
SFRNEXT
(Port 5)
SFRLAST
AD
VA
NC
ED
SFRLAST
popped to
SFRNEXT
Page 130
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
N
On the execution of the RETI instruction in the ADC2 Window Comparator ISR, the value in SFRPAGE register is
overwritten with the contents of SFRNEXT. The CIP-51 may now access the Port 5 SFR bits as it did prior to the
interrupts occurring. See Figure 12.8 below.
IO
Figure 12.8. SFR Page Stack Upon Return From ADC2 Window Interrupt
AT
SFR Page 0x02
Automatically
popped off of the
stack on return from
interrupt
(Port 5)
SFRPAGE
SFRNEXT
SFRLAST
ED
IN
FO
SFRNEXT
popped to
SFRPAGE
RM
0x0F
VA
NC
Note that in the above example, all three bytes in the SFR Page Stack are accessible via the SFRPAGE, SFRNEXT,
and SFRLAST special function registers. If the stack is altered while servicing an interrupt, it is possible to return to
a different SFR Page upon interrupt exit than selected prior to the interrupt call. Direct access to the SFR Page stack
can be useful to enable real-time operating systems to control and manage context switching between multiple tasks.
AD
Push operations on the SFR Page Stack only occur on interrupt service, and pop operations only occur on interrupt
exit (execution on the RETI instruction). The automatic switching of the SFRPAGE and operation of the SFR Page
Stack as described above can be disabled in software by clearing the SFR Automatic Page Enable Bit (SFRPGEN) in
the SFR Page Control Register (SFRPGCN). See Figure 12.9.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 131
Advanced
Information
C8051F060/1/2/3
Figure 12.9. SFRPGCN: SFR Page Control Register
R/W
R/W
R/W
R/W
R/W
R/W
-
-
-
-
-
-
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Reset Value
SFRPGEN 00000001
Bit0
IO
Bit7
R/W
N
R/W
SFR Address: 0x96
SFR Page: F
AT
Reserved.
SFRPGEN: SFR Automatic Page Control Enable.
Upon interrupt, the C8051 Core will vector to the specified interrupt service routine and automatically switch the SFR page to the corresponding peripheral or function’s SFR page. This bit is used to
control this autopaging function.
0: SFR Automatic Paging disabled. C8051 core will not automatically change to the appropriate SFR
page (i.e., the SFR page that contains the SFR’s for the peripheral/function that was the source of the
interrupt).
1: SFR Automatic Paging enabled. Upon interrupt, the C8051 will switch the SFR page to the page
that contains the SFR’s for the peripheral or function that is the source of the interrupt.
FO
RM
Bits7-1:
Bit0:
IN
Figure 12.10. SFRPAGE: SFR Page Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
00000000
SFR Address: 0x84
SFR Page: All Pages
SFR Page Bits: Byte Represents the SFR Page the C8051 MCU uses when reading or modifying
SFR’s.
Write: Sets the SFR Page.
Read: Byte is the SFR page the C8051 MCU is using.
VA
NC
Bits7-0:
ED
R/W
AD
When enabled in the SFR Page Control Register (SFRPGEN), the C8051 will automatically switch to
the SFR Page that contains the SFR’s of the corresponding peripheral/function that caused the interrupt, and return to the previous SFR page upon return from interrupt (unless SFR Stack was altered
before a returning from the interrupt).
SFRPAGE is the top byte of the SFR Page Stack, and push/pop events of this stack are caused by
interrupts (and not by reading/writing to the SFRPAGE register)
Page 132
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.11. SFRNEXT: SFR Next Register
Bit6
R/W
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
Bit2
Bit1
R/W
N
Bit7
R/W
Reset Value
00000000
Bit0
IO
R/W
SFR Address: 0x85
SFR Page: All Pages
AT
SFR Page Stack Bits: SFR page context is retained upon interrupts/return from interrupts in a 3 byte
SFR Page Stack: SFRPAGE is the first entry, SFRNEXT is the second, and SFRLAST is the third
entry. The SFR stack bytes may be used to alter the context in the SFR Page Stack, and will not cause
the stack to ‘push’ or ‘pop’. Only interrupts and return from interrupt cause push and pop the SFR
Page Stack.
Write: Sets the SFR Page contained in the second byte of the SFR Stack. This will cause the
SFRPAGE SFR to have this SFR page value upon a return from interrupt.
Read: Returns the value of the SFR page contained in the second byte of the SFR stack. This is the
value that will go to the SFR Page register upon a return from interrupt.
IN
FO
RM
Bits7-0:
Figure 12.12. SFRLAST: SFR Last Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x86
SFR Page: All Pages
SFR Page Stack Bits: SFR page context is retained upon interrupts/return from interrupts in a 3 byte
SFR Page Stack: SFRPAGE is the first entry, SFRNEXT is the second, and SFRLAST is the third
entry. The SFR stack bytes may be used to alter the context in the SFR Page Stack, and will not cause
the stack to ‘push’ or ‘pop’. Only interrupts and return from interrupt cause push and pop the SFR
Page Stack.
Write:
Sets the SFR Page in the last entry of the SFR Stack. This will cause the SFRNEXT SFR to have this
SFR page value upon a return from interrupt.
Read:
Returns the value of the SFR page contained in the last entry of the SFR stack.
AD
Bits7-0:
Bit6
VA
NC
Bit7
ED
00000000
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 133
Advanced
Information
C8051F060/1/2/3
Table 12.2. Special Function Register (SFR) Memory Map
F8
1(9)
2(A)
3(B)
4(C)
5(D)
SPI0CN
CAN0CN
PCA0L
PCA0H
PCA0CPL0
PCA0CPH0
PCA0CPL1
DMA0CF
P7
DMA0CTL
DMA0CTH
DMA0CSL
DMA0CSH
D0
C8
C0
B8
0(8)
Page 134
1(9)
DMA0BND
PCA0CPL4
FO
PCA0CPH3
PCA0CPH5
7(F)
PCA0CPH1
WDTCN
(ALL PAGES)
DMA0ISW
EIP1
EIP2
(ALL PAGES) (ALL PAGES)
PCA0CPH4
RSTSRC
EIE1
EIE2
(ALL PAGES) (ALL PAGES)
IN
D8
PCA0CPL3
XBR1
XBR2
XBR3
PCA0CPM0 PCA0CPM1 PCA0CPM2 PCA0CPM3 PCA0CPM4 PCA0CPM5
CAN0ADR CAN0TST
DMA0DAH
DMA0DSL
DMA0DSH
DAC0L
DAC1L
DAC0H
DAC1H
DAC0CN
DAC1CN
RCAP2L
RCAP3L
RCAP4L
RCAP2H
RCAP3H
RCAP4H
TMR2L
TMR3L
TMR4L
TMR2H
TMR3H
TMR4H
SMB0DAT
SMB0ADR
ADC0GTL
ADC0GTH
ADC0LTL
ADC0LTH
ADC2GTL
ADC2GTH
ADC2LTL
ADC2LTH
ADC0L
ADC1L
ADC2L
ADC0H
ADC1H
ADC2H
6(E)
7(F)
ED
E0
PCA0CPH2
VA
NC
E8
AD
F0
RM
0
1
B
2
(ALL PAGES)
3
F
0
ADC0CN
PCA0CPL2
1
ADC1CN
2
ADC2CN
3
F
P6
0
PCA0CPL5
1
ACC
2
(ALL PAGES)
3
F
XBR0
0
PCA0CN
PCA0MD
1 CAN0DATL CAN0DATH
2
3
DMA0CN DMA0DAL
F
P5
0
REF0CN
1
REF1CN
PSW
2
REF2CN
(ALL PAGES)
3
F
0
TMR2CN
TMR2CF
1
TMR3CN
TMR3CF
2
TMR4CN
TMR4CF
3
F
P4
0
SMB0CN
SMB0STA
1
CAN0STA
2
3
F
0
SADEN0
1
IP
2
(ALL PAGES)
3
F
6(E)
N
0
1
2
3
F
0(8)
IO
SFR
P
A
G
E
AT
A
D
D
R
E
S
S
AMX0SL
AMX2CF
AMX2SL
ADC0CPT
ADC0CCF
2(A)
3(B)
DMA0IPT
ADC0CF
ADC1CF
ADC2CF
4(C)
5(D)
DMA0IDT
SMB0CR
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 12.2. Special Function Register (SFR) Memory Map
FLSCL
0
1
A8 2
N
SADDR0
0
IE
(ALL PAGES)
3
F
0
1
2
3
F
SSTA0
TCON
CPT0CN
CPT1CN
CPT2CN
TMOD
CPT0MD
CPT1MD
CPT2MD
TL0
OSCICN
0
P6MDOUT
P7MDOUT
TL1
TH0
TH1
SFRPGCN
CKCON
CLKSEL
PSCTL
OSCICL
OSCXCN
1
P0
SP
DPL
DPH
SFRPAGE
SFRNEXT
SFRLAST
PCON
2
(ALL PAGES) (ALL PAGES) (ALL PAGES) (ALL PAGES) (ALL PAGES) (ALL PAGES) (ALL PAGES) (ALL PAGES)
3
F
VA
NC
80
P5MDOUT
IN
88
P4MDOUT
SPI0DAT
1
P1
2
(ALL PAGES)
3
F
0
1
2
3
F
P3MDOUT
SPI0CFG
P0MDOUT
SCON0
SCON1
0
90
P2MDOUT
SBUF0
SBUF1
P2
(ALL PAGES)
ED
98
P1MDOUT
SPI0CKR
EMI0CF
RM
3
F
P2MDIN
EMI0CN
FO
1
A0 2
P1MDIN
EMI0TC
AT
0
FLACL
IO
B0
1
P3
2
(ALL PAGES)
3
F
0(8)
1(9)
2(A)
3(B)
4(C)
5(D)
6(E)
7(F)
Table 12.3. Special Function Registers
AD
SFR’s are listed in alphabetical order. All undefined SFR locations are reserved.
SFR
Register
Address
Description
Page
B
0xF0
All Pages B Register
ACC
0xE0
All Pages Accumulator
ADC0CCF
0xBB
F
ADC0 Calibration Coefficient
ADC0CF
0xBC
0
ADC0 Configuration
ADC0CN
0xE8
0
ADC0 Control
ADC0CPT
0xBA
F
ADC0 Calibration Pointer
ADC0GTH
0xC5
0
ADC0 Greater-Than High
ADC0GTL
0xC4
0
ADC0 Greater-Than Low
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page No.
page 142
page 142
page 63
page 53
page 55
page 63
page 64
page 64
Page 135
C8051F060/1/2/3
Advanced
Information
Table 12.3. Special Function Registers
N
Page No.
AD
VA
NC
ED
IN
FO
RM
AT
IO
SFR’s are listed in alphabetical order. All undefined SFR locations are reserved.
SFR
Register
Address
Description
Page
ADC0H
0xBF
0
ADC0 Data Word High
ADC0L
0xBE
0
ADC0 Data Word Low
ADC0LTH
0xC7
0
ADC0 Less-Than High
ADC0LTL
0xC6
0
ADC0 Less-Than Low
ADC1CF
0xBC
1
ADC1 Configuration
ADC1CN
0xE8
1
ADC1 Control
ADC1H
0xBF
1
ADC1 Data Word High
ADC1L
0xBE
1
ADC1 Data Word Low
ADC2CF
0xBC
2
ADC2 Configuration
ADC2CN
0xE8
2
ADC2 Control
ADC2GTH
0xC5
2
ADC2 Greater-Than High
ADC2GTL
0xC4
2
ADC2 Greater-Than Low
ADC2H
0xBF
2
ADC2 Data Word High
ADC2L
0xBE
2
ADC2 Data Word Low
ADC2LTH
0xC7
2
ADC2 Less-Than High
ADC2LTL
0xC6
2
ADC2 Less-Than Low
AMX0SL
0xBB
0
ADC0 Multiplexer Channel Select
AMX2CF
0xBA
2
ADC2 Analog Multiplexer Configuration
AMX2SL
0xBB
2
ADC2 Analog Multiplexer Channel Select
CAN0ADR
0xDA
1
CAN0 Address
CAN0CN
0xF8
1
CAN0 Control
CAN0DATH
0xD9
1
CAN0 Data High
CAN0DATL
0xD8
1
CAN0 Data Low
CAN0STA
0xC0
1
CAN0 Status
CAN0TST
0xDB
1
CAN0 Test
CKCON
0x8E
0
Clock Control
CLKSEL
0x97
F
Oscillator Clock Selection Register
CPT0CN
0x88
1
Comparator 0 Control
CPT0MD
0x89
1
Comparator 0 Configuration
CPT1CN
0x88
2
Comparator 1 Control
CPT1MD
0x89
2
Comparator 1 Configuration
CPT2CN
0x88
3
Comparator 2 Control
CPT2MD
0x89
3
Comparator 2 Configuration
DAC0CN
0xD4
0
DAC0 Control
DAC0H
0xD3
0
DAC0 High
DAC0L
0xD2
0
DAC0 Low
DAC1CN
0xD4
1
DAC1 Control
DAC1H
0xD3
1
DAC1 High
DAC1L
0xD2
1
DAC1 Low
DMA0BND
0xFD
3
DMA0 Instruction Boundary
DMA0CF
0xF8
3
DMA0 Configuration
DMA0CN
0xD8
3
DMA0 Control
DMA0CSH
0xFC
3
DMA0 Repeat Counter Status High Byte
DMA0CSL
0xFB
3
DMA0 Repeat Counter Status Low Byte
Page 136
page 58
page 58
page 65
page 65
page 54
page 56
page 60
page 60
page 90
page 92
page 93
page 93
page 91
page 91
page 94
page 94
page 89
page 90
page 89
page 221
page 221
page 220
page 220
page 222
page 222
page 277
page 163
page 114
page 115
page 114
page 115
page 114
page 115
page 102
page 101
page 101
page 104
page 103
page 103
page 79
page 77
page 76
page 81
page 81
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 12.3. Special Function Registers
N
Page No.
AD
VA
NC
ED
IN
FO
RM
AT
IO
SFR’s are listed in alphabetical order. All undefined SFR locations are reserved.
SFR
Register
Address
Description
Page
DMA0CTH
0xFA
3
DMA0 Repeat Counter Limit High Byte
DMA0CTL
0xF9
3
DMA0 Repeat Counter Limit Low Byte
DMA0DAH
0xDA
3
DMA0 Data Address Beginning High Byte
DMA0DAL
0xD9
3
DMA0 Data Address Beginning Low Byte
DMA0DSH
0xDC
3
DMA0 Data Address Pointer High Byte
DMA0DSL
0xDB
3
DMA0 Data Address Pointer Low Byte
DMA0IDT
0xDE
3
DMA0 Instruction Write Data
DMA0IPT
0xDD
3
DMA0 Instruction Write Address
DMA0ISW
0xFE
3
DMA0 Instruction Status
DPH
0x83
All Pages Data Pointer High
DPL
0x82
All Pages Data Pointer Low
EIE1
0xE6
All Pages Extended Interrupt Enable 1
EIE2
0xE7
All Pages Extended Interrupt Enable 2
EIP1
0xF6
All Pages Extended Interrupt Priority 1
EIP2
0xF7
All Pages Extended Interrupt Priority 2
EMI0CF
0xA3
0
EMIF Configuration
EMI0CN
0xA2
0
EMIF Control
EMI0TC
0xA1
0
EMIF Timing Control
FLACL
0xB7
F
FLASH Access Limit
FLSCL
0xB7
0
FLASH Scale
IE
0xA8
All Pages Interrupt Enable
IP
0xB8
All Pages Interrupt Priority
OSCICL
0x8B
F
Internal Oscillator Calibration
OSCICN
0x8A
F
Internal Oscillator Control
OSCXCN
0x8C
F
External Oscillator Control
P0
0x80
All Pages Port 0 Latch
P0MDOUT
0xA4
F
Port 0 Output Mode Configuration
P1
0x90
All Pages Port 1 Latch
P1MDIN
0xAD
F
Port 1 Input Mode
P1MDOUT
0xA5
F
Port 1 Output Mode Configuration
P2
0xA0
All Pages Port 2 Latch
P2MDIN
0xAE
F
Port 2 Input Mode
P2MDOUT
0xA6
F
Port 2 Output Mode Configuration
P3
0xB0
All Pages Port 3 Latch
P3MDOUT
0xA7
F
Port 3 Output Mode Configuration
P4
0xC8
F
Port 4 Latch
P4MDOUT
0x9C
F
Port 4 Output Mode Configuration
P5
0xD8
F
Port 5 Latch
P5MDOUT
0x9D
F
Port 5 Output Mode Configuration
P6
0xE8
F
Port 6 Latch
P6MDOUT
0x9E
F
Port 6 Output Mode Configuration
P7
0xF8
F
Port 7 Latch
P7MDOUT
0x9F
F
Port 7 Output Mode Configuration
PCA0CN
0xD8
0
PCA Control
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
page 81
page 81
page 80
page 80
page 80
page 80
page 78
page 78
page 79
page 140
page 140
page 148
page 149
page 150
page 151
page 177†
page 177†
page 182†
page 171
page 172
page 146
page 147
page 162
page 162
page 164
page 202
page 202
page 203
page 203
page 204
page 204
page 205
page 205
page 206†
page 206†
page 209†
page 209†
page 210†
page 210†
page 211†
page 211†
page 212†
page 212†
page 296
Page 137
C8051F060/1/2/3
Advanced
Information
Table 12.3. Special Function Registers
N
Page No.
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 300
page 298
page 298
page 298
page 298
page 298
page 298
page 299
page 299
page 297
page 153
page 173
page 141
page 285
page 285
page 285
page 285
page 285
page 285
page 57
page 57
page 108†, page 110*
page 159
page 259
page 259
page 259
page 267
page 257
page 266
page 133
page 133
page 132
page 132
AD
VA
NC
ED
IN
FO
RM
AT
IO
SFR’s are listed in alphabetical order. All undefined SFR locations are reserved.
SFR
Register
Address
Description
Page
PCA0CPH0
0xFC
0
PCA Capture 0 High
PCA0CPH1
0xFE
0
PCA Capture 1 High
PCA0CPH2
0xEA
0
PCA Capture 2 High
PCA0CPH3
0xEC
0
PCA Capture 3 High
PCA0CPH4
0xEE
0
PCA Capture 4 High
PCA0CPH5
0xE2
0
PCA Capture 5 High
PCA0CPL0
0xFB
0
PCA Capture 0 Low
PCA0CPL1
0xFD
0
PCA Capture 1 Low
PCA0CPL2
0xE9
0
PCA Capture 2 Low
PCA0CPL3
0xEB
0
PCA Capture 3 Low
PCA0CPL4
0xED
0
PCA Capture 4 Low
PCA0CPL5
0xE1
0
PCA Capture 5 Low
PCA0CPM0
0xDA
0
PCA Module 0 Mode Register
PCA0CPM1
0xDB
0
PCA Module 1 Mode Register
PCA0CPM2
0xDC
0
PCA Module 2 Mode Register
PCA0CPM3
0xDD
0
PCA Module 3 Mode Register
PCA0CPM4
0xDE
0
PCA Module 4 Mode Register
PCA0CPM5
0xDF
0
PCA Module 5 Mode Register
PCA0H
0xFA
0
PCA Counter High
PCA0L
0xF9
0
PCA Counter Low
PCA0MD
0xD9
0
PCA Mode
PCON
0x87
All Pages Power Control
PSCTL
0x8F
0
Program Store R/W Control
PSW
0xD0
All Pages Program Status Word
RCAP2H
0xCB
0
Timer/Counter 2 Capture/Reload High
RCAP2L
0xCA
0
Timer/Counter 2 Capture/Reload Low
RCAP3H
0xCB
1
Timer/Counter 3 Capture/Reload High
RCAP3L
0xCA
1
Timer/Counter 3 Capture/Reload Low
RCAP4H
0xCB
2
Timer/Counter 4 Capture/Reload High
RCAP4L
0xCA
2
Timer/Counter 4 Capture/Reload Low
REF0CN
0xD1
0
Voltage Reference Control 0
REF1CN
0xD1
1
Voltage Reference Control 1
REF2CN
0xD1
2
Voltage Reference Control 2
RSTSRC
0xEF
0
Reset Source
SADDR0
0xA9
0
UART 0 Slave Address
SADEN0
0xB9
0
UART 0 Slave Address Enable
SBUF0
0x99
0
UART 0 Data Buffer
SBUF1
0x99
1
UART 1 Data Buffer
SCON0
0x98
0
UART 0 Control
SCON1
0x98
1
UART 1 Control
SFRLAST
0x86
All Pages SFR Page Stack Access Register
SFRNEXT
0x85
All Pages SFR Page Register
SFRPAGE
0x84
All Pages SFR Page Register
SFRPGCN
0x96
F
SFR Page Control Register
Page 138
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 12.3. Special Function Registers
IO
N
Page No.
page 231
page 229
page 230
page 231
page 232
page 140
page 241
page 243
page 242
page 244
page 258
page 275
page 278
page 278
page 278
page 278
page 276
page 284
page 283
page 286
page 285
page 284
page 283
page 286
page 285
page 284
page 283
page 286
page 285
page 158
page 198
page 199
page 200
page 201
AD
VA
NC
ED
IN
FO
RM
AT
SFR’s are listed in alphabetical order. All undefined SFR locations are reserved.
SFR
Register
Address
Description
Page
SMB0ADR
0xC3
0
SMBus Slave Address
SMB0CN
0xC0
0
SMBus Control
SMB0CR
0xCF
0
SMBus Clock Rate
SMB0DAT
0xC2
0
SMBus Data
SMB0STA
0xC1
0
SMBus Status
SP
0x81
All Pages Stack Pointer
SPI0CFG
0x9A
0
SPI Configuration
SPI0CKR
0x9D
0
SPI Clock Rate Control
SPI0CN
0xF8
0
SPI Control
SPI0DAT
0x9B
0
SPI Data
SSTA0
0x91
0
UART 0 Status
TCON
0x88
0
Timer/Counter Control
TH0
0x8C
0
Timer/Counter 0 High
TH1
0x8D
0
Timer/Counter 1 High
TL0
0x8A
0
Timer/Counter 0 Low
TL1
0x8B
0
Timer/Counter 1 Low
TMOD
0x89
0
Timer/Counter Mode
TMR2CF
0xC9
0
Timer/Counter 2 Configuration
TMR2CN
0xC8
0
Timer/Counter 2 Control
TMR2H
0xCD
0
Timer/Counter 2 High
TMR2L
0xCC
0
Timer/Counter 2 Low
TMR3CF
0xC9
1
Timer/Counter 3 Configuration
TMR3CN
0xC8
1
Timer/Counter 3 Control
TMR3H
0xCD
1
Timer/Counter 3 High
TMR3L
0xCC
1
Timer/Counter 3 Low
TMR4CF
0xC9
2
Timer/Counter 4 Configuration
TMR4CN
0xC8
2
Timer/Counter 4 Control
TMR4H
0xCD
2
Timer/Counter 4 High
TMR4L
0xCC
2
Timer/Counter 4 Low
WDTCN
0xFF
All Pages Watchdog Timer Control
XBR0
0xE1
F
Port I/O Crossbar Control 0
XBR1
0xE2
F
Port I/O Crossbar Control 1
XBR2
0xE3
F
Port I/O Crossbar Control 2
XBR3
0xE4
F
Port I/O Crossbar Control 3
† Refers to a register in the C8051F060/2 only.
* Refers to a register in the C8051F061/3 only.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 139
Advanced
Information
C8051F060/1/2/3
12.2.7. Register Descriptions
Bits7-0:
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
Bit2
R/W
AT
Bit7
R/W
Bit1
R/W
Reset Value
00000111
Bit0
SFR Address: 0x81
SFR Page: All Pages
RM
R/W
IO
Figure 12.13. SP: Stack Pointer
N
Following are descriptions of SFRs related to the operation of the CIP-51 System Controller. Reserved bits should not
be set to logic l. Future product versions may use these bits to implement new features in which case the reset value
of the bit will be logic 0, selecting the feature's default state. Detailed descriptions of the remaining SFRs are included
in the sections of the datasheet associated with their corresponding system function.
SP: Stack Pointer.
The Stack Pointer holds the location of the top of the stack. The stack pointer is incremented before
every PUSH operation. The SP register defaults to 0x07 after reset.
Bits7-0:
Bit6
R/W
R/W
R/W
IN
Bit7
R/W
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0x82
SFR Page: All Pages
DPL: Data Pointer Low.
The DPL register is the low byte of the 16-bit DPTR. DPTR is used to access indirectly addressed
XRAM and FLASH memory.
ED
R/W
FO
Figure 12.14. DPL: Data Pointer Low Byte
R/W
Bit7
R/W
Bit6
R/W
Bit5
R/W
R/W
R/W
R/W
R/W
Reset Value
00000000
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x83
SFR Page: All Pages
DPH: Data Pointer High.
The DPH register is the high byte of the 16-bit DPTR. DPTR is used to access indirectly addressed
XRAM and FLASH memory.
AD
Bits7-0:
VA
NC
Figure 12.15. DPH: Data Pointer High Byte
Page 140
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.16. PSW: Program Status Word
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
CY
AC
F0
RS1
RS0
OV
F1
PARITY
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xD0
SFR Page: All Pages
Bits4-3:
AT
RM
Bit5:
RS1
0
0
1
1
OV: Overflow Flag.
This bit is set to 1 if the last arithmetic operation resulted in a carry (addition), borrow (subtraction),
or overflow (multiply or divide). It is cleared to 0 by all other arithmetic operations.
F1: User Flag 1.
This is a bit-addressable, general purpose flag for use under software control.
PARITY: Parity Flag.
This bit is set to 1 if the sum of the eight bits in the accumulator is odd and cleared if the sum is even.
AD
Bit0:
Address
0x00 - 0x07
0x08 - 0x0F
0x10 - 0x17
0x18 - 0x1F
ED
Bit1:
Register Bank
0
1
2
3
VA
NC
Bit2:
RS0
0
1
0
1
FO
Bit6:
CY: Carry Flag.
This bit is set when the last arithmetic operation resulted in a carry (addition) or a borrow (subtraction). It is cleared to 0 by all other arithmetic operations.
AC: Auxiliary Carry Flag.
This bit is set when the last arithmetic operation resulted in a carry into (addition) or a borrow from
(subtraction) the high order nibble. It is cleared to 0 by all other arithmetic operations.
F0: User Flag 0.
This is a bit-addressable, general purpose flag for use under software control.
RS1-RS0: Register Bank Select.
These bits select which register bank is used during register accesses.
IN
Bit7:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 141
C8051F060/1/2/3
Advanced
Information
Figure 12.17. ACC: Accumulator
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
ACC.7
ACC.6
ACC.5
ACC.4
ACC.3
ACC.2
ACC.1
ACC.0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
Bits7-0:
ACC: Accumulator.
This register is the accumulator for arithmetic operations.
AT
SFR Address: 0xE0
SFR Page: All Pages
R/W
R/W
R/W
R/W
B.7
B.6
B.5
B.4
B.3
Bit7
Bit6
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
B.2
B.1
B.0
00000000
Bit2
Bit1
Bit0
Bit
Addressable
SFR Address: 0xF0
SFR Page: All Pages
IN
B: B Register.
This register serves as a second accumulator for certain arithmetic operations.
AD
VA
NC
ED
Bits7-0:
FO
R/W
RM
Figure 12.18. B: B Register
Page 142
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
12.3. Interrupt Handler
IO
N
The CIP-51 includes an extended interrupt system supporting a total of 22 interrupt sources with two priority levels.
The allocation of interrupt sources between on-chip peripherals and external inputs pins varies according to the specific version of the device. Each interrupt source has one or more associated interrupt-pending flag(s) located in an
SFR. When a peripheral or external source meets a valid interrupt condition, the associated interrupt-pending flag is
set to logic 1.
RM
AT
If interrupts are enabled for the source, an interrupt request is generated when the interrupt-pending flag is set. As
soon as execution of the current instruction is complete, the CPU generates an LCALL to a predetermined address to
begin execution of an interrupt service routine (ISR). Each ISR must end with an RETI instruction, which returns program execution to the next instruction that would have been executed if the interrupt request had not occurred. If
interrupts are not enabled, the interrupt-pending flag is ignored by the hardware and program execution continues as
normal. (The interrupt-pending flag is set to logic 1 regardless of the interrupt's enable/disable state.)
FO
Each interrupt source can be individually enabled or disabled through the use of an associated interrupt enable bit in
an SFR (IE-EIE2). However, interrupts must first be globally enabled by setting the EA bit (IE.7) to logic 1 before the
individual interrupt enables are recognized. Setting the EA bit to logic 0 disables all interrupt sources regardless of
the individual interrupt-enable settings.
IN
Some interrupt-pending flags are automatically cleared by the hardware when the CPU vectors to the ISR. However,
most are not cleared by the hardware and must be cleared by software before returning from the ISR. If an interruptpending flag remains set after the CPU completes the return-from-interrupt (RETI) instruction, a new interrupt
request will be generated immediately and the CPU will re-enter the ISR after the completion of the next instruction.
12.3.1. MCU Interrupt Sources and Vectors
VA
NC
ED
The MCUs support 22 interrupt sources. Software can simulate an interrupt event by setting any interrupt-pending
flag to logic 1. If interrupts are enabled for the flag, an interrupt request will be generated and the CPU will vector to
the ISR address associated with the interrupt-pending flag. MCU interrupt sources, associated vector addresses, priority order and control bits are summarized in Table 12.4. Refer to the datasheet section associated with a particular onchip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s).
12.3.2. External Interrupts
AD
The external interrupt sources (/INT0 and /INT1) are configurable as active-low level-sensitive or active-low edgesensitive inputs depending on the setting of bits IT0 (TCON.0) and IT1 (TCON.2). IE0 (TCON.1) and IE1 (TCON.3)
serve as the interrupt-pending flag for the /INT0 and /INT1 external interrupts, respectively. If an /INT0 or /INT1
external interrupt is configured as edge-sensitive, the corresponding interrupt-pending flag is automatically cleared
by the hardware when the CPU vectors to the ISR. When configured as level sensitive, the interrupt-pending flag follows the state of the external interrupt's input pin. The external interrupt source must hold the input active until the
interrupt request is recognized. It must then deactivate the interrupt request before execution of the ISR completes or
another interrupt request will be generated.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 143
Advanced
Information
C8051F060/1/2/3
Reset
0x0000
Top
External Interrupt 0 (/INT0)
Timer 0 Overflow
External Interrupt 1 (/INT1)
Timer 1 Overflow
0x0003
0x000B
0x0013
0x001B
0
1
2
3
UART0
0x0023
4
Timer 2
0x002B
Serial Peripheral Interface
None
ES0 (IE.4)
PS0 (IP.4)
Y
ET2 (IE.5)
ESPI0
(EIE1.0)
ESMB0
(EIE1.1)
EWADC0
(EIE1.2)
PT2 (IP.5)
PSPI0
(EIP1.0)
PSMB0
(EIP1.1)
PWADC0
(EIP1.2)
EPCA0
(EIE1.3)
PPCA0
(EIP1.3)
CP0IE
(EIE1.4)
CP1IE
(EIE1.5)
CP2IE
(EIE1.6)
EADC0
(EIE1.7)
ET3
(EIE2.0)
EADC1
(EIE2.1)
ET4
(EIE2.2)
EWADC2
(EIE2.3)
EADC2
(EIE2.4)
ECAN0
(EIE2.5)
ES1
(EIP2.6)
EDMA0
(EIE2.7)
PCP0
(EIP1.4)
PCP1
(EIP1.5)
PCP2
(EIP1.6)
PADC0
(EIP1.7)
PT3
(EIP2.0)
PADC1
(EIP2.1)
PT4
(EIP2.2)
PWADC2
(EIP2.3)
PADC2
(EIP2.4)
PCAN0
(EIP2.5)
PS1
(EIP2.6)
PDMA0
(EIP2.7)
6
SPIF (SPI0CN.7)
Y
SMBus Interface
0x003B
7
ADC0 Window Comparator
0x0043
8
Programmable Counter Array
0x004B
Comparator 0
0x0053
Comparator 1
0x005B
11
Comparator 2
0x0063
12
FO
IN
ED
VA
NC
RM
0x0033
10
Y
Y
Y
Y
Y
Y
13
Timer 3
0x0073
14
TF3 (TMR3CN.7)
Y
ADC1 End of Conversion
0x007B
15
ADC1INT
(ADC1CN.5)
Y
Timer 4
0x0083
16
TF4 (TMR4CN.7)
Y
ADC2 Window Comparator
0x008B
17
ADC2 End of Conversion
0x0093
18
CAN Interrupt
0x009B
19
UART1
0x00A3
20
DMA0 Interrupt
0x00AB
21
AD
0x006B
Page 144
CAN0CN.7
RI1 (SCON1.0)
TI1 (SCON1.1)
DMA0INT
(DMA0CN.6)
Y
Y
Y
Y
Y
ADC0 End of Conversion
AD2WINT
(ADC2CN.1)
AD2INT
(ADC2CN.5)
N
Y
5
AD0WINT
(ADC0CN.1)
CF (PCA0CN.7)
CCFn
(PCA0CN.n)
CP0FIF/CP0RIF
(CPT0CN.4/.5)
CP1FIF/CP1RIF
(CPT1CN.4/.5)
CP2FIF/CP2RIF
(CPT2CN.4/.5)
ADC0INT
(ADC0CN.5)
Priority
Control
Always
Highest
PX0 (IP.0)
PT0 (IP.1)
PX1 (IP.2)
PT1 (IP.3)
Y
Y
Y
Y
SI (SMB0CN.3)
Enable
Flag
Always
Enabled
EX0 (IE.0)
ET0 (IE.1)
EX1 (IE.2)
ET1 (IE.3)
N/A N/A
IE0 (TCON.1)
TF0 (TCON.5)
IE1 (TCON.3)
TF1 (TCON.7)
RI0 (SCON0.0)
TI0 (SCON0.1)
TF2 (TMR2CN.7)
9
Cleared by HW?
Priority
Pending Flag
Order
IO
Interrupt
Vector
AT
Interrupt Source
Bit addressable?
Table 12.4. Interrupt Summary
Y
Y
Y
Y
Y
Y
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
12.3.3. Interrupt Priorities
IO
N
Each interrupt source can be individually programmed to one of two priority levels: low or high. A low priority interrupt service routine can be preempted by a high priority interrupt. A high priority interrupt cannot be preempted. Each
interrupt has an associated interrupt priority bit in an SFR (IP-EIP2) used to configure its priority level. Low priority
is the default. If two interrupts are recognized simultaneously, the interrupt with the higher priority is serviced first. If
both interrupts have the same priority level, a fixed priority order is used to arbitrate, given in Table 12.4.
12.3.4. Interrupt Latency
AD
VA
NC
ED
IN
FO
RM
AT
Interrupt response time depends on the state of the CPU when the interrupt occurs. Pending interrupts are sampled
and priority decoded each system clock cycle. Therefore, the fastest possible response time is 5 system clock cycles:
1 clock cycle to detect the interrupt and 4 clock cycles to complete the LCALL to the ISR. If an interrupt is pending
when a RETI is executed, a single instruction is executed before an LCALL is made to service the pending interrupt.
Therefore, the maximum response time for an interrupt (when no other interrupt is currently being serviced or the
new interrupt is of greater priority) occurs when the CPU is performing an RETI instruction followed by a DIV as the
next instruction. In this case, the response time is 18 system clock cycles: 1 clock cycle to detect the interrupt, 5 clock
cycles to execute the RETI, 8 clock cycles to complete the DIV instruction and 4 clock cycles to execute the LCALL
to the ISR. If the CPU is executing an ISR for an interrupt with equal or higher priority, the new interrupt will not be
serviced until the current ISR completes, including the RETI and following instruction.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 145
Advanced
Information
C8051F060/1/2/3
12.3.5. Interrupt Register Descriptions
IO
Figure 12.19. IE: Interrupt Enable
N
The SFRs used to enable the interrupt sources and set their priority level are described below. Refer to the datasheet
section associated with a particular on-chip peripheral for information regarding valid interrupt conditions for the
peripheral and the behavior of its interrupt-pending flag(s).
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
EA
IEGF0
ET2
ES0
ET1
EX1
ET0
EX0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit0
Bit
Addressable
Bit4:
Bit3:
Bit2:
Bit1:
RM
FO
AD
Bit0:
EA: Enable All Interrupts.
This bit globally enables/disables all interrupts. It overrides the individual interrupt mask settings.
0: Disable all interrupt sources.
1: Enable each interrupt according to its individual mask setting.
IEGF0: General Purpose Flag 0.
This is a general purpose flag for use under software control.
ET2: Enabler Timer 2 Interrupt.
This bit sets the masking of the Timer 2 interrupt.
0: Disable Timer 2 interrupt.
1: Enable interrupt requests generated by the TF2 flag.
ES0: Enable UART0 Interrupt.
This bit sets the masking of the UART0 interrupt.
0: Disable UART0 interrupt.
1: Enable UART0 interrupt.
ET1: Enable Timer 1 Interrupt.
This bit sets the masking of the Timer 1 interrupt.
0: Disable all Timer 1 interrupt.
1: Enable interrupt requests generated by the TF1 flag.
EX1: Enable External Interrupt 1.
This bit sets the masking of external interrupt 1.
0: Disable external interrupt 1.
1: Enable interrupt requests generated by the /INT1 pin.
ET0: Enable Timer 0 Interrupt.
This bit sets the masking of the Timer 0 interrupt.
0: Disable all Timer 0 interrupt.
1: Enable interrupt requests generated by the TF0 flag.
EX0: Enable External Interrupt 0.
This bit sets the masking of external interrupt 0.
0: Disable external interrupt 0.
1: Enable interrupt requests generated by the /INT0 pin.
IN
Bit5:
SFR Address: 0xA8
SFR Page: All Pages
ED
Bit6:
Bit1
VA
NC
Bit7:
AT
R/W
Page 146
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.20. IP: Interrupt Priority
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
-
-
PT2
PS0
PT1
PX1
PT0
PX0
11000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xB8
SFR Page: All Pages
Bit2:
Bit1:
AT
RM
AD
VA
NC
Bit0:
FO
Bit3:
IN
Bit4:
UNUSED. Read = 11b, Write = don't care.
PT2: Timer 2 Interrupt Priority Control.
This bit sets the priority of the Timer 2 interrupt.
0: Timer 2 interrupt priority determined by default priority order.
1: Timer 2 interrupts set to high priority level.
PS0: UART0 Interrupt Priority Control.
This bit sets the priority of the UART0 interrupt.
0: UART0 interrupt priority determined by default priority order.
1: UART0 interrupts set to high priority level.
PT1: Timer 1 Interrupt Priority Control.
This bit sets the priority of the Timer 1 interrupt.
0: Timer 1 interrupt priority determined by default priority order.
1: Timer 1 interrupts set to high priority level.
PX1: External Interrupt 1 Priority Control.
This bit sets the priority of the External Interrupt 1 interrupt.
0: External Interrupt 1 priority determined by default priority order.
1: External Interrupt 1 set to high priority level.
PT0: Timer 0 Interrupt Priority Control.
This bit sets the priority of the Timer 0 interrupt.
0: Timer 0 interrupt priority determined by default priority order.
1: Timer 0 interrupt set to high priority level.
PX0: External Interrupt 0 Priority Control.
This bit sets the priority of the External Interrupt 0 interrupt.
0: External Interrupt 0 priority determined by default priority order.
ED
Bits7-6:
Bit5:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 147
C8051F060/1/2/3
Advanced
Information
Figure 12.21. EIE1: Extended Interrupt Enable 1
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
EADC0
CP2IE
CP1IE
CP0IE
EPCA0
EWADC0
ESMB0
ESPI0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bit3:
Bit2:
Bit1:
AT
RM
AD
Bit0:
FO
Bit6:
IN
Bit6:
ED
Bit6:
EADC0: Enable ADC0 End of Conversion Interrupt.
This bit sets the masking of the ADC0 End of Conversion Interrupt.
0: Disable ADC0 Conversion Interrupt.
1: Enable interrupt requests generated by the ADC1 Conversion Interrupt.
CP2IE: Enable Comparator (CP2) Interrupt.
This bit sets the masking of the CP2 interrupt.
0: Disable CP2 interrupts.
1: Enable interrupt requests generated by the CP2IF flag.
CP1IE: Enable Comparator (CP1) Interrupt.
This bit sets the masking of the CP1 interrupt.
0: Disable CP1 interrupts.
1: Enable interrupt requests generated by the CP1IF flag.
CP0IE: Enable Comparator (CP0) Interrupt.
This bit sets the masking of the CP0 interrupt.
0: Disable CP0 interrupts.
1: Enable interrupt requests generated by the CP0IF flag.
EPCA0: Enable Programmable Counter Array (PCA0) Interrupt.
This bit sets the masking of the PCA0 interrupts.
0: Disable all PCA0 interrupts.
1: Enable interrupt requests generated by PCA0.
EWADC0: Enable Window Comparison ADC0 Interrupt.
This bit sets the masking of ADC0 Window Comparison interrupt.
0: Disable ADC0 Window Comparison Interrupt.
1: Enable Interrupt requests generated by ADC0 Window Comparisons.
ESMB0: Enable System Management Bus (SMBus0) Interrupt.
This bit sets the masking of the SMBus interrupt.
0: Disable all SMBus interrupts.
1: Enable interrupt requests generated by the SI flag.
ESPI0: Enable Serial Peripheral Interface (SPI0) Interrupt.
This bit sets the masking of SPI0 interrupt.
0: Disable all SPI0 interrupts.
1: Enable Interrupt requests generated by the SPI0 flag.
VA
NC
Bit7:
IO
SFR Address: 0xE6
SFR Page: All Pages
Page 148
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.22. EIE2: Extended Interrupt Enable 2
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
EDMA0
ES1
ECAN0
EADC2
EWADC2
ET4
EADC1
ET3
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bit3:
Bit2:
Bit1:
AT
RM
AD
Bit0:
FO
Bit4:
IN
Bit5:
ED
Bit6:
EDMA0: Enable DMA0 Interrupt.
This bit sets the masking of the DMA0 Interrupt.
0: Disable DMA0 interrupt.
1: Enable DMA0 interrupt.
ES1: Enable UART1 Interrupt.
This bit sets the masking of the UART1 Interrupt.
0: Disable UART1 interrupt.
1: Enable UART1 interrupt.
ECAN0: Enable CAN Controller Interrupt.
This bit sets the masking of the CAN Controller Interrupt.
0: Disable CAN Controller Interrupt.
1: Enable interrupt requests generated by the CAN Controller.
EADC2: Enable ADC2 End Of Conversion Interrupt.
This bit sets the masking of the ADC2 End of Conversion interrupt.
0: Disable ADC2 End of Conversion interrupt.
1: Enable interrupt requests generated by the ADC2 End of Conversion Interrupt.
EWADC2: Enable Window Comparison ADC1 Interrupt.
This bit sets the masking of ADC2 Window Comparison interrupt.
0: Disable ADC2 Window Comparison Interrupt.
1: Enable Interrupt requests generated by ADC2 Window Comparisons.
ET4: Enable Timer 4 Interrupt
This bit sets the masking of the Timer 4 interrupt.
0: Disable Timer 4 interrupt.
1: Enable interrupt requests generated by the TF4 flag.
EADC1: Enable ADC1 End of Conversion Interrupt.
This bit sets the masking of the ADC1 End of Conversion Interrupt.
0: Disable ADC1 Conversion Interrupt.
1: Enable interrupt requests generated by the ADC1 Conversion Interrupt.
ET3: Enable Timer 3 Interrupt.
This bit sets the masking of the Timer 3 interrupt.
0: Disable all Timer 3 interrupts.
1: Enable interrupt requests generated by the TF3 flag.
VA
NC
Bit7:
IO
SFR Address: 0xE7
SFR Page: All Pages
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 149
C8051F060/1/2/3
Advanced
Information
Figure 12.23. EIP1: Extended Interrupt Priority 1
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
PADC0
PCP2
PCP1
PCP0
PPCA0
PWADC0
PSMB0
PSPI0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bit3:
Bit2:
Bit1:
AT
RM
AD
Bit0:
FO
Bit4:
IN
Bit5:
ED
Bit6:
PADC0: ADC End of Conversion Interrupt Priority Control.
This bit sets the priority of the ADC0 End of Conversion Interrupt.
0: ADC0 End of Conversion interrupt set to low priority level.
1: ADC0 End of Conversion interrupt set to high priority level.
PCP2: Comparator2 (CP2) Interrupt Priority Control.
This bit sets the priority of the CP2 interrupt.
0: CP2 interrupt set to low priority level.
1: CP2 interrupt set to high priority level.
PCP1: Comparator1 (CP1) Interrupt Priority Control.
This bit sets the priority of the CP1 interrupt.
0: CP1 interrupt set to low priority level.
1: CP1 interrupt set to high priority level.
PCP0: Comparator0 (CP0) Interrupt Priority Control.
This bit sets the priority of the CP0 interrupt.
0: CP0 interrupt set to low priority level.
1: CP0 interrupt set to high priority level.
PPCA0: Programmable Counter Array (PCA0) Interrupt Priority Control.
This bit sets the priority of the PCA0 interrupt.
0: PCA0 interrupt set to low priority level.
1: PCA0 interrupt set to high priority level.
PWADC0: ADC0 Window Comparator Interrupt Priority Control.
This bit sets the priority of the ADC0 Window interrupt.
0: ADC0 Window interrupt set to low priority level.
1: ADC0 Window interrupt set to high priority level.
PSMB0: System Management Bus (SMBus0) Interrupt Priority Control.
This bit sets the priority of the SMBus0 interrupt.
0: SMBus interrupt set to low priority level.
1: SMBus interrupt set to high priority level.
PSPI0: Serial Peripheral Interface (SPI0) Interrupt Priority Control.
This bit sets the priority of the SPI0 interrupt.
0: SPI0 interrupt set to low priority level.
1: SPI0 interrupt set to high priority level.
VA
NC
Bit7:
IO
SFR Address: 0xF6
SFR Page: All Pages
Page 150
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.24. EIP2: Extended Interrupt Priority 2
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
PDMA0
PS1
PCAN0
PADC2
PWADC2
PT4
PADC1
PT3
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bit3:
Bit2:
Bit1:
AT
RM
AD
Bit0:
FO
Bit4:
IN
Bit5:
ED
Bit6:
PDMA0: DMA0 Interrupt Priority Control.
This bit sets the priority of the DMA0 interrupt.
0: DMA0 interrupt set to low priority.
1: DMA0 interrupt set to high priority.
PS1: UART1 Interrupt Priority Control.
This bit sets the priority of the UART1 interrupt.
0: UART1 interrupt set to low priority.
1: UART1 interrupt set to high priority.
PCAN0: CAN Interrupt Priority Control.
This bit sets the priority of the CAN Interrupt.
0: CAN Interrupt set to low priority level.
1: CAN Interrupt set to high priority level.
PADC2: ADC2 End Of Conversion Interrupt Priority Control.
This bit sets the priority of the ADC2 End of Conversion interrupt.
0: ADC2 End of Conversion interrupt set to low priority.
1: ADC2 End of Conversion interrupt set to low priority.
PWADC2: ADC2 Window Comparator Interrupt Priority Control.
0: ADC2 Window interrupt set to low priority.
1: ADC2 Window interrupt set to high priority.
PT4: Timer 4 Interrupt Priority Control.
This bit sets the priority of the Timer 4 interrupt.
0: Timer 4 interrupt set to low priority.
1: Timer 4 interrupt set to low priority.
PADC1: ADC End of Conversion Interrupt Priority Control.
This bit sets the priority of the ADC1 End of Conversion Interrupt.
0: ADC1 End of Conversion interrupt set to low priority level.
1: ADC1 End of Conversion interrupt set to high priority level.
PT3: Timer 3 Interrupt Priority Control.
This bit sets the priority of the Timer 3 interrupts.
0: Timer 3 interrupt priority determined by default priority order.
1: Timer 3 interrupt set to high priority level.
VA
NC
Bit7:
IO
SFR Address: 0xF7
SFR Page: All Pages
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 151
C8051F060/1/2/3
Advanced
Information
12.4. Power Management Modes
IO
N
The CIP-51 core has two software programmable power management modes: Idle and Stop. Idle mode halts the CPU
while leaving the external peripherals and internal clocks active. In Stop mode, the CPU is halted, all interrupts and
timers (except the Missing Clock Detector) are inactive, and the internal oscillator is stopped. Since clocks are running in Idle mode, power consumption is dependent upon the system clock frequency and the number of peripherals
left in active mode before entering Idle. Stop mode consumes the least power. Figure 12.25 describes the Power Control Register (PCON) used to control the CIP-51's power management modes.
RM
AT
Although the CIP-51 has Idle and Stop modes built in (as with any standard 8051 architecture), power management
of the entire MCU is better accomplished by enabling/disabling individual peripherals as needed. Each analog peripheral can be disabled when not in use and put into low power mode. Digital peripherals, such as timers or serial buses,
draw little power whenever they are not in use. Turning off the oscillator saves even more power, but requires a reset
to restart the MCU.
12.4.1. Idle Mode
FO
Setting the Idle Mode Select bit (PCON.0) causes the CIP-51 to halt the CPU and enter Idle mode as soon as the
instruction that sets the bit completes. All internal registers and memory maintain their original data. All analog and
digital peripherals can remain active during Idle mode.
IN
Idle mode is terminated when an enabled interrupt or /RST is asserted. The assertion of an enabled interrupt will
cause the Idle Mode Selection bit (PCON.0) to be cleared and the CPU to resume operation. The pending interrupt
will be serviced and the next instruction to be executed after the return from interrupt (RETI) will be the instruction
immediately following the one that set the Idle Mode Select bit. If Idle mode is terminated by an internal or external
reset, the CIP-51 performs a normal reset sequence and begins program execution at address 0x0000.
VA
NC
ED
If enabled, the WDT will eventually cause an internal watchdog reset and thereby terminate the Idle mode. This feature protects the system from an unintended permanent shutdown in the event of an inadvertent write to the PCON
register. If this behavior is not desired, the WDT may be disabled by software prior to entering the Idle mode if the
WDT was initially configured to allow this operation. This provides the opportunity for additional power savings,
allowing the system to remain in the Idle mode indefinitely, waiting for an external stimulus to wake up the system.
Refer to Section 13.7 for more information on the use and configuration of the WDT.
12.4.2. Stop Mode
Setting the Stop Mode Select bit (PCON.1) causes the CIP-51 to enter Stop mode as soon as the instruction that sets
the bit completes. In Stop mode, the CPU and internal oscillators are stopped, effectively shutting down all digital
peripherals. Each analog peripheral must be shut down individually prior to entering Stop Mode. Stop mode can only
be terminated by an internal or external reset. On reset, the CIP-51 performs the normal reset sequence and begins
program execution at address 0x0000.
AD
If enabled, the Missing Clock Detector will cause an internal reset and thereby terminate the Stop mode. The Missing
Clock Detector should be disabled if the CPU is to be put to sleep for longer than the MCD timeout of 100 µs.
Page 152
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 12.25. PCON: Power Control
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
IDLE
00000000
-
-
-
-
-
-
STOP
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
AD
VA
NC
ED
IN
FO
RM
Bit0:
Reserved.
STOP: STOP Mode Select.
Writing a ‘1’ to this bit will place the CIP-51 into STOP mode. This bit will always read ‘0’.
1: CIP-51 forced into power-down mode. (Turns off internal oscillator).
IDLE: IDLE Mode Select.
Writing a ‘1’ to this bit will place the CIP-51 into IDLE mode. This bit will always read ‘0’.
1: CIP-51 forced into IDLE mode. (Shuts off clock to CPU, but clock to Timers, Interrupts, and all
peripherals remain active.)
AT
Bits7-2:
Bit1:
IO
SFR Address: 0x87
SFR Page: All Pages
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 153
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 154
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
13.
C8051F060/1/2/3
RESET SOURCES
CIP-51 halts program execution
Special Function Registers (SFRs) are initialized to their defined reset values
External port pins are forced to a known configuration
Interrupts and timers are disabled.
IO
•
•
•
•
N
Reset circuitry allows the controller to be easily placed in a predefined default condition. On entry to this reset state,
the following occur:
AT
All SFRs are reset to the predefined values noted in the SFR detailed descriptions. The contents of internal data memory are unaffected during a reset; any previously stored data is preserved. However, since the stack pointer SFR is
reset, the stack is effectively lost even though the data on the stack are not altered.
RM
The I/O port latches are reset to 0xFF (all logic 1’s), activating internal weak pull-ups which take the external I/O pins
to a high state. The external I/O pins do not go high immediately, but will go high within four system clock cycles
after entering the reset state. This allows power to be conserved while the part is held in reset. For VDD Monitor
resets, the /RST pin is driven low until the end of the VDD reset timeout.
IN
FO
On exit from the reset state, the program counter (PC) is reset, and the system clock defaults to the internal oscillator
running at its lowest frequency. Refer to Section “14. OSCILLATORS” on page 161 for information on selecting
and configuring the system clock source. The Watchdog Timer is enabled using its longest timeout interval (see Section “13.7. Watchdog Timer Reset” on page 157). Once the system clock source is stable, program execution begins
at location 0x0000.
There are seven sources for putting the MCU into the reset state: power-on, power-fail, external /RST pin, external
CNVSTR2 signal, software command, Comparator0, Missing Clock Detector, and Watchdog Timer. Each reset
source is described in the following sections.
(CNVSTR
reset
enable)
Supply
Reset
Timeout
+
-
Comparator0
EN
OSC
Clock Select
PRE
WDT
Enable
MCD
Enable
System
Clock
Reset
Funnel
WDT
WDT
Strobe
Missing
Clock
Detector
(oneshot)
XTAL1
/RST
(wired-OR)
(CP0
reset
enable)
EN
Internal
Clock
Generator
(wired-OR)
VDD Monitor
reset enable
+
-
CP0-
AD
Supply
Monitor
Crossbar
CP0+
XTAL2
VDD
CNVSTR2
VA
NC
(Port
I/O)
ED
Figure 13.1. Reset Sources
Software Reset
CIP-51
Microcontroller
Core
System Reset
Extended Interrupt
Handler
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 155
C8051F060/1/2/3
13.1.
Advanced
Information
Power-on Reset
IO
N
The C8051F060/1/2/3 family incorporates a power supply monitor that holds the MCU in the reset state until VDD
rises above the VRST level during power-up. See Figure 13.2 for timing diagram, and refer to Table 13.1 for the Electrical Characteristics of the power supply monitor circuit. The /RST pin is asserted low until the end of the 100 ms
VDD Monitor timeout in order to allow the VDD supply to stabilize. The VDD Monitor reset is enabled and disabled
using the external VDD monitor enable pin (MONEN).
AT
On exit from a power-on reset, the PORSF flag (RSTSRC.1) is set by hardware to logic 1. All of the other reset flags
in the RSTSRC Register are indeterminate. PORSF is cleared by all other resets. Since all resets cause program execution to begin at the same location (0x0000) software can read the PORSF flag to determine if a power-up was the
cause of reset. The contents of internal data memory should be assumed to be undefined after a power-on reset.
volts
RM
Figure 13.2. Reset Timing
2.70
2.55
VD
D
2.0
FO
VRST
IN
1.0
Logic HIGH
/RST
13.2.
VA
NC
Logic LOW
ED
t
100ms
Power-On Reset
100ms
VDD Monitor Reset
Power-fail Reset
AD
When a power-down transition or power irregularity causes VDD to drop below VRST, the power supply monitor will
drive the /RST pin low and return the CIP-51 to the reset state. When VDD returns to a level above VRST, the CIP-51
will leave the reset state in the same manner as that for the power-on reset (see Figure 13.2). Note that even though
internal data memory contents are not altered by the power-fail reset, it is impossible to determine if VDD dropped
below the level required for data retention. If the PORSF flag is set to logic 1, the data may no longer be valid.
13.3.
External Reset
The external /RST pin provides a means for external circuitry to force the MCU into a reset state. Asserting the /RST
pin low will cause the MCU to enter the reset state. It may be desirable to provide an external pull-up and/or decoupling of the /RST pin to avoid erroneous noise-induced resets. The MCU will remain in reset until at least 12 clock
cycles after the active-low /RST signal is removed. The PINRSF flag (RSTSRC.0) is set on exit from an external
reset.
Page 156
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
13.4. Missing Clock Detector Reset
Comparator0 Reset
AT
13.5.
IO
N
The Missing Clock Detector is essentially a one-shot circuit that is triggered by the MCU system clock. If the system
clock goes away for more than 100 µs, the one-shot will time out and generate a reset. After a Missing Clock Detector
reset, the MCDRSF flag (RSTSRC.2) will be set, signifying the MSD as the reset source; otherwise, this bit reads ‘0’.
The state of the /RST pin is unaffected by this reset. Setting the MCDRSF bit, RSTSRC.2 (see Section
“14. OSCILLATORS” on page 161) enables the Missing Clock Detector.
External CNVSTR2 Pin Reset
FO
13.6.
RM
Comparator0 can be configured as a reset input by writing a ‘1’ to the C0RSEF flag (RSTSRC.5). Comparator0
should be enabled using CPT0CN.7 (see Section “11. COMPARATORS” on page 111) prior to writing to C0RSEF
to prevent any turn-on chatter on the output from generating an unwanted reset. The Comparator0 reset is active-low:
if the non-inverting input voltage (CP0+ pin) is less than the inverting input voltage (CP0- pin), the MCU is put into
the reset state. After a Comparator0 Reset, the C0RSEF flag (RSTSRC.5) will read ‘1’ signifying Comparator0 as the
reset source; otherwise, this bit reads ‘0’. The state of the /RST pin is unaffected by this reset.
13.7.
ED
IN
The external CNVSTR2 signal can be configured as a reset input by writing a ‘1’ to the CNVRSEF flag (RSTSRC.6).
The CNVSTR2 signal can appear on any of the P0, P1, P2 or P3 I/O pins as described in Section “17.1. Ports 0
through 3 and the Priority Crossbar Decoder” on page 193. Note that the Crossbar must be configured for the
CNVSTR2 signal to be routed to the appropriate Port I/O. The Crossbar should be configured and enabled before the
CNVRSEF is set. CNVSTR2 cannot be used to start ADC2 conversions when it is configured as a reset source. When
configured as a reset, CNVSTR2 is active-low and level sensitive. After a CNVSTR2 reset, the CNVRSEF flag
(RSTSRC.6) will read ‘1’ signifying CNVSTR2 as the reset source; otherwise, this bit reads ‘0’. The state of the /
RST pin is unaffected by this reset.
Watchdog Timer Reset
VA
NC
The MCU includes a programmable Watchdog Timer (WDT) running off the system clock. A WDT overflow will
force the MCU into the reset state. To prevent the reset, the WDT must be restarted by application software before
overflow. If the system experiences a software or hardware malfunction preventing the software from restarting the
WDT, the WDT will overflow and cause a reset. This should prevent the system from running out of control.
Following a reset the WDT is automatically enabled and running with the default maximum time interval. If desired
the WDT can be disabled by system software or locked on to prevent accidental disabling. Once locked, the WDT
cannot be disabled until the next system reset. The state of the /RST pin is unaffected by this reset.
AD
The WDT consists of a 21-bit timer running from the programmed system clock. The timer measures the period
between specific writes to its control register. If this period exceeds the programmed limit, a WDT reset is generated.
The WDT can be enabled and disabled as needed in software, or can be permanently enabled if desired. Watchdog
features are controlled via the Watchdog Timer Control Register (WDTCN) shown in Figure 13.3.
13.7.1. Enable/Reset WDT
The watchdog timer is both enabled and reset by writing 0xA5 to the WDTCN register. The user's application software should include periodic writes of 0xA5 to WDTCN as needed to prevent a watchdog timer overflow. The WDT
is enabled and reset as a result of any system reset.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 157
C8051F060/1/2/3
Advanced
Information
13.7.2. Disable WDT
EA
WDTCN,#0DEh
WDTCN,#0ADh
EA
; disable all interrupts
; disable software watchdog timer
IO
CLR
MOV
MOV
SETB
N
Writing 0xDE followed by 0xAD to the WDTCN register disables the WDT. The following code segment illustrates
disabling the WDT:
; re-enable interrupts
AT
The writes of 0xDE and 0xAD must occur within 4 clock cycles of each other, or the disable operation is ignored.
Interrupts should be disabled during this procedure to avoid delay between the two writes.
13.7.3. Disable WDT Lockout
RM
Writing 0xFF to WDTCN locks out the disable feature. Once locked out, the disable operation is ignored until the
next system reset. Writing 0xFF does not enable or reset the watchdog timer. Applications always intending to use the
watchdog should write 0xFF to WDTCN in the initialization code.
13.7.4. Setting WDT Interval
3 + WDTCN [ 2 – 0 ]
× T sysclk ; where Tsysclk is the system clock period.
IN
4
FO
WDTCN.[2:0] control the watchdog timeout interval. The interval is given by the following equation:
For a 3 MHz system clock, this provides an interval range of 0.021 ms to 349.5 ms. WDTCN.7 must be logic 0 when
setting this interval. Reading WDTCN returns the programmed interval. WDTCN.[2:0] reads 111b after a system
reset.
Bit7
Bits7-0:
Bit6
R/W
Bit5
R/W
Bit4
R/W
R/W
R/W
R/W
Reset Value
xxxxx111
Bit3
Bit2
Bit1
Bit0
SFR Address: 0xFF
SFR Page: All Pages
WDT Control.
Writing 0xA5 both enables and reloads the WDT.
Writing 0xDE followed within 4 system clocks by 0xAD disables the WDT.
Writing 0xFF locks out the disable feature.
Watchdog Status Bit (when Read).
Reading the WDTCN.[4] bit indicates the Watchdog Timer Status.
0: WDT is inactive.
1: WDT is active.
Watchdog Timeout Interval Bits.
The WDTCN.[2:0] bits set the Watchdog Timeout Interval. When writing these bits, WDTCN.7 must
be set to 0.
AD
Bit4:
R/W
VA
NC
R/W
ED
Figure 13.3. WDTCN: Watchdog Timer Control Register
Bits2-0:
Page 158
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 13.4. RSTSRC: Reset Source Register
Bit7
R/W
R/W
R/W
CNVRSEF C0RSEF
Bit6
Bit5
SWRSEF
Bit4
R
R/W
WDTRSF MCDRSF
Bit3
Bit2
R
R/W
Reset Value
PORSF
PINRSF
00000000
Bit1
N
R
Bit0
Bit3:
Bit2:
Bit1:
AT
RM
FO
AD
Bit0:
IN
Bit4:
ED
Bit5:
Reserved.
CNVRSEF: Convert Start Reset Source Enable and Flag
Write: 0: CNVSTR2 is not a reset source.
1: CNVSTR2 is a reset source (active low).
Read: 0: Source of prior reset was not CNVSTR2.
1: Source of prior reset was CNVSTR2.
C0RSEF: Comparator0 Reset Enable and Flag.
Write: 0: Comparator0 is not a reset source.
1: Comparator0 is a reset source (active low).
Read: 0: Source of last reset was not Comparator0.
1: Source of last reset was Comparator0.
SWRSF: Software Reset Force and Flag.
Write: 0: No effect.
1: Forces an internal reset. /RST pin is not effected.
Read: 0: Source of last reset was not a write to the SWRSF bit.
1: Source of last reset was a write to the SWRSF bit.
WDTRSF: Watchdog Timer Reset Flag.
0: Source of last reset was not WDT timeout.
1: Source of last reset was WDT timeout.
MCDRSF: Missing Clock Detector Flag.
Write: 0: Missing Clock Detector disabled.
1: Missing Clock Detector enabled; triggers a reset if a missing clock condition is detected.
Read: 0: Source of last reset was not a Missing Clock Detector timeout.
1: Source of last reset was a Missing Clock Detector timeout.
PORSF: Power-On Reset Flag.
This bit is set anytime a power-on reset occurs. This may be due to a true power-on reset or a VDD
monitor reset. In either case, data memory should be considered indeterminate following the reset.
The VDD Monitor reset is enabled/disabled using the external VDD monitor enable pin.
0: Source of last reset was not a power-on or VDD monitor reset.
1: Source of last reset was a power-on or VDD monitor reset.
Note: When this flag is set, all other reset flags indeterminate.
PINRSF: HW Pin Reset Flag.
Write: 0: No effect.
1: Forces a Power-On Reset. /RST is driven low.
Read: 0: Source of prior reset was not /RST pin.
1: Source of prior reset was /RST pin.
VA
NC
Bit7:
Bit6:
IO
SFR Address: 0xEF
SFR Page: 0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 159
C8051F060/1/2/3
Advanced
Information
/RST = 0.0 V
RM
/RST Input Leakage Current
VDD for /RST Output Valid
AV+ for /RST Output Valid
VDD POR Threshold (VRST)
Minimum /RST Low Time to
Generate a System Reset
AT
/RST Input Low Voltage
MAX
0.6
FO
/RST rising edge after VDD crosses
VRST threshold
Time from last system clock to reset
initiation
1.0
1.0
2.40
V
0.3 x
VDD
50
2.55
UNITS
V
2.70
10
µA
V
V
V
ns
80
100
120
ms
100
220
500
µs
AD
VA
NC
ED
IN
Missing Clock Detector Timeout
TYP
0.7 x
VDD
/RST Input High Voltage
Reset Time Delay
MIN
IO
-40°C to +85°C unless otherwise specified.
PARAMETER
CONDITIONS
IOL = 8.5 mA, VDD = 2.7 V to 3.6 V
/RST Output Low Voltage
N
Table 13.1. Reset Electrical Characteristics
Page 160
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
14.
C8051F060/1/2/3
OSCILLATORS
XTAL2
Option 4
RM
EN
XTAL1
Programmable
Internal Clock
Generator
Option 1
FO
XTAL1
Input
Circuit
XTAL1
CLKSL
0
SYSCLK
1
OSCXCN
Programmable Internal Oscillator
VA
NC
14.1.
ED
XTLVLD
XOSCMD2
XOSCMD1
XOSCMD0
IN
XTAL2
OSC
n
XFCN2
XFCN1
XFCN0
Option 2
VDD
AT
Option 3
XTAL1
CLKSEL
IFCN1
IFCN0
OSCICN
IOSCEN
IFRDY
OSCICL
IO
Figure 14.1. Oscillator Diagram
N
C8051F060/1/2/3 devices include a programmable internal oscillator and an external oscillator drive circuit. The
internal oscillator can be enabled, disabled and calibrated using the OSCICN and OSCICL registers, as shown in
Figure 14.1. The system clock can be sourced by the external oscillator circuit, the internal oscillator, or a scaled version of the internal oscillator. The internal oscillator's electrical specifications are given in Table 14.1.
All C8051F060/1/2/3 devices include a programmable internal oscillator that defaults as the system clock after a system reset. The internal oscillator period can be adjusted via the OSCICL register as defined by Figure 14.2, where
fBASE is the frequency of the internal oscillator following a reset, ∆T is the change in internal oscillator period, and
∆OSCICL is a change to the value held in register OSCICL.
OSCICL is factory calibrated to obtain a 24.5 MHz base frequency (fBASE).
AD
Electrical specifications for the precision internal oscillator are given in Table 14.1. The programmed internal oscillator frequency must not exceed 25 MHz. Note that the system clock may be derived from the programmed internal
oscillator divided by 1, 2, 4, or 8, as defined by the IFCN bits in register OSCICN.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 161
Advanced
Information
C8051F060/1/2/3
.
Bit7
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
R/W
Reset Value
Variable
IO
R/W
N
Figure 14.2. OSCICL: Internal Oscillator Calibration Register
Bit2
Bit1
Bit0
OSCICL: Internal Oscillator Calibration Register
This register calibrates the internal oscillator period. The reset value for OSCICL defines the internal
oscillator base frequency. The reset value is factory calibrated to generate an internal oscillator frequency of 24.5 MHz.
FO
RM
Bits 7-0:
AT
SFR Address: 0x8B
SFR Page: F
R
R/W
IFRDY
-
Bit7
Bit6
Bit5
Bit6:
R/W
R/W
R/W
Reset Value
-
-
IFCN1
IFCN0
11000000
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x8A
SFR Page: F
IOSCEN: Internal Oscillator Enable Bit
0: Internal Oscillator Disabled
1: Internal Oscillator Enabled
IFRDY: Internal Oscillator Frequency Ready Flag
0: Internal Oscillator not running at programmed frequency.
1: Internal Oscillator running at programmed frequency.
Reserved.
IFCN1-0: Internal Oscillator Frequency Control Bits
00: SYSCLK derived from Internal Oscillator divided by 8.
01: SYSCLK derived from Internal Oscillator divided by 4.
10: SYSCLK derived from Internal Oscillator divided by 2.
11: SYSCLK derived from Internal Oscillator divided by 1.
AD
Bits5-2:
Bits1-0:
R/W
-
VA
NC
Bit7:
R
ED
R/W
IOSCEN
IN
Figure 14.3. OSCICN: Internal Oscillator Control Register
Page 162
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 14.1. Internal Oscillator Electrical Characteristics
24
24.5
MAX
N
TYP
25
TBD
UNITS
MHz
µA
AT
14.2.
MIN
IO
-40°C to +85°C unless otherwise specified
PARAMETER
CONDITIONS
Calibrated Internal Oscillator
Frequency
Internal Oscillator Supply Current
OSCICN.7 = 1
(from VDD)
External Oscillator Drive Circuit
System Clock Selection
FO
14.3.
RM
The external oscillator circuit may drive an external crystal, ceramic resonator, capacitor, or RC network. A CMOS
clock may also provide a clock input. For a crystal or ceramic resonator configuration, the crystal/resonator must be
wired across the XTAL1 and XTAL2 pins as shown in Option 1 of Figure 14.1. In RC, capacitor, or CMOS clock
configuration, the clock source should be wired to the XTAL2 and/or XTAL1 pin(s) as shown in Option 2, 3, or 4 of
Figure 14.1. The type of external oscillator must be selected in the OSCXCN register, and the frequency control bits
(XFCN) must be selected appropriately (see Figure 14.5).
ED
IN
The CLKSL bit in register CLKSEL selects which oscillator generates the system clock. CLKSL must be set to ‘1’
for the system clock to run from the external oscillator; however the external oscillator may still clock peripherals
(timers, PCA) when the internal oscillator is selected as the system clock. The system clock may be switched on-thefly between the internal and external oscillator, so long as the selected oscillator is enabled and settled. The internal
oscillator requires little start-up time, and may be enabled and selected as the system clock in the same write to
OSCICN. External crystals and ceramic resonators typically require a start-up time before they are settled and ready
for use as the system clock. The Crystal Valid Flag (XTLVLD in register OSCXCN) is set to ‘1’ by hardware when
the external oscillator is settled. To avoid reading a false XTLVLD, in crystal mode software should delay at least
1 ms between enabling the external oscillator and checking XTLVLD. RC and C modes typically require no startup
time.
R/W
Bit7
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
-
-
-
-
-
-
CLKSL
00000000
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x97
SFR Page: F
Reserved.
CLKSL: System Clock Source Select Bit.
0: SYSCLK derived from the Internal Oscillator, and scaled as per the IFCN bits in OSCICN.
1: SYSCLK derived from the External Oscillator circuit.
AD
Bits7-1:
Bit0:
VA
NC
Figure 14.4. CLKSEL: Oscillator Clock Selection Register
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 163
C8051F060/1/2/3
Advanced
Information
Figure 14.5. OSCXCN: External Oscillator Control Register
R/W
R/W
R/W
Bit6
Bit5
Bit4
R/W
R/W
-
XFCN2
XFCN1
R/W
Bit3
Bit2
Bit1
XFCN0
Reset Value
00000000
Bit0
IO
Bit7
R
N
R
XTLVLD XOSCMD2 XOSCMD1 XOSCMD0
SFR Address: 0x8C
SFR Page: F
IN
Crystal (XOSCMD = 11x)
f ≤ 32kHz
32kHz < f ≤ 84kHz
84kHz < f ≤ 225kHz
225kHz < f ≤ 590kHz
590kHz < f ≤ 1.5MHz
1.5MHz < f ≤ 4MHz
4MHz < f ≤ 10MHz
10MHz < f ≤ 30MHz
VA
NC
XFCN
000
001
010
011
100
101
110
111
ED
Bit3:
Bits2-0:
FO
RM
Bits6-4:
XTLVLD: Crystal Oscillator Valid Flag.
(Valid only when XOSCMD = 11x.).
0: Crystal Oscillator is unused or not yet stable.
1: Crystal Oscillator is running and stable.
XOSCMD2-0: External Oscillator Mode Bits.
00x: External Oscillator circuit off.
010: External CMOS Clock Mode (External CMOS Clock input on XTAL1 pin).
011: External CMOS Clock Mode with divide by 2 stage (External CMOS Clock input on XTAL1
pin).
10x: RC/C Oscillator Mode with divide by 2 stage.
110: Crystal Oscillator Mode.
111: Crystal Oscillator Mode with divide by 2 stage.
Unused. Read = 0, Write = don't care.
XFCN2-0: External Oscillator Frequency Control Bits.
000-111: see table below:
AT
Bit7:
RC (XOSCMD = 10x)
f ≤ 25kHz
25kHz < f ≤ 50kHz
50kHz < f ≤ 100kHz
100kHz < f ≤ 200kHz
200kHz < f ≤ 400kHz
400kHz < f ≤ 800kHz
800kHz < f ≤ 1.6MHz
1.6MHz < f ≤ 3.2MHz
C (XOSCMD = 10x)
K Factor = 0.87
K Factor = 2.6
K Factor = 7.7
K Factor = 22
K Factor = 65
K Factor = 180
K Factor = 664
K Factor = 1590
CRYSTAL MODE (Circuit from Figure 14.1, Option 1; XOSCMD = 11x).
Choose XFCN value to match crystal frequency.
AD
RC MODE (Circuit from Figure 14.1, Option 2; XOSCMD = 10x).
Choose XFCN value to match frequency range:
f = 1.23(103) / (R * C), where
f = frequency of oscillation in MHz
C = capacitor value in pF
R = Pull-up resistor value in kΩ
C MODE (Circuit from Figure 14.1, Option 3; XOSCMD = 10x).
Choose K Factor (KF) for the oscillation frequency desired:
f = KF / (C * VDD), where
f = frequency of oscillation in MHz
C = capacitor value on XTAL1, XTAL2 pins in pF
Page 164
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
14.4.
C8051F060/1/2/3
External Crystal Example
IO
N
If a crystal or ceramic resonator is used as an external oscillator source for the MCU, the circuit should be configured
as shown in Figure 14.1, Option 1. The External Oscillator Frequency Control value (XFCN) should be chosen from
the Crystal column of the table in Figure 14.5 (OSCXCN register). For example, an 11.0592 MHz crystal requires an
XFCN setting of 111b.
Enable the external oscillator.
Wait at least1 ms.
Poll for XTLVLD => ‘1’.
Switch the system clock to the external oscillator.
RM
Step 1.
Step 2.
Step 3.
Step 4.
AT
When the crystal oscillator is enabled, the oscillator amplitude detection circuit requires a settle time to achieve
proper bias. Introducing a blanking interval of at least 1 ms between enabling the oscillator and checking the
XTLVLD bit will prevent a premature switch to the external oscillator as the system clock. Switching to the external
oscillator before the crystal oscillator has stabilized can result in unpredictable behavior. The recommended procedure is:
External RC Example
IN
14.5.
FO
Important Note on External Crystals: Crystal oscillator circuits are quite sensitive to PCB layout and external
noise. The crystal should be placed as close as possible to the XTAL pins on the device. The traces should be as short
as possible and shielded with ground plane from any other traces which could introduce noise or interference. Crystal
loading capacitors should be referenced to AGND.
ED
If an RC network is used as an external oscillator source for the MCU, the circuit should be configured as shown in
Figure 14.1, Option 2. The capacitor should be no greater than 100 pF; however for very small capacitors, the total
capacitance may be dominated by parasitic capacitance in the PCB layout. To determine the required External Oscillator Frequency Control value (XFCN) in the OSCXCN Register, first select the RC network value to produce the
desired frequency of oscillation. If the frequency desired is 100 kHz, let R = 246 kΩ and C = 50 pF:
f = 1.23( 103 ) / RC = 1.23 ( 103 ) / [ 246 * 50 ] = 0.1 MHz = 100 kHz
14.6.
VA
NC
Referring to the table in Figure 14.5, the required XFCN setting is 010.
External Capacitor Example
AD
If a capacitor is used as an external oscillator for the MCU, the circuit should be configured as shown in Figure 14.1,
Option 3. The capacitor should be no greater than 100 pF; however for very small capacitors, the total capacitance
may be dominated by parasitic capacitance in the PCB layout. To determine the required External Oscillator Frequency Control value (XFCN) in the OSCXCN Register, select the capacitor to be used and find the frequency of
oscillation from the equations below. Assume VDD = 3.0 V and C = 50 pF:
f = KF / ( C * VDD ) = KF / ( 50 * 3 )
f = KF / 150
If a frequency of roughly 50 kHz is desired, select the K Factor from the table in Figure 14.5 as KF = 7.7:
f = 7.7 / 150 = 0.051 MHz, or 51 kHz
Therefore, the XFCN value to use in this example is 010.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 165
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 166
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
15.
C8051F060/1/2/3
FLASH MEMORY
15.1.
AT
IO
N
The C8051F060/1/2/3 family includes 64k + 128 bytes of on-chip, reprogrammable FLASH memory for program
code and non-volatile data storage. The FLASH memory can be programmed in-system, a single byte at a time,
through the JTAG interface or by software using the MOVX write instructions. Once cleared to logic 0, a FLASH bit
must be erased to set it back to logic 1. The bytes would typically be erased (set to 0xFF) before being reprogrammed.
FLASH write and erase operations are automatically timed by hardware for proper execution; data polling to determine the end of the write/erase operation is not required. The CPU is stalled during write/erase operations while the
device peripherals remain active. Interrupts that occur during FLASH write/eraee operations are held, and are then
serviced in their priority order once the FLASH operation has completed. Refer to Table 15.1 for the electrical characteristics of the FLASH memory.
Programming The Flash Memory
RM
The simplest means of programming the FLASH memory is through the JTAG interface using programming tools
provided by Cygnal or a third party vendor. This is the only means for programming a non-initialized device. For
details on the JTAG commands to program FLASH memory, see Section “25. JTAG (IEEE 1149.1)” on page 301.
IN
FO
The FLASH memory can be programmed from software using the MOVX write instruction with the address and data
byte to be programmed provided as normal operands. Before writing to FLASH memory using MOVX, FLASH write
operations must be enabled by setting the PSWE Program Store Write Enable bit (PSCTL.0) to logic 1. This directs
the MOVX writes to FLASH memory instead of to XRAM, which is the default target. The PSWE bit remains set
until cleared by software. To avoid errant FLASH writes, it is recommended that interrupts be disabled while the
PSWE bit is logic 1.
FLASH memory is read using the MOVC instruction. MOVX reads are always directed to XRAM, regardless of the
state of PSWE.
ED
NOTE: To ensure the integrity of FLASH memory contents, it is strongly recommended that the on-chip VDD
monitor be enabled by connecting the VDD monitor enable pin (MONEN) to VDD in any system that writes
and/or erases FLASH memory from software. See “RESET SOURCES” on page 155 for more information.
VA
NC
A write to FLASH memory can clear bits but cannot set them; only an erase operation can set bits in FLASH. A byte
location to be programmed must be erased before a new value can be written. The 64k byte FLASH memory is
organized in 512-byte pages. The erase operation applies to an entire page (setting all bytes in the page to 0xFF). The
following steps illustrate the algorithm for programming FLASH from user software.
AD
Step 1. Disable interrupts.
Step 2. Set FLWE (FLSCL.0) to enable FLASH writes/erases via user software.
Step 3. Set PSEE (PSCTL.1) to enable FLASH erases.
Step 4. Set PSWE (PSCTL.0) to redirect MOVX commands to write to FLASH.
Step 5. Use the MOVX command to write a data byte to any location within the 512-byte page to be erased.
Step 6. Clear PSEE to disable FLASH erases
Step 7. Use the MOVX command to write a data byte to the desired byte location within the erased 512-byte
page. Repeat this step until all desired bytes are written (within the target page).
Step 8. Clear the PSWE bit to redirect MOVX commands to the XRAM data space.
Step 9. Re-enable interrupts.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 167
C8051F060/1/2/3
Advanced
Information
Write/Erase timing is automatically controlled by hardware. Note that code execution in the 8051 is stalled while the
FLASH is being programmed or erased.
Table 15.1. FLASH Electrical Characteristics
TYP
100k
12
50
MAX
N
MIN
20k
10
40
14
60
IO
CONDITIONS
UNITS
Erase/Write
ms
µs
AD
VA
NC
ED
IN
FO
RM
AT
PARAMETER
Endurance
Erase Cycle Time
Write Cycle Time
Page 168
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
15.2.
C8051F060/1/2/3
Non-volatile Data Storage
N
The FLASH memory can be used for non-volatile data storage as well as program code. This allows data such as calibration coefficients to be calculated and stored at run time. Data is written using the MOVX write instruction (as
described in the previous section) and read using the MOVC instruction.
Security Options
RM
15.3.
AT
IO
An additional 128-byte sector of FLASH memory is included for non-volatile data storage. Its smaller sector size
makes it particularly well suited as general purpose, non-volatile scratchpad memory. Even though FLASH memory
can be written a single byte at a time, an entire sector must be erased first. In order to change a single byte of a multibyte data set, the data must be moved to temporary storage. The 128-byte sector-size facilitates updating data without
wasting program memory or RAM space. The 128-byte sector is double-mapped over the 64k byte FLASH memory;
its address ranges from 0x00 to 0x7F (see Figure 15.1). To access this 128-byte sector, the SFLE bit in PSCTL must
be set to logic 1. Code execution from this 128-byte scratchpad sector is not permitted.
FO
The CIP-51 provides security options to protect the FLASH memory from inadvertent modification by software as
well as prevent the viewing of proprietary program code and constants. The Program Store Write Enable (PSCTL.0)
and the Program Store Erase Enable (PSCTL.1) bits protect the FLASH memory from accidental modification by
software. These bits must be explicitly set to logic 1 before software can write or erase the FLASH memory. Additional security features prevent proprietary program code and data constants from being read or altered across the
JTAG interface or by software running on the system controller.
IN
A set of security lock bytes stored at 0xFBFE and 0xFBFF protect the FLASH program memory from being read or
altered across the JTAG interface. Each bit in a security lock-byte protects one 8k-byte block of memory. Clearing a
bit to logic 0 in a Read Lock Byte prevents the corresponding block of FLASH memory from being read across the
JTAG interface. Clearing a bit in the Write/Erase Lock Byte protects the block from JTAG erasures and/or writes.
AD
VA
NC
ED
The Read Lock Byte is at location 0xFBFF. The Write/Erase Lock Byte is located at 0xFBFE. Figure 15.1 shows the
location and bit definitions of the security bytes. The 512-byte sector containing the lock bytes can be written to, but
not erased by software. An attempted read of a read-locked byte returns undefined data. Debugging code in a readlocked sector is not possible through the JTAG interface. Note: To ensure protection from external access, the
block containing the lock bytes (0xFA00-0xFBFF) must be write/erase locked by clearing the MSB of byte
0xFBFE.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 169
C8051F060/1/2/3
Advanced
Information
7
6
5
4
3
2
1
0
0xE000 - 0xFBFD
0xC000 - 0xDFFF
0xA000 - 0xBFFF
0x8000 - 0x9FFF
0x6000 - 0x7FFF
0x4000 - 0x5FFF
0x2000 - 0x3FFF
0x0000 - 0x1FFF
0xFFFF
Reserved
0xFC00
Read Lock Byte
0xFBFF
Write/Erase Lock Byte
0xFBFE
Scratchpad Memory
(Data only)
0x007F
0x0000
AT
Memory Block
SFLE = 1
0xFBFD
RM
Bit
SFLE = 0
IO
Read and Write/Erase Security Bits.
(Bit 7 is MSB.)
N
Figure 15.1. FLASH Program Memory Map and Security Bytes
Program/Data
Memory Space
FO
Software Read Limit
0x0000
VA
NC
ED
IN
FLASH Read Lock Byte
Bits7-0: Each bit locks a corresponding block of memory. (Bit7 is MSB).
0: Read operations are locked (disabled) for corresponding block across the JTAG interface.
1: Read operations are unlocked (enabled) for corresponding block across the JTAG interface.
FLASH Write/Erase Lock Byte
Bits7-0: Each bit locks a corresponding block of memory.
0: Write/Erase operations are locked (disabled) for corresponding block across the JTAG interface.
1: Write/Erase operations are unlocked (enabled) for corresponding block across the JTAG interface.
NOTE: When the highest block is locked, the security bytes may be written but not erased.
FLASH access Limit Register (FLACL)
The content of this register is used as the high byte of the 16-bit software read limit address. This 16bit read limit address value is calculated as 0xNN00 where NN is replaced by content of this register
on reset. Software running at or above this address is prohibited from using the MOVX and MOVC
instructions to read, write, or erase FLASH locations below this address. Any attempts to read locations below this limit will return the value 0x00.
AD
The lock bits can always be read and cleared to logic 0 regardless of the security setting applied to the block containing the security bytes. This allows additional blocks to be protected after the block containing the security bytes has
been locked. Important Note: The only means of removing a lock once the MSB of the write/erase security byte
is set is to erase the entire program memory space by performing a JTAG erase operation (i.e. cannot be done
in user firmware). Addressing either security byte while performing a JTAG erase operation will automatically initiate erasure of the entire program memory space (except for the reserved area). This erasure can only
be performed via JTAG. If a non-security byte in the 0xFA00-0xFBFF page is addressed during the JTAG erasure, only that page (including the security bytes) will be erased.
The FLASH Access Limit security feature (see Figure 15.1) protects proprietary program code and data from being
read by software running on the C8051F060/1/2/3. This feature provides support for OEMs that wish to program the
Page 170
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
MCU with proprietary value-added firmware before distribution. The value-added firmware can be protected while
allowing additional code to be programmed in remaining program memory space later.
AT
IO
N
The Software Read Limit (SRL) is a 16-bit address that establishes two logical partitions in the program memory
space. The first is an upper partition consisting of all the program memory locations at or above the SRL address, and
the second is a lower partition consisting of all the program memory locations starting at 0x0000 up to (but excluding) the SRL address. Software in the upper partition can execute code in the lower partition, but is prohibited from
reading locations in the lower partition using the MOVC instruction. (Executing a MOVC instruction from the upper
partition with a source address in the lower partition will always return a data value of 0x00.) Software running in the
lower partition can access locations in both the upper and lower partition without restriction.
RM
The Value-added firmware should be placed in the lower partition. On reset, control is passed to the value-added
firmware via the reset vector. Once the value-added firmware completes its initial execution, it branches to a predetermined location in the upper partition. If entry points are published, software running in the upper partition may execute program code in the lower partition, but it cannot read the contents of the lower partition. Parameters may be
passed to the program code running in the lower partition either through the typical method of placing them on the
stack or in registers before the call or by placing them in prescribed memory locations in the upper partition.
IN
FO
The SRL address is specified using the contents of the FLASH Access Register. The 16-bit SRL address is calculated
as 0xNN00, where NN is the contents of the SRL Security Register. Thus, the SRL can be located on 256-byte boundaries anywhere in program memory space. However, the 512-byte erase sector size essentially requires that a 512
boundary be used. The contents of a non-initialized SRL security byte is 0x00, thereby setting the SRL address to
0x0000 and allowing read access to all locations in program memory space by default.
Figure 15.2. FLACL: FLASH Access Limit
Bit5
R/W
Bit4
R/W
R/W
R/W
R/W
Reset Value
00000000
Bit3
Bit2
Bit1
Bit0
SFR Address:
SFR Address: 0xB7
SFR Page: F
FLACL: FLASH Access Limit.
This register holds the high byte of the 16-bit program memory read/write/erase limit address. The
entire 16-bit access limit address value is calculated as 0xNN00 where NN is replaced by contents of
FLACL. A write to this register sets the FLASH Access Limit. This register can only be written once
after any reset. Any subsequent writes are ignored until the next reset. To fully protect all addresses
below this limit, bit 0 of FLACL should be set to ‘0’.
AD
Bits 7-0:
Bit6
R/W
ED
Bit7
R/W
VA
NC
R/W
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 171
C8051F060/1/2/3
Advanced
Information
R/W
R/W
R/W
R/W
R/W
R/W
FRAE
Reserved
Reserved
Reserved
Reserved
Reserved
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
Reset Value
FLWE
10000000
IO
R/W
FOSE
N
Figure 15.3. FLSCL: FLASH Memory Control
Bit0
SFR Address:
Bit 6:
AD
VA
NC
ED
IN
FO
Bits 5-1:
Bit 0:
FOSE: FLASH One-Shot Timer Enable
This is the timer that turns off the sense amps after a FLASH read.
0: FLASH One-Shot Timer disabled.
1: FLASH One-Shot Timer enabled (recommended setting.)
FRAE: FLASH Read Always Enable
0: FLASH reads occur as necessary (recommended setting.).
1: FLASH reads occur every system clock cycle.
RESERVED. Read = 00000b. Must Write 00000b.
FLWE: FLASH Write/Erase Enable
This bit must be set to allow FLASH writes/erases from user software.
0: FLASH writes/erases disabled.
1: FLASH writes/erases enabled.
RM
Bit 7:
AT
SFR Address: 0xB7
SFR Page: 0
Page 172
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
R/W
R/W
R/W
R/W
R/W
-
-
-
-
SFLE
PSEE
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
Reset Value
PSWE
00000000
Bit0
SFR Address:
IO
Bit7
N
Figure 15.4. PSCTL: Program Store Read/Write Control
AD
VA
NC
ED
Bit 0:
IN
FO
Bit 1:
UNUSED. Read = 00000b, Write = don't care.
SFLE: Scratchpad FLASH Memory Access Enable
When this bit is set, FLASH MOVC reads and writes from user software are directed to the 128-byte
Scratchpad FLASH sector. When SFLE is set to logic 1, FLASH accesses out of the address range
0x00-0x7F should not be attempted. Reads/Writes out of this range will yield undefined results.
0: FLASH access from user software directed to the 64k byte Program/Data FLASH sector.
1: FLASH access from user software directed to the 128 byte Scratchpad sector.
PSEE: Program Store Erase Enable.
Setting this bit allows an entire page of the FLASH program memory to be erased provided the
PSWE bit is also set. After setting this bit, a write to FLASH memory using the MOVX instruction
will erase the entire page that contains the location addressed by the MOVX instruction. The value of
the data byte written does not matter. Note: The FLASH page containing the Read Lock Byte and
Write/Erase Lock Byte cannot be erased by software.
0: FLASH program memory erasure disabled.
1: FLASH program memory erasure enabled.
PSWE: Program Store Write Enable.
Setting this bit allows writing a byte of data to the FLASH program memory using the MOVX write
instruction. The location must be erased prior to writing data.
0: Write to FLASH program memory disabled. MOVX write operations target External RAM.
1: Write to FLASH program memory enabled. MOVX write operations target FLASH memory.
RM
Bits 7-3:
Bit 2:
AT
SFR Address: 0x8F
SFR Page: 0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 173
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 174
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
16.
C8051F060/1/2/3
EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM
16.1.
AT
IO
N
The C8051F060/1/2/3 MCUs include 4k bytes of on-chip RAM mapped into the external data memory space
(XRAM). In addition, the C8051F060/2 include an External Data Memory Interface which can be used to access offchip memories and memory-mapped devices connected to the GPIO ports. The external memory space may be
accessed using the external move instruction (MOVX) and the data pointer (DPTR), or using the MOVX indirect
addressing mode using R0 or R1. If the MOVX instruction is used with an 8-bit address operand (such as @R1), then
the high byte of the 16-bit address is provided by the External Memory Interface Control Register (EMI0CN, shown
in Figure 16.1). Note: the MOVX instruction can also be used for writing to the FLASH memory. See Section
“15. FLASH MEMORY” on page 167 for details. The MOVX instruction accesses XRAM by default.
Accessing XRAM
RM
The XRAM memory space (both internal and external) is accessed using the MOVX instruction. The MOVX instruction has two forms, both of which use an indirect addressing method. The first method uses the Data Pointer, DPTR,
a 16-bit register which contains the effective address of the XRAM location to be read or written. The second method
uses R0 or R1 in combination with the EMI0CN register to generate the effective XRAM address. Examples of both
of these methods are given below.
FO
16.1.1. 16-Bit MOVX Example
The 16-bit form of the MOVX instruction accesses the memory location pointed to by the contents of the DPTR register. The following series of instructions reads the value of the byte at address 0x1234 into the accumulator A:
DPTR, #1234h
A, @DPTR
; load DPTR with 16-bit address to read (0x1234)
; load contents of 0x1234 into accumulator A
IN
MOV
MOVX
16.1.2. 8-Bit MOVX Example
ED
The above example uses the 16-bit immediate MOV instruction to set the contents of DPTR. Alternately, the DPTR
can be accessed through the SFR registers DPH, which contains the upper 8-bits of DPTR, and DPL, which contains
the lower 8-bits of DPTR.
EMI0CN, #12h
R0, #34h
a, @R0
; load high byte of address into EMI0CN
; load low byte of address into R0 (or R1)
; load contents of 0x1234 into accumulator A
AD
MOV
MOV
MOVX
VA
NC
The 8-bit form of the MOVX instruction uses the contents of the EMI0CN SFR to determine the upper 8-bits of the
effective address to be accessed and the contents of R0 or R1 to determine the lower 8-bits of the effective address to
be accessed. The following series of instructions read the contents of the byte at address 0x1234 into the accumulator
A.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 175
C8051F060/1/2/3
16.2.
Advanced
Information
Configuring the External Memory Interface
Configuring the External Memory Interface consists of four steps:
AT
IO
N
1. Enable the EMIF on the High Ports (P7, P6, P5, and P4).
2. Configure the Output Modes of the port pins as either push-pull or open-drain (push-pull is most common).
3. Configure Port latches to “park” the EMIF pins in a dormant state (usually by setting them to logic ‘1’).
4. Select Multiplexed mode or Non-multiplexed mode.
5. Select the memory mode (on-chip only, split mode without bank select, split mode with bank select, or
off-chip only).
6. Set up timing to interface with off-chip memory or peripherals.
16.3.
RM
Each of these four steps is explained in detail in the following sections. The Port enable bit, Multiplexed mode selection, and Mode bits are located in the EMI0CF register shown in Figure 16.2.
Port Selection and Configuration
FO
When enabled, the External Memory Interface appears on Ports 7, 6, 5, and 4 in non-multiplexed mode, or Ports 7, 6,
and 4 in multiplexed mode.
IN
The External Memory Interface claims the associated Port pins for memory operations ONLY during the execution of
an off-chip MOVX instruction. Once the MOVX instruction has completed, control of the Port pins reverts to the Port
latches. See Section “17. PORT INPUT/OUTPUT” on page 191 for more information about the Port operation and
configuration. The Port latches should be explicitly configured to ‘park’ the External Memory Interface pins in
a dormant state, most commonly by setting them to a logic 1.
AD
VA
NC
ED
During the execution of the MOVX instruction, the External Memory Interface will explicitly disable the drivers on
all Port pins that are acting as Inputs (Data[7:0] during a READ operation, for example). The Output mode of the Port
pins (whether the pin is configured as Open-Drain or Push-Pull) is unaffected by the External Memory Interface operation, and remains controlled by the PnMDOUT registers. See Section “17. PORT INPUT/OUTPUT” on page 191
for more information about Port output mode configuration.
Page 176
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 16.1. EMI0CN: External Memory Interface Control
R/W
R/W
R/W
R/W
R/W
PGSEL5
PGSEL4
PGSEL3
PGSEL2
PGSEL1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
Reset Value
PGSEL0
00000000
N
R/W
PGSEL6
Bit0
IO
R/W
PGSEL7
SFR Address: 0xA2
SFR Page: 0
AT
PGSEL[7:0]: XRAM Page Select Bits.
The XRAM Page Select Bits provide the high byte of the 16-bit external data memory address when
using an 8-bit MOVX command, effectively selecting a 256-byte page of RAM.
0x00: 0x0000 to 0x00FF
0x01: 0x0100 to 0x01FF
...
0xFE: 0xFE00 to 0xFEFF
0xFF: 0xFF00 to 0xFFFF
RM
Bits7-0:
R/W
R/W
R/W
-
-
PRTSEL
EMD2
Bit7
Bit6
Bit5
Bit4
R/W
Reset Value
EALE0
00000011
Bit2
Bit1
Bit3
Bit0
SFR Address: 0xA3
SFR Page: 0
Unused. Read = 00b. Write = don’t care.
PRTSEL: EMIF Port Select.
0: EMIF not mapped to port pins.
1: EMIF active on P4-P7.
EMD2: EMIF Multiplex Mode Select.
0: EMIF operates in multiplexed address/data mode.
1: EMIF operates in non-multiplexed mode (separate address and data pins).
EMD1-0: EMIF Operating Mode Select.
These bits control the operating mode of the External Memory Interface.
00: Internal Only: MOVX accesses on-chip XRAM only. All effective addresses alias to on-chip
memory space.
01: Split Mode without Bank Select: Accesses below the 4k boundary are directed on-chip. Accesses
above the 4k boundary are directed off-chip. 8-bit off-chip MOVX operations use the current contents
of the Address High port latches to resolve upper address byte. Note that in order to access off-chip
space, EMI0CN must be set to a page that is not contained in the on-chip address space.
10: Split Mode with Bank Select: Accesses below the 4k boundary are directed on-chip. Accesses
above the 4k boundary are directed off-chip. 8-bit off-chip MOVX operations use the contents of
EMI0CN to determine the high-byte of the address.
11: External Only: MOVX accesses off-chip XRAM only. On-chip XRAM is not visible to the CPU.
EALE1-0: ALE Pulse-Width Select Bits (only has effect when EMD2 = 0).
00: ALE high and ALE low pulse width = 1 SYSCLK cycle.
01: ALE high and ALE low pulse width = 2 SYSCLK cycles.
10: ALE high and ALE low pulse width = 3 SYSCLK cycles.
11: ALE high and ALE low pulse width = 4 SYSCLK cycles.
AD
Bits3-2:
R/W
EALE1
ED
Bit4:
R/W
EMD0
VA
NC
Bits7-6:
Bit5:
R/W
EMD1
IN
R/W
FO
Figure 16.2. EMI0CF: External Memory Configuration
Bits1-0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 177
C8051F060/1/2/3
16.4.
Advanced
Information
Multiplexed and Non-multiplexed Selection
N
The External Memory Interface is capable of acting in a Multiplexed mode or a Non-multiplexed mode, depending
on the state of the EMD2 (EMI0CF.4) bit.
16.4.1. Multiplexed Configuration
AT
IO
In Multiplexed mode, the Data Bus and the lower 8-bits of the Address Bus share the same Port pins: AD[7:0]. In this
mode, an external latch (74HC373 or equivalent logic gate) is used to hold the lower 8-bits of the RAM address. The
external latch is controlled by the ALE (Address Latch Enable) signal, which is driven by the External Memory Interface logic. An example of a Multiplexed Configuration is shown in Figure 16.3.
RM
In Multiplexed mode, the external MOVX operation can be broken into two phases delineated by the state of the ALE
signal. During the first phase, ALE is high and the lower 8-bits of the Address Bus are presented to AD[7:0]. During
this phase, the address latch is configured such that the ‘Q’ outputs reflect the states of the ‘D’ inputs. When ALE
falls, signaling the beginning of the second phase, the address latch outputs remain fixed and are no longer dependent
on the latch inputs. Later in the second phase, the Data Bus controls the state of the AD[7:0] port at the time /RD or /
WR is asserted.
FO
See Section “16.6.2. Multiplexed Mode” on page 186 for more information.
Figure 16.3. Multiplexed Configuration Example
Page 178
A[15:8]
74HC373
G
ADDRESS/DATA BUS
VA
NC
AD[7:0]
(P7)
D
Q
A[7:0]
VDD
64K X 8
SRAM
(Optional)
8
I/O[7:0]
/RD (P4.6)
OE
/WR (P4.7)
WE
AD
E
M
I
F
ADDRESS BUS
ED
ALE (P4.5)
IN
A[15:8]
(P6)
CE
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
16.4.2. Non-multiplexed Configuration
N
In Non-multiplexed mode, the Data Bus and the Address Bus pins are not shared. An example of a Non-multiplexed
Configuration is shown in Figure 16.4. See Section “16.6.1. Non-multiplexed Mode” on page 183 for more information about Non-multiplexed operation.
A[15:0]
VDD
RM
(Optional)
8
D[7:0]
(P7)
FO
DATA BUS
/RD (P4.6)
/WR (P4.7)
64K X 8
SRAM
I/O[7:0]
OE
WE
CE
AD
VA
NC
ED
IN
E
M
I
F
ADDRESS BUS
AT
A[15:0]
(P5 and P6)
IO
Figure 16.4. Non-multiplexed Configuration Example
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 179
Advanced
Information
C8051F060/1/2/3
16.5.
Memory Mode Selection
N
The external data memory space can be configured in one of four modes, shown in Figure 16.5, based on the EMIF
Mode bits in the EMI0CF register (Figure 16.2). These modes are summarized below. More information about the
different modes can be found in Section “16.6. Timing” on page 182.
IO
16.5.1. Internal XRAM Only
•
8-bit MOVX operations use the contents of EMI0CN to determine the high-byte of the effective address and R0
or R1 to determine the low-byte of the effective address.
16-bit MOVX operations use the contents of the 16-bit DPTR to determine the effective address.
RM
•
AT
When EMI0CF.[3:2] are set to ‘00’, all MOVX instructions will target the internal XRAM space on the device. Memory accesses to addresses beyond the populated space will wrap on 4k boundaries. As an example, the addresses
0x1000 and 0x2000 both evaluate to address 0x0000 in on-chip XRAM space.
16.5.2. Split Mode without Bank Select
When EMI0CF.[3:2] are set to ‘01’, the XRAM memory map is split into two areas, on-chip space and off-chip space.
FO
VA
NC
ED
•
Effective addresses below the 4k boundary will access on-chip XRAM space.
Effective addresses beyond the 4k boundary will access off-chip space.
8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-chip or offchip. However, in the “No Bank Select” mode, an 8-bit MOVX operation will not drive the upper 8-bits A[15:8]
of the Address Bus during an off-chip access. This allows the user to manipulate the upper address bits at will by
setting the Port state directly. This behavior is in contrast with “Split Mode with Bank Select” described below.
The lower 8-bits of the Address Bus A[7:0] are driven, determined by R0 or R1.
16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-chip or offchip, and unlike 8-bit MOVX operations, the full 16-bits of the Address Bus A[15:0] are driven during the offchip transaction.
IN
•
•
•
Figure 16.5. EMIF Operating Modes
EMI0CF[3:2] = 00
EMI0CF[3:2] = 01
0xFFFF
On-Chip XRAM
AD
On-Chip XRAM
EMI0CF[3:2] = 10
Off-Chip
Memory
(No Bank Select)
EMI0CF[3:2] = 11
0xFFFF
0xFFFF
0xFFFF
Off-Chip
Memory
(Bank Select)
On-Chip XRAM
Off-Chip
Memory
On-Chip XRAM
On-Chip XRAM
On-Chip XRAM
On-Chip XRAM
On-Chip XRAM
0x0000
Page 180
0x0000
0x0000
0x0000
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
16.5.3. Split Mode with Bank Select
When EMI0CF.[3:2] are set to ‘10’, the XRAM memory map is split into two areas, on-chip space and off-chip space.
N
IO
•
Effective addresses below the 4k boundary will access on-chip XRAM space.
Effective addresses beyond the 4k boundary will access off-chip space.
8-bit MOVX operations use the contents of EMI0CN to determine whether the memory access is on-chip or offchip. The upper 8-bits of the Address Bus A[15:8] are determined by EMI0CN, and the lower 8-bits of the
Address Bus A[7:0] are determined by R0 or R1. All 16-bits of the Address Bus A[15:0] are driven in “Bank
Select” mode.
16-bit MOVX operations use the contents of DPTR to determine whether the memory access is on-chip or offchip, and the full 16-bits of the Address Bus A[15:0] are driven during the off-chip transaction.
AT
•
•
•
16.5.4. External Only
AD
VA
NC
ED
IN
•
8-bit MOVX operations ignore the contents of EMI0CN. The upper Address bits A[15:8] are not driven (identical behavior to an off-chip access in “Split Mode without Bank Select” described above). This allows the user to
manipulate the upper address bits at will by setting the Port state directly. The lower 8-bits of the effective
address A[7:0] are determined by the contents of R0 or R1.
16-bit MOVX operations use the contents of DPTR to determine the effective address A[15:0]. The full 16-bits
of the Address Bus A[15:0] are driven during the off-chip transaction.
FO
•
RM
When EMI0CF[3:2] are set to ‘11’, all MOVX operations are directed to off-chip space. On-chip XRAM is not visible to the CPU. This mode is useful for accessing off-chip memory located between 0x0000 and the 4k boundary.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 181
C8051F060/1/2/3
16.6.
Advanced
Information
Timing
IO
N
The timing parameters of the External Memory Interface can be configured to enable connection to devices having
different setup and hold time requirements. The Address Setup time, Address Hold time, /RD and /WR strobe widths,
and in multiplexed mode, the width of the ALE pulse are all programmable in units of SYSCLK periods through
EMI0TC, shown in Figure 16.6, and EMI0CF[1:0].
AT
Assuming non-multiplexed operation, the minimum execution time for an off-chip XRAM operation is 4 SYSCLK
cycles: 3 cycles for the MOVX operation + 1 cycle for the /RD or /WR pulse duration. The programmable setup and
hold times default to the maximum delay settings after a reset.
R/W
RM
Table 16.1 lists the AC parameters for the External Memory Interface, and Figure 16.7 through Figure 16.12 show the
timing diagrams for the different External Memory Interface modes and MOVX operations.
R/W
R/W
R/W
Reset Value
EWR1
EWR0
EAH1
EAH0
11111111
Bit3
Bit2
Bit1
Bit0
R/W
R/W
R/W
EAS0
ERW3
EWR2
Bit7
Bit6
Bit5
Bit4
AD
VA
NC
Bits5-2:
EAS1-0: EMIF Address Setup Time Bits.
00: Address setup time = 0 SYSCLK cycles.
01: Address setup time = 1 SYSCLK cycle.
10: Address setup time = 2 SYSCLK cycles.
11: Address setup time = 3 SYSCLK cycles.
EWR3-0: EMIF /WR and /RD Pulse-Width Control Bits.
0000: /WR and /RD pulse width = 1 SYSCLK cycle.
0001: /WR and /RD pulse width = 2 SYSCLK cycles.
0010: /WR and /RD pulse width = 3 SYSCLK cycles.
0011: /WR and /RD pulse width = 4 SYSCLK cycles.
0100: /WR and /RD pulse width = 5 SYSCLK cycles.
0101: /WR and /RD pulse width = 6 SYSCLK cycles.
0110: /WR and /RD pulse width = 7 SYSCLK cycles.
0111: /WR and /RD pulse width = 8 SYSCLK cycles.
1000: /WR and /RD pulse width = 9 SYSCLK cycles.
1001: /WR and /RD pulse width = 10 SYSCLK cycles.
1010: /WR and /RD pulse width = 11 SYSCLK cycles.
1011: /WR and /RD pulse width = 12 SYSCLK cycles.
1100: /WR and /RD pulse width = 13 SYSCLK cycles.
1101: /WR and /RD pulse width = 14 SYSCLK cycles.
1110: /WR and /RD pulse width = 15 SYSCLK cycles.
1111: /WR and /RD pulse width = 16 SYSCLK cycles.
EAH1-0: EMIF Address Hold Time Bits.
00: Address hold time = 0 SYSCLK cycles.
01: Address hold time = 1 SYSCLK cycle.
10: Address hold time = 2 SYSCLK cycles.
11: Address hold time = 3 SYSCLK cycles.
ED
Bits7-6:
SFR Address: 0xA1
SFR Page: 0
IN
R/W
EAS1
FO
Figure 16.6. EMI0TC: External Memory Timing Control
Bits1-0:
Page 182
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
16.6.1. Non-multiplexed Mode
16.6.1.1. 16-bit MOVX: EMI0CF[4:2] = ‘101’, ‘110’, or ‘111’.
N
Figure 16.7. Non-multiplexed 16-bit MOVX Timing
IO
Nonmuxed 16-bit WRITE
P5
EMIF ADDRESS (8 MSBs) from DPH
ADDR[7:0]
P6
EMIF ADDRESS (8 LSBs) from DPL
P6
DATA[7:0]
P7
EMIF WRITE DATA
P7
T
WDS
T
P4.6
T
ACW
ACH
FO
/RD
WDH
P4.7
P4.6
IN
P4.7
P5
T
T
ACS
/WR
RM
AT
ADDR[15:8]
P5
ADDR[7:0]
P6
DATA[7:0]
AD
/RD
VA
NC
ADDR[15:8]
/WR
ED
Nonmuxed 16-bit READ
EMIF ADDRESS (8 MSBs) from DPH
P5
EMIF ADDRESS (8 LSBs) from DPL
P6
EMIF READ DATA
P7
P7
T
RDS
T
ACS
T
ACW
T
RDH
T
ACH
P4.6
P4.6
P4.7
P4.7
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 183
Advanced
Information
C8051F060/1/2/3
16.6.1.2. 8-bit MOVX without Bank Select: EMI0CF[4:2] = ‘101’ or ‘111’.
Figure 16.8. Non-multiplexed 8-bit MOVX without Bank Select Timing
ADDR[15:8]
IO
N
Nonmuxed 8-bit WRITE without Bank Select
P5
P6
EMIF ADDRESS (8 LSBs) from R0 or R1
P6
DATA[7:0]
P7
EMIF WRITE DATA
P7
T
WDS
T
P4.6
ACW
ACH
P4.7
FO
/RD
WDH
T
P4.6
IN
P4.7
T
T
ACS
/WR
RM
AT
ADDR[7:0]
Nonmuxed 8-bit READ without Bank Select
P6
DATA[7:0]
AD
/RD
VA
NC
ADDR[7:0]
/WR
Page 184
P5
ED
ADDR[15:8]
EMIF ADDRESS (8 LSBs) from R0 or R1
P7
EMIF READ DATA
T
RDS
T
ACS
T
ACW
P6
P7
T
RDH
T
ACH
P4.6
P4.6
P4.7
P4.7
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
16.6.1.3. 8-bit MOVX with Bank Select: EMI0CF[4:2] = ‘110’.
IO
Nonmuxed 8-bit WRITE with Bank Select
N
Figure 16.9. Non-multiplexed 8-bit MOVX with Bank Select Timing
P5
EMIF ADDRESS (8 MSBs) from EMI0CN
P5
ADDR[7:0]
P6
EMIF ADDRESS (8 LSBs) from R0 or R1
P6
DATA[7:0]
P7
EMIF WRITE DATA
P7
T
WDS
T
P4.6
ACW
ACH
P4.7
FO
/RD
WDH
T
P4.6
IN
P4.7
T
T
ACS
/WR
RM
AT
ADDR[15:8]
Nonmuxed 8-bit READ with Bank Select
ADDR[7:0]
P6
DATA[7:0]
AD
/RD
/WR
EMIF ADDRESS (8 MSBs) from EMI0CN
P5
EMIF ADDRESS (8 LSBs) from R0 or R1
P6
ED
P5
VA
NC
ADDR[15:8]
P7
EMIF READ DATA
T
RDS
T
ACS
T
ACW
P7
T
RDH
T
ACH
P4.6
P4.6
P4.7
P4.7
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 185
C8051F060/1/2/3
Advanced
Information
16.6.2. Multiplexed Mode
16.6.2.1. 16-bit MOVX: EMI0CF[4:2] = ‘001’, ‘010’, or ‘011’.
N
Figure 16.10. Multiplexed 16-bit MOVX Timing
AD[7:0]
P7
EMIF ADDRESS (8 MSBs) from DPH
EMIF ADDRESS (8 LSBs) from
DPL
T
ALEH
ALE
EMIF WRITE DATA
AT
P6
T
ALEL
P4.5
RM
ADDR[15:8]
IO
Muxed 16-bit WRITE
T
WDS
P4.7
/RD
P4.6
T
ACW
ACH
P4.7
P4.6
IN
/WR
WDH
T
FO
ACS
P7
P4.5
T
T
P6
Muxed 16-bit READ
P6
AD[7:0]
P7
EMIF ADDRESS (8 MSBs) from DPH
EMIF ADDRESS (8 LSBs) from
DPL
T
ALE
/RD
T
T
ALEL
RDS
P7
T
RDH
P4.5
P4.5
T
ACS
T
ACW
T
ACH
P4.6
P4.6
P4.7
P4.7
AD
/WR
VA
NC
ALEH
P6
EMIF READ DATA
ED
ADDR[15:8]
Page 186
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
16.6.2.2. 8-bit MOVX without Bank Select: EMI0CF[4:2] = ‘001’ or ‘011’.
Figure 16.11. Multiplexed 8-bit MOVX without Bank Select Timing
P7
EMIF ADDRESS (8 LSBs) from
R0 or R1
T
ALEH
ALE
EMIF WRITE DATA
T
ALEL
P4.5
RM
T
AT
AD[7:0]
P6
IO
ADDR[15:8]
N
Muxed 8-bit WRITE Without Bank Select
P4.5
T
WDS
T
/WR
P4.7
/RD
P4.6
WDH
T
T
ACW
ACH
P4.7
FO
ACS
P7
P4.6
IN
Muxed 8-bit READ Without Bank Select
ADDR[15:8]
P7
EMIF ADDRESS (8 LSBs) from
R0 or R1
T
ALEH
P4.5
VA
NC
ALE
EMIF READ DATA
T
ED
AD[7:0]
P6
T
ALEL
RDS
P7
T
RDH
P4.5
T
ACS
T
ACW
T
ACH
P4.6
P4.6
/WR
P4.7
P4.7
AD
/RD
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 187
C8051F060/1/2/3
Advanced
Information
16.6.2.3. 8-bit MOVX with Bank Select: EMI0CF[4:2] = ‘010’.
Figure 16.12. Multiplexed 8-bit MOVX with Bank Select Timing
AD[7:0]
P7
EMIF ADDRESS (8 MSBs) from EMI0CN
EMIF ADDRESS (8 LSBs) from
R0 or R1
T
ALEH
ALE
IO
P6
EMIF WRITE DATA
T
ALEL
P4.5
RM
T
AT
ADDR[15:8]
N
Muxed 8-bit WRITE with Bank Select
T
/WR
P4.7
/RD
P4.6
WDH
T
T
ACW
ACH
P4.7
FO
ACS
P7
P4.5
WDS
T
P6
P4.6
ADDR[15:8]
P6
AD[7:0]
P7
IN
Muxed 8-bit READ with Bank Select
EMIF ADDRESS (8 MSBs) from EMI0CN
EMIF ADDRESS (8 LSBs) from
R0 or R1
T
P4.5
VA
NC
ALE
EMIF READ DATA
T
T
ALEL
ED
ALEH
P6
RDS
P7
T
RDH
P4.5
T
ACS
T
ACW
T
ACH
P4.6
P4.6
/WR
P4.7
P4.7
AD
/RD
Page 188
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 16.1. AC Parameters for External Memory Interface
DESCRIPTION
MIN
TSYSCLK
System Clock Period
40
TACS
Address / Control Setup Time
0
TACW
Address / Control Pulse Width
TACH
Address / Control Hold Time
TALEH
Address Latch Enable High Time
TALEL
Address Latch Enable Low Time
TWDS
Write Data Setup Time
TWDH
Write Data Hold Time
TRDS
Read Data Setup Time
TRDH
Read Data Hold Time
MAX
N
PARAMETER
ns
ns
1*TSYSCLK
16*TSYSCLK
ns
0
3*TSYSCLK
ns
1*TSYSCLK
4*TSYSCLK
ns
1*TSYSCLK
4*TSYSCLK
ns
1*TSYSCLK
19*TSYSCLK
ns
0
3*TSYSCLK
ns
AT
IO
3*TSYSCLK
20
ns
0
ns
AD
VA
NC
ED
IN
FO
RM
UNITS
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 189
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 190
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
17.
C8051F060/1/2/3
PORT INPUT/OUTPUT
IO
N
The C8051F06x family of devices are fully integrated mixed-signal System on a Chip MCUs with 59 digital I/O pins
(C8051F060/2) or 24 digital I/O pins (C8051F061/3), organized as 8-bit Ports. All ports are both bit- and byteaddressable through their corresponding Port Data registers. All Port pins support configurable Open-Drain or PushPull output modes and weak pull-ups. Additionally, Port 0 pins are 5 V-tolerant. A block diagram of the Port I/O cell
is shown in Figure 17.1. Complete Electrical Specifications for the Port I/O pins are given in Table 17.1.
Figure 17.1. Port I/O Cell Block Diagram
AT
/WEAK-PULLUP
VDD
VDD
RM
PUSH-PULL
/PORT-OUTENABLE
FO
PORT-OUTPUT
PORT
PAD
DGND
IN
Analog Select
(Port 1 and 2 Only)
(WEAK)
ANALOG INPUT
VA
NC
ED
PORT-INPUT
Table 17.1. Port I/O DC Electrical Characteristics
VDD = 2.7 V to 3.6 V, -40°C to +85°C unless otherwise specified.
PARAMETER
CONDITIONS
Output High Voltage (VOH) IOH = -3 mA, Port I/O Push-Pull
IOH = -10 µA, Port I/O Push-Pull
MIN
TYP
VDD - 0.7
VDD - 0.1
AD
0.6
0.1
V
0.7 x VDD
Input Low Voltage (VIL)
Input Leakage Current
UNITS
V
Output Low Voltage (VOL) IOL = 8.5 mA
IOL = 10 µA
Input High Voltage (VIH)
MAX
0.3 x VDD
DGND < Port Pin < VDD, Pin Tri-state
Weak Pull-up Off
Weak Pull-up On
Input Capacitance
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
µA
±1
10
5
pF
Page 191
C8051F060/1/2/3
Advanced
Information
IO
N
The C8051F06x family of devices have a wide array of digital resources which are available through the four lower I/
O Ports: P0, P1, P2, and (on the C8051F060/2) P3. Each of the pins on P0, P1, P2, and P3, can be defined as a General-Purpose I/O (GPIO) pin or can be controlled by a digital peripheral or function (like UART0 or /INT1 for example), as shown in Figure 17.2. The system designer controls which digital functions are assigned pins, limited only by
the number of pins available. This resource assignment flexibility is achieved through the use of a Priority Crossbar
Decoder. Note that the state of a Port I/O pin can always be read from its associated Data register regardless of
whether that pin has been assigned to a digital peripheral or behaves as GPIO. The Port pins on Ports 1, and 2 can be
used as Analog Inputs to ADC2 or the Analog Voltage Comparators, respectively
AT
An External Memory Interface which is active during the execution of a MOVX instruction whose target address
resides in off-chip memory can be active on either the lower Ports or the upper Ports. See Section “16. EXTERNAL
DATA MEMORY INTERFACE AND ON-CHIP XRAM” on page 175 for more information about the External
Memory Interface.
RM
The upper Ports (available on C8051F060/2) can be byte-accessed as GPIO pins.
UART0
2
SMBus
P0MDOUT, P1MDOUT,
P2MDOUT, P3MDOUT
Registers
External
Pins
Priority
Decoder
2
UART1
8
6
PCA
2
Comptr.
Outputs
T0, T1,
T2, T2EX,
T3, T3EX,
T4,T4EX,
/INT0,
/INT1
VA
NC
(Internal Digital Signals)
IN
4
SPI
Lowest
Priority
XBR0, XBR1, XBR2,
XBR3 P1MDIN,
P2MDIN, P3MDIN
Registers
2
ED
Highest
Priority
FO
Figure 17.2. Port I/O Functional Block Diagram
Digital
Crossbar
8
P0
I/O
Cells
P0.0
P1
I/O
Cells
P1.0
Highest
Priority
P0.7
P1.7
8
8
/SYSCLK
P2
I/O
Cells
P2.0
P3
I/O
Cells
P3.0
P2.7
CNVSTR2
AD
8
P0
P1
Port
Latches
P2
8
P3.7
Lowest
Priority
(P0.0-P0.7)
8
(P1.0-P1.7)
8
To
ADC2
Input
C8051F060/2
Only
To
Comparators
(P2.0-P2.7)
8
P3
Page 192
(P3.0-P3.7)
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
17.1.
C8051F060/1/2/3
Ports 0 through 3 and the Priority Crossbar Decoder
IO
N
The Priority Crossbar Decoder, or “Crossbar”, allocates and assigns Port pins on Port 0 through Port 3 to the digital
peripherals (UARTs, SMBus, PCA, Timers, etc.) on the device using a priority order. The Port pins are allocated in
order starting with P0.0 and continue through P3.7 (on the C8051F060/2) or P2.7 (on the C8051F061/3) if necessary.
The digital peripherals are assigned Port pins in a priority order which is listed in Figure 17.3, with UART0 having
the highest priority and CNVSTR2 having the lowest priority.
17.1.1. Crossbar Pin Assignment and Allocation
RM
AT
The Crossbar assigns Port pins to a peripheral if the corresponding enable bits of the peripheral are set to a logic 1 in
the Crossbar configuration registers XBR0, XBR1, XBR2, and XBR3, shown in Figure 17.5, Figure 17.6,
Figure 17.7, and Figure 17.8. For example, if the UART0EN bit (XBR0.2) is set to a logic 1, the TX0 and RX0 pins
will be mapped to P0.0 and P0.1 respectively. Because UART0 has the highest priority, its pins will always be
mapped to P0.0 and P0.1 when UART0EN is set to a logic 1. If a digital peripheral’s enable bits are not set to a
logic 1, then its ports are not accessible at the Port pins of the device. Also note that the Crossbar assigns pins to all
P0
PIN I/O 0
1
2
3
P1
4
5
6
7
0
1
2
3
P2
4
5
6
7
●
TX0
●
●
●
MISO
●
●
MOSI
●
●
NSS
●
●
TX1
●
CEX0
● ● ● ● ●
● ● ● ● ● ● ●
●
RX1
0
1
2
3
Crossbar Register Bits
4
5
6
7
UART0EN: XBR0.2
SPI0EN: XBR0.1
SMB0EN: XBR0.0
UART1EN: XBR2.2
PCA0ME: XBR0.[5:3]
● ● ● ● ● ● ● ● ●
●
CEX5
7
● ● ● ● ● ● ● ● ●
●
CEX4
6
● ● ● ● ● ● ● ● ●
●
CEX3
P3
5
● ● ● ● ● ● ● ● ●
●
CEX2
4
● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ●
●
CEX1
3
NSS is not assigned to a port pin when the SPI is placed in 3-wire mode
● ● ● ● ●
●
SCL
●
2
VA
NC
SDA
1
IN
●
SCK
0
ED
RX0
FO
Figure 17.3. Priority Crossbar Decode Table
● ● ● ● ● ● ● ● ●
ECI
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
ECI0E: XBR0.6
CP0
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
CP0E: XBR0.7
CP1
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
CP1E: XBR1.0
CP2
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
CP2E: XBR3.3
T0
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
/INT0
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
T1
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
T2
T2EX
T3
T3EX
T1E: XBR1.3
AD
/INT1
T0E: XBR1.1
INT0E: XBR1.2
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
T2E: XBR1.5
T2EXE: XBR1.6
T3E: XBR3.0
T3EXE: XBR3.1
T4E: XBR2.3
T4EXE: XBR2.4
SYSCKE: XBR1.7
CNVSTE2: XBR3.2
CP0-
CP0+
CP2-
CP2+
CP1-
CP1+
AIN2.7
AIN2.6
AIN2.5
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
AIN2.4
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
CNVSTR2
AIN2.3
/SYSCLK
AIN2.2
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
AIN2.1
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
AIN2.0
T4
T4EX
INT1E: XBR1.4
Page 193
C8051F060/1/2/3
Advanced
Information
associated functions when the SMBus, UART0 or UART1 are selected (i.e. SMBus, SPI, UART). It would be impossible, for example, to assign TX0 to a Port pin without assigning RX0 as well. The SPI can operate in 3 or 4-wire
mode (with or without NSS). Each combination of enabled peripherals results in a unique device pinout.
IO
N
All Port pins on Ports 0 through 3 that are not allocated by the Crossbar can be accessed as General-Purpose I/O
(GPIO) pins by reading and writing the associated Port Data registers (See Figure 17.9, Figure 17.11, Figure 17.14,
and Figure 17.17), a set of SFR’s which are both byte- and bit-addressable. The output states of Port pins that are allocated by the Crossbar are controlled by the digital peripheral that is mapped to those pins. Writes to the Port Data registers (or associated Port bits) will have no effect on the states of these pins.
RM
AT
A Read of a Port Data register (or Port bit) will always return the logic state present at the pin itself, regardless of
whether the Crossbar has allocated the pin for peripheral use or not. An exception to this occurs during the execution
of a read-modify-write instruction (ANL, ORL, XRL, CPL, INC, DEC, DJNZ, JBC, CLR, SETB, and the bitwise
MOV write operation). During the read cycle of the read-modify-write instruction, it is the contents of the Port Data
register, not the state of the Port pins themselves, which is read.
FO
Because the Crossbar registers affect the pinout of the peripherals of the device, they are typically configured in the
initialization code of the system before the peripherals themselves are configured. Once configured, the Crossbar registers are typically left alone.
IN
Once the Crossbar registers have been properly configured, the Crossbar is enabled by setting XBARE (XBR2.4) to a
logic 1. Until XBARE is set to a logic 1, the output drivers on Ports 0 through 3 are explicitly disabled in order
to prevent possible contention on the Port pins while the Crossbar registers and other registers which can
affect the device pinout are being written.
The output drivers on Crossbar-assigned input signals (like RX0, for example) are explicitly disabled; thus the values
of the Port Data registers and the PnMDOUT registers have no effect on the states of these pins.
ED
17.1.2. Configuring the Output Modes of the Port Pins
The output drivers on Ports 0 through 3 remain disabled until the Crossbar is enabled by setting XBARE (XBR2.4) to
a logic 1.
VA
NC
The output mode of each port pin can be configured to be either Open-Drain or Push-Pull. In the Push-Pull configuration, writing a logic 0 to the associated bit in the Port Data register will cause the Port pin to be driven to GND, and
writing a logic 1 will cause the Port pin to be driven to VDD. In the Open-Drain configuration, writing a logic 0 to the
associated bit in the Port Data register will cause the Port pin to be driven to GND, and a logic 1 will cause the Port
pin to assume a high-impedance state. The Open-Drain configuration is useful to prevent contention between devices
in systems where the Port pin participates in a shared interconnection in which multiple outputs are connected to the
same physical wire (like the SDA signal on an SMBus connection).
AD
The output modes of the Port pins on Ports 0 through 3 are determined by the bits in the associated PnMDOUT registers (See Figure 17.10, Figure 17.13, Figure 17.16, and Figure 17.18). For example, a logic 1 in P3MDOUT.7 will
configure the output mode of P3.7 to Push-Pull; a logic 0 in P3MDOUT.7 will configure the output mode of P3.7 to
Open-Drain. All Port pins default to Open-Drain output.
The PnMDOUT registers control the output modes of the port pins regardless of whether the Crossbar has allocated
the Port pin for a digital peripheral or not. The exceptions to this rule are: the Port pins connected to SDA, SCL, RX0
(if UART0 is in Mode 0), and RX1 (if UART1 is in Mode 0) are always configured as Open-Drain outputs, regardless
of the settings of the associated bits in the PnMDOUT registers.
Page 194
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
17.1.3. Configuring Port Pins as Digital Inputs
N
A Port pin is configured as a digital input by setting its output mode to “Open-Drain” and writing a logic 1 to the
associated bit in the Port Data register. For example, P3.7 is configured as a digital input by setting P3MDOUT.7 to a
logic 0 and P3.7 to a logic 1.
IO
If the Port pin has been assigned to a digital peripheral by the Crossbar and that pin functions as an input (for example
RX0, the UART0 receive pin), then the output drivers on that pin are automatically disabled.
17.1.4. Weak Pull-ups
RM
AT
By default, each Port pin has an internal weak pull-up device enabled which provides a resistive connection (about
100 kΩ) between the pin and VDD. The weak pull-up devices can be globally disabled by writing a logic 1 to the
Weak Pull-up Disable bit, (WEAKPUD, XBR2.7). The weak pull-up is automatically deactivated on any pin that is
driving a logic 0; that is, an output pin will not contend with its own pull-up device. The weak pull-up device can also
be explicitly disabled on a Port 1 pin by configuring the pin as an Analog Input, as described below.
17.1.5. Configuring Port 1 and 2 pins as Analog Inputs
FO
The pins on Port 1 can serve as analog inputs to the ADC2 analog MUX and the pins on Port 2 can serve as analog
inputs to the Comparators. A Port pin is configured as an Analog Input by writing a logic 0 to the associated bit in the
PnMDIN registers. All Port pins default to a Digital Input mode. Configuring a Port pin as an analog input:
IN
1. Disables the digital input path from the pin. This prevents additional power supply current from being
drawn when the voltage at the pin is near VDD / 2. A read of the Port Data bit will return a logic 0 regardless
of the voltage at the Port pin.
2. Disables the weak pull-up device on the pin.
3. Causes the Crossbar to “skip over” the pin when allocating Port pins for digital peripherals.
AD
VA
NC
ED
Note that the output drivers on a pin configured as an Analog Input are not explicitly disabled. Therefore, the associated PnMDOUT bits of pins configured as Analog Inputs should explicitly be set to logic 0 (Open-Drain output
mode), and the associated Port Data bits should be set to logic 1 (high-impedance). Also note that it is not required to
configure a Port pin as an Analog Input in order to use it as an input to ADC2 or the Comparators, however, it is
strongly recommended. See the analog peripheral’s corresponding section in this datasheet for further information.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 195
C8051F060/1/2/3
Advanced
Information
17.1.6. Crossbar Pin Assignment Example
N
In this example (Figure 17.4), we configure the Crossbar to allocate Port pins for UART0, the SMBus, all 6 PCA
modules, /INT0, and /INT1 (12 pins total). Additionally, we configure P1.2, P1.3, and P1.4 for Analog Input mode so
that the voltages at these pins can be measured by ADC2. The configuration steps are as follows:
IO
XBR0, XBR1, and XBR2 are set such that UART0EN = 1, SMB0EN = 1, PCA0ME = ‘110’, INT0E = 1, and
INT1E = 1. Thus: XBR0 = 0x3D, XBR1 = 0x14, and XBR2 = 0x40.
AD
VA
NC
ED
IN
FO
RM
AT
1. We configure the desired Port 1 pins to Analog Input mode by setting P1MDIN to 0xE3 (P1.4, P1.3, and
P1.2 are Analog Inputs, so their associated P1MDIN bits are set to logic 0).
2. We enable the Crossbar by setting XBARE = 1: XBR2 = 0x40.
- UART0 has the highest priority, so P0.0 is assigned to TX0, and P0.1 is assigned to RX0.
- The SMBus is next in priority order, so P0.2 is assigned to SDA, and P0.3 is assigned to SCL.
- PCA0 is next in priority order, so P0.4 through P1.1 are assigned to CEX0 through CEX5
- P1MDIN is set to 0xE3, which configures P1.2, P1.3, and P1.4 as Analog Inputs, causing the
Crossbar to skip these pins.
- /INT0 is next in priority order, so it is assigned to the next non-skipped pin, which is P1.5.
- /INT1 is next in priority order, so it is assigned to P1.6.
3. We set the UART0 TX pin (TX0, P0.0) output and the CEX0-3 outputs to Push-Pull by setting
P0MDOUT = 0xF1.
4. We explicitly disable the output drivers on the 3 Analog Input pins by setting the corresponding bits in
the P1MDOUT register to ‘0’, and in P1 to ‘1’. Additionally, the CEX5-4 output pins are set to Push-Pull
mode. Therefore, P1MDOUT = 0x03 (configure unused pins to Open-Drain) and P1 = 0xFF (a logic 1
selects the high-impedance state).
Page 196
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 17.4. Crossbar Example:
1
2
3
P1
4
5
6
7
0
1
2
3
P2
4
5
6
7
0
1
2
3
P3
4
5
6
7
0
1
●
TX0
●
●
●
●
●
MOSI
●
●
NSS
●
SDA
●
TX1
●
CEX0
●
CEX1
CEX2
● ● ● ● ●
● ● ● ● ● ● ●
●
RX1
●
● ● ● ● ●
●
SCL
● ● ● ● ● ● ●
● ● ● ● ● ● ● ●
●
● ● ● ● ● ● ●
●
● ● ● ● ● ●
● ●
● ● ●
●
CEX3
● ● ● ● ●
●
CEX4
● ● ● ●
● ● ● ●
●
CEX5
5
6
7
RM
MISO
Crossbar Register Bits
4
AT
●
SCK
3
FO
RX0
2
IO
P0
PIN I/O 0
N
(P1MDIN = 0xE3; XBR0 = 0x3D; XBR1 = 0x14; XBR2 = 0x40)
UART0EN: XBR0.2
SPI0EN: XBR0.1
SMB0EN: XBR0.0
UART1EN: XBR2.2
PCA0ME: XBR0.[5:3]
● ● ● ● ●
● ● ●
● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ●
ECI0E: XBR0.6
CP0
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ●
CP0E: XBR0.7
CP1
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ●
CP1E: XBR1.0
CP2
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
CP2E: XBR3.3
T0
● ● ● ● ● ● ● ● ● ●
/INT0
● ● ● ● ● ● ● ● ● ●
T1
● ● ● ● ● ● ● ● ● ●
/INT1
● ● ● ● ● ● ● ● ● ●
T2
● ● ● ● ● ● ● ● ● ●
T2EX
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ●
ED
T3
T3EX
IN
ECI
● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
T0E: XBR1.1
INT0E: XBR1.2
T1E: XBR1.3
INT1E: XBR1.4
T2E: XBR1.5
T2EXE: XBR1.6
T3E: XBR3.0
T3EXE: XBR3.1
CP0-
AIN2.3
AIN2.2
AIN2.1
AIN2.0
AD
CP0+
CNVSTE2: XBR3.2
CP2-
SYSCKE: XBR1.7
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
CP2+
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
CP1-
● ● ● ● ● ● ● ● ● ●
CNVSTR2
CP1+
/SYSCLK
AIN2.7
T4EXE: XBR2.4
AIN2.6
T4E: XBR2.3
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
AIN2.5
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●
● ● ● ● ● ● ● ● ● ●
AIN2.4
● ● ● ● ● ● ● ● ● ●
VA
NC
T4
T4EX
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 197
C8051F060/1/2/3
Advanced
Information
Figure 17.5. XBR0: Port I/O Crossbar Register 0
R/W
CP0E
ECI0E
Bit7
Bit6
R/W
R/W
R/W
PCA0ME
Bit5
Bit4
R/W
R/W
R/W
Reset Value
UART0EN
SPI0EN
SMB0EN
00000000
Bit2
Bit1
Bit3
N
R/W
Bit0
Bit1:
AT
RM
AD
Bit0:
FO
Bit2:
IN
Bits5-3:
ED
Bit6:
CP0E: Comparator 0 Output Enable Bit.
0: CP0 unavailable at Port pin.
1: CP0 routed to Port pin.
ECI0E: PCA0 External Counter Input Enable Bit.
0: PCA0 External Counter Input unavailable at Port pin.
1: PCA0 External Counter Input (ECI0) routed to Port pin.
PCA0ME: PCA0 Module I/O Enable Bits.
000: All PCA0 I/O unavailable at port pins.
001: CEX0 routed to port pin.
010: CEX0, CEX1 routed to 2 port pins.
011: CEX0, CEX1, and CEX2 routed to 3 port pins.
100: CEX0, CEX1, CEX2, and CEX3 routed to 4 port pins.
101: CEX0, CEX1, CEX2, CEX3, and CEX4 routed to 5 port pins.
110: CEX0, CEX1, CEX2, CEX3, CEX4, and CEX5 routed to 6 port pins.
UART0EN: UART0 I/O Enable Bit.
0: UART0 I/O unavailable at Port pins.
1: UART0 TX routed to P0.0, and RX routed to P0.1.
SPI0EN: SPI0 Bus I/O Enable Bit.
0: SPI0 I/O unavailable at Port pins.
4-wire mode:
1: SPI0 SCK, MISO, MOSI, and NSS routed to 4 Port pins.
3-wire mode:
1: SPI0 SCK, MISO and MOSI routed to 3 Port pins.
SMB0EN: SMBus0 Bus I/O Enable Bit.
0: SMBus0 I/O unavailable at Port pins.
1: SMBus0 SDA and SCL routed to 2 Port pins.
VA
NC
Bit7:
IO
SFR Address: 0xE1
SFR Page: F
Page 198
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 17.6. XBR1: Port I/O Crossbar Register 1
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
SYSCKE
T2EXE
T2E
INT1E
T1E
INT0E
T0E
CP1E
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bit3:
Bit2:
Bit1:
AT
AD
VA
NC
Bit0:
RM
Bit4:
FO
Bit5:
IN
Bit6:
SYSCKE: /SYSCLK Output Enable Bit.
0: /SYSCLK unavailable at Port pin.
1: /SYSCLK routed to Port pin.
T2EXE: T2EX Input Enable Bit.
0: T2EX unavailable at Port pin.
1: T2EX routed to Port pin.
T2E: T2 Input Enable Bit.
0: T2 unavailable at Port pin.
1: T2 routed to Port pin.
INT1E: /INT1 Input Enable Bit.
0: /INT1 unavailable at Port pin.
1: /INT1 routed to Port pin.
T1E: T1 Input Enable Bit.
0: T1 unavailable at Port pin.
1: T1 routed to Port pin.
INT0E: /INT0 Input Enable Bit.
0: /INT0 unavailable at Port pin.
1: /INT1 routed to Port pin.
T0E: T0 Input Enable Bit.
0: T0 unavailable at Port pin.
1: T1 routed to Port pin.
CP1E: CP1 Output Enable Bit.
0: CP1 unavailable at Port pin.
1: CP1 routed to Port pin.
ED
Bit7:
IO
SFR Address: 0xE2
SFR Page: F
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 199
Advanced
Information
C8051F060/1/2/3
R/W
R/W
WEAKPUD
Bit7
R/W
R/W
Reset Value
UART1E
-
-
00000000
Bit2
Bit1
N
Figure 17.7. XBR2: Port I/O Crossbar Register 2
R/W
R/W
R/W
R/W
XBARE
-
T4EXE
T4E
Bit6
Bit5
Bit4
Bit3
Bit0
Bit3:
Bit2:
AT
AD
VA
NC
ED
Bits1-0:
RM
Bit5:
Bit4:
FO
Bit6:
WEAKPUD: Weak Pull-Up Disable Bit.
0: Weak pull-ups globally enabled.
1: Weak pull-ups globally disabled.
XBARE: Crossbar Enable Bit.
0: Crossbar disabled. All pins on Ports 0, 1, 2, and 3, are forced to Input mode.
1: Crossbar enabled.
UNUSED. Read = 0, Write = don't care.
T4EXE: T4EX Input Enable Bit.
0: T4EX unavailable at Port pin.
1: T4EX routed to Port pin.
T4E: T4 Input Enable Bit.
0: T4 unavailable at Port pin.
1: T4 routed to Port pin.
UART1E: UART1 I/O Enable Bit.
0: UART1 I/O unavailable at Port pins.
1: UART1 TX and RX routed to 2 Port pins.
Reserved
IN
Bit7:
IO
SFR Address: 0xE3
SFR Page: F
Page 200
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 17.8. XBR3: Port I/O Crossbar Register 3
R
R
CTXOUT
-
-
Bit7
Bit6
Bit5
R/W
Bit4
R/W
R/W
R/W
R/W
Reset Value
CP2E
CNVST2E
T3EXE
T3E
00000000
Bit3
Bit2
Bit1
N
R
Bit0
Bit2:
Bit1:
AT
AD
VA
NC
ED
IN
Bit0:
RM
Bit6-4:
Bit3:
CTXOUT: CAN Transmit Pin (CTX) Output Mode.
0: CTX pin output mode is configured as open-drain.
1: CTX pin output mode is configured as push-pull.
Reserved
CP2E: CP2 Output Enable Bit.
0: CP2 unavailable at Port pin.
1: CP2 routed to Port pin.
CNVST2E: ADC2 External Convert Start Input Enable Bit.
0: CNVST2 for ADC2 unavailable at Port pin.
1: CNVST2 for ADC2 routed to Port pin.
T3EXE: T3EX Input Enable Bit.
0: T3EX unavailable at Port pin.
1: T3EX routed to Port pin.
T3E: T3 Input Enable Bit.
0: T3 unavailable at Port pin.
1: T3 routed to Port pin.
FO
Bit7:
IO
SFR Address: 0xE4
SFR Page: F
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 201
Advanced
Information
C8051F060/1/2/3
Figure 17.9. P0: Port0 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P0.7
P0.6
P0.5
P0.4
P0.3
P0.2
P0.1
P0.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0x80
SFR Page: All Pages
AT
P0.[7:0]: Port0 Output Latch Bits.
(Write - Output appears on I/O pins per XBR0, XBR1, XBR2, and XBR3 Registers)
0: Logic Low Output.
1: Logic High Output (open if corresponding P0MDOUT.n bit = 0).
(Read - Regardless of XBR0, XBR1, XBR2, and XBR3 Register settings).
0: P0.n pin is logic low.
1: P0.n pin is logic high.
FO
RM
Bits7-0:
Figure 17.10. P0MDOUT: Port0 Output Mode Register
Bit6
R/W
R/W
R/W
IN
Bit7
R/W
Bit5
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0xA4
SFR Page: F
ED
R/W
P0MDOUT.[7:0]: Port0 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
Note:
SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are always
configured as Open-Drain when they appear on Port pins.
AD
VA
NC
Bits7-0:
Page 202
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P1.1
P1.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
R/W
N
Figure 17.11. P1: Port1 Data Register
P1.[7:0]: Port1 Output Latch Bits.
(Write - Output appears on I/O pins per XBR0, XBR1, XBR2, and XBR3 Registers)
0: Logic Low Output.
1: Logic High Output (open if corresponding P1MDOUT.n bit = 0).
(Read - Regardless of XBR0, XBR1, XBR2, and XBR3 Register settings).
0: P1.n pin is logic low.
1: P1.n pin is logic high.
RM
Bits7-0:
AT
SFR Address: 0x90
SFR Page: All Pages
Note:
IN
FO
P1.[7:0] can be configured as inputs to ADC2 as AIN2.[7:0], in which case they are ‘skipped’ by the
Crossbar assignment process and their digital input paths are disabled, depending on P1MDIN (See
Figure 17.12). Note that in analog mode, the output mode of the pin is determined by the Port 1 latch
and P1MDOUT (Figure 17.13). See Section “7. 10-Bit ADC (ADC2)” on page 83 for more information about ADC2.
ED
Figure 17.12. P1MDIN: Port1 Input Mode Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
VA
NC
11111111
SFR Address: 0xAD
SFR Page: F
P1MDIN.[7:0]: Port 1 Input Mode Bits.
0: Port Pin is configured in Analog Input mode. The digital input path is disabled (a read from the
Port bit will always return ‘0’). The weak pull-up on the pin is disabled.
1: Port Pin is configured in Digital Input mode. A read from the Port bit will return the logic level at
the Pin. The state of the weak pull-up is determined by the WEAKPUD bit (XBR2.7, see
Figure 17.7).
AD
Bits7-0:
Reset Value
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 203
Advanced
Information
C8051F060/1/2/3
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
Figure 17.13. P1MDOUT: Port1 Output Mode Register
Bit0
IO
SFR Address: 0xA5
SFR Page: F
P1MDOUT.[7:0]: Port1 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
Note:
SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are always
configured as Open-Drain when they appear on Port pins.
RM
AT
Bits7-0:
R/W
R/W
R/W
P2.6
P2.5
P2.4
Bit7
Bit6
Bit5
Bit4
R/W
R/W
R/W
Reset Value
P2.2
P2.1
P2.0
11111111
Bit2
Bit1
Bit0
Bit
Addressable
SFR Address: 0xA0
SFR Page: All Pages
ED
Bit3
P2.[7:0]: Port2 Output Latch Bits.
(Write - Output appears on I/O pins per XBR0, XBR1, XBR2, and XBR3 Registers)
0: Logic Low Output.
1: Logic High Output (open if corresponding P2MDOUT.n bit = 0).
(Read - Regardless of XBR0, XBR1, XBR2, and XBR3 Register settings).
0: P2.n pin is logic low.
1: P2.n pin is logic high.
AD
VA
NC
Bits7-0:
R/W
P2.3
IN
R/W
P2.7
FO
Figure 17.14. P2: Port2 Data Register
Page 204
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
Figure 17.15. P2MDIN: Port2 Input Mode Register
Bit0
P2MDIN.[7:0]: Port 2 Input Mode Bits.
0: Port Pin is configured in Analog Input mode. The digital input path is disabled (a read from the
Port bit will always return ‘0’). The weak pull-up on the pin is disabled.
1: Port Pin is configured in Digital Input mode. A read from the Port bit will return the logic level at
the Pin. The state of the weak pull-up is determined by the WEAKPUD bit (XBR2.7, see
Figure 17.7).
RM
AT
Bits7-0:
IO
SFR Address: 0xAE
SFR Page: F
Figure 17.16. P2MDOUT: Port2 Output Mode Register
Bit6
R/W
Bit5
R/W
Bit4
R/W
FO
Bit7
R/W
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0xA6
SFR Page: F
IN
R/W
P2MDOUT.[7:0]: Port2 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
Note:
SDA, SCL, and RX0 (when UART0 is in Mode 0) and RX1 (when UART1 is in Mode 0) are always
configured as Open-Drain when they appear on Port pins.
AD
VA
NC
ED
Bits7-0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 205
Advanced
Information
C8051F060/1/2/3
Figure 17.17. P3: Port3 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P3.7
P3.6
P3.5
P3.4
P3.3
P3.2
P3.1
P3.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xB0
SFR Page: All Pages
P3.[7:0]: Port3 Output Latch Bits.
(Write - Output appears on I/O pins per XBR0, XBR1, XBR2, and XBR3 Registers)
0: Logic Low Output.
1: Logic High Output (open if corresponding P3MDOUT.n bit = 0).
(Read - Regardless of XBR0, XBR1, XBR2, and XBR3 Register settings).
0: P3.n pin is logic low.
1: P3.n pin is logic high.
Note:
Although P3 is not brought out to pins on the C8051F061/3 devices, the Port Data register is still
present and can be used by software. See “Configuring Ports which are not Pinned Out” on page 207.
FO
RM
AT
Bits7-0:
Bit7
Bit6
R/W
Bit5
R/W
R/W
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0xA7
SFR Page: F
P3MDOUT.[7:0]: Port3 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
AD
VA
NC
Bits7-0:
R/W
ED
R/W
IN
Figure 17.18. P3MDOUT: Port3 Output Mode Register
Page 206
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
17.2.
C8051F060/1/2/3
Ports 4 through 7 (C8051F060/2 only)
N
All Port pins on Ports 4 through 7 can be accessed as General-Purpose I/O (GPIO) pins by reading and writing the
associated Port Data registers (See Figure 17.19, Figure 17.21, Figure 17.23, and Figure 17.25), a set of SFR’s which
are byte-addressable. Note that Port 4 has only three pins: P4.5, P4.6, and P4.7.
AT
IO
A Read of a Port Data register (or Port bit) will always return the logic state present at the pin itself, regardless of
whether the Crossbar has allocated the pin for peripheral use or not. An exception to this occurs during the execution
of a read-modify-write instruction (ANL, ORL, XRL, CPL, INC, DEC, DJNZ, JBC, CLR, SETB, and the bitwise
MOV write operation). During the read cycle of the read-modify-write instruction, it is the contents of the Port Data
register, not the state of the Port pins themselves, which is read.
17.2.1. Configuring Ports which are not Pinned Out
RM
Although P3, P4, P5, P6, and P7 are not brought out to pins on the C8051F061/3 devices, the Port Data registers are
still present and can be used by software. Because the digital input paths also remain active, it is recommended that
these pins not be left in a ‘floating’ state in order to avoid unnecessary power dissipation arising from the inputs floating to non-valid logic levels. This condition can be prevented by any of the following:
FO
1. Leave the weak pull-up devices enabled by setting WEAKPUD (XBR2.7) to a logic 0.
2. Configure the output modes of P3, P4, P5, P6, and P7 to “Push-Pull” by writing 0xFF to the associated
output mode register (PnMDOUT).
3. Force the output states of P3, P4, P5, P6, and P7 to logic 0 by writing zeros to the Port Data registers: P3
= 0x00, P4 = 0x00, P5 = 0x00, P6= 0x00, and P7 = 0x00.
IN
17.2.2. Configuring the Output Modes of the Port Pins
ED
The output mode of each port pin can be configured to be either Open-Drain or Push-Pull. In the Push-Pull configuration, a logic 0 in the associated bit in the Port Data register will cause the Port pin to be driven to GND, and a logic 1
will cause the Port pin to be driven to VDD. In the Open-Drain configuration, a logic 0 in the associated bit in the
Port Data register will cause the Port pin to be driven to GND, and a logic 1 will cause the Port pin to assume a highimpedance state. The Open-Drain configuration is useful to prevent contention between devices in systems where the
Port pin participates in a shared interconnection in which multiple outputs are connected to the same physical wire.
VA
NC
The output modes of the Port pins on Ports 4 through 7 are determined by the bits in their respective PnMDOUT Output Mode Registers. Each bit in PnMDOUT controls the output mode of its corresponding port pin (see Figure 17.20,
Figure 17.22, Figure 17.24, and Figure 17.26). For example, to place Port pin 5.3 in push-pull mode (digital output),
set P5MDOUT.3 to logic 1. All port pins default to open-drain mode upon device reset.
17.2.3. Configuring Port Pins as Digital Inputs
AD
A Port pin is configured as a digital input by setting its output mode to “Open-Drain” and writing a logic 1 to the
associated bit in the Port Data register. For example, P7.7 is configured as a digital input by setting P7MDOUT.7 to a
logic 0 and P7.7 to a logic 1.
17.2.4. Weak Pull-ups
By default, each Port pin has an internal weak pull-up device enabled which provides a resistive connection (about
100 kΩ) between the pin and VDD. The weak pull-up devices can be globally disabled by writing a logic 1 to the
Weak Pull-up Disable bit, (WEAKPUD, XBR2.7). The weak pull-up is automatically deactivated on any pin that is
driving a logic 0; that is, an output pin will not contend with its own pull-up device.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 207
C8051F060/1/2/3
Advanced
Information
17.2.5. External Memory Interface
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
If the External Memory Interface is enabled on the High ports and an off-chip MOVX operation occurs, the External
Memory Interface will control the output states of the affected Port pins during the execution phase of the MOVX
instruction, regardless of the settings of the Port Data registers. The output configuration of the Port pins is not
affected by the EMIF operation, except that Read operations will explicitly disable the output drivers on the Data Bus
during the MOVX execution. See Section “16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP
XRAM” on page 175 for more information about the External Memory Interface.
Page 208
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 17.19. P4: Port4 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P4.7
P4.6
P4.5
-
-
-
-
-
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xC8
SFR Page: F
Bits 4-0:
AT
P4.[7:5]: Port4 Output Latch Bits.
Write - Output appears on I/O pins.
0: Logic Low Output.
1: Logic High Output (open, if corresponding P4MDOUT.n bit = 0). See Figure 17.20.
Read - Returns states of I/O pins.
0: P4.n pin is logic low.
1: P4.n pin is logic high.
Reserved. Write to ‘11111’.
RM
Bits7-5:
IN
FO
Note: P4.7 (/WR), P4.6 (/RD), and P4.5 (ALE) can be driven by the External Data Memory Interface.
See Section “16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM” on
Figure 17.20. P4MDOUT: Port4 Output Mode Register
R/W
R/W
Bit7
Bit6
Bit5
R/W
R/W
R/W
Reset Value
00000000
-
-
-
-
-
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x9C
SFR Page: F
P4MDOUT.[7:5]: Port4 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
Reserved. Write to ‘00000’.
AD
Bits 4-0:
R/W
VA
NC
Bits7-5:
R/W
ED
R/W
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 209
Advanced
Information
C8051F060/1/2/3
Figure 17.21. P5: Port5 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P5.7
P5.6
P5.5
P5.4
P5.3
P5.2
P5.1
P5.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xD8
SFR Page: F
P5.[7:0]: Port5 Output Latch Bits.
Write - Output appears on I/O pins.
0: Logic Low Output.
1: Logic High Output (open, if corresponding P5MDOUT bit = 0). See Figure 17.22.
Read - Returns states of I/O pins.
0: P5.n pin is logic low.
1: P5.n pin is logic high.
Note:
P5.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Non-multiplexed
mode). See Section “16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM” on
page 175 for more information about the External Memory Interface.
FO
RM
AT
Bits7-0:
Bit7
Bit6
R/W
Bit5
R/W
R/W
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0x9D
SFR Page: F
P5MDOUT.[7:0]: Port5 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
AD
VA
NC
Bits7-0:
R/W
ED
R/W
IN
Figure 17.22. P5MDOUT: Port5 Output Mode Register
Page 210
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 17.23. P6: Port6 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P6.7
P6.6
P6.5
P6.4
P6.3
P6.2
P6.1
P6.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xE8
SFR Page: F
P6.[7:0]: Port6 Output Latch Bits.
Write - Output appears on I/O pins.
0: Logic Low Output.
1: Logic High Output (open, if corresponding P6MDOUT bit = 0). See Figure 17.24.
Read - Returns states of I/O pins.
0: P6.n pin is logic low.
1: P6.n pin is logic high.
Note:
P6.[7:0] can be driven by the External Data Memory Interface (as Address[15:8] in Multiplexed
mode, or as Address[7:0] in Non-multiplexed mode). See Section “16. EXTERNAL DATA MEMORY INTERFACE AND ON-CHIP XRAM” on page 175 for more information about the External
Memory Interface.
IN
FO
RM
AT
Bits7-0:
Figure 17.24. P6MDOUT: Port6 Output Mode Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x9E
SFR Page: F
P6MDOUT.[7:0]: Port6 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
AD
Bits7-0:
Bit6
VA
NC
Bit7
ED
00000000
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 211
Advanced
Information
C8051F060/1/2/3
Figure 17.25. P7: Port7 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
P7.7
P7.6
P7.5
P7.4
P7.3
P7.2
P7.1
P7.0
11111111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0xF8
SFR Page: F
P7.[7:0]: Port7 Output Latch Bits.
Write - Output appears on I/O pins.
0: Logic Low Output.
1: Logic High Output (open, if corresponding P7MDOUT bit = 0). See Figure 17.26.
Read - Returns states of I/O pins.
0: P7.n pin is logic low.
1: P7.n pin is logic high.
Note:
P7.[7:0] can be driven by the External Data Memory Interface (as AD[7:0] in Multiplexed mode, or
as D[7:0] in Non-multiplexed mode). See Section “16. EXTERNAL DATA MEMORY INTERFACE
AND ON-CHIP XRAM” on page 175 for more information about the External Memory Interface.
IN
FO
RM
AT
Bits7-0:
Figure 17.26. P7MDOUT: Port7 Output Mode Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x9F
SFR Page: F
P7MDOUT.[7:0]: Port7 Output Mode Bits.
0: Port Pin output mode is configured as Open-Drain.
1: Port Pin output mode is configured as Push-Pull.
AD
Bits7-0:
Bit6
VA
NC
Bit7
ED
00000000
Page 212
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
18.
C8051F060/1/2/3
CONTROLLER AREA NETWORK (CAN0)
IO
N
IMPORTANT DOCUMENTATION NOTE: The Bosch CAN Controller is integrated in the C8051F06x Family of
devices. This section of the data sheet gives a description of the CAN controller as an overview and offers a description of how the Cygnal CIP-51 MCU interfaces with the on-chip Bosch CAN controller. In order to use the CAN controller, please refer to Bosch’s C_CAN User’s Manual (revision 1.2) as an accompanying manual to Cygnal’s
C8051F060/1/2/3 Data sheet.
RM
AT
The C8051F060/1/2/3 family of devices feature a Control Area Network (CAN) controller that enables serial communication using the CAN protocol. Cygnal 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 CIP-51 RAM), a message handler state machine, and control registers. Cygnal
CAN is a protocol controller and does not provide physical layer drivers (i.e., transceivers). Figure 18.2 shows an
example typical configuration on a CAN bus.
AD
VA
NC
ED
IN
FO
Cygnal CAN operates at bit rates of up to 1 Mbit/second, though this can be limited by the physical layer chosen to
transmit data on the CAN bus. The CAN processor has 32 Message Objects that can be configured to transmit or
receive data. Incoming data, message objects and their 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 CIP-51 MCU. In this way, minimal CPU bandwidth is needed to use CAN communication. The CIP-51 configures the CAN controller, accesses received data, and passes data for transmission via Special Function Registers
(SFR) in the CIP-51.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 213
C8051F060/1/2/3
Advanced
Information
N
Figure 18.1. CAN Controller Diagram
CANRX
C8051F060/1/2/3
IO
CANTX
C
8
0
5
1
TX
AT
CAN Controller
RX
Message RAM
REGISTERS
IN
(32 Message Objects)
FO
RM
CAN
Core
M
C
U
Interrupt
VA
NC
ED
Message Handler
S
F
R
's
Figure 18.2. Typical CAN Bus Configuration
C8051F06x
AD
CANTX
CANRX
CAN
Transceiver
Isolation/Buffer (Optional)
CAN Protocol Device
CAN Protocol Device
CAN
Transceiver
CAN
Transceiver
Isolation/Buffer (Optional)
Isolation/Buffer (Optional)
CAN_H
R
R
CAN_L
Page 214
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
18.1.
C8051F060/1/2/3
Bosch CAN Controller Operation
N
The CAN Controller featured in the C8051F06x family of devices is a full implementation of Bosch’s full CAN module and fully complies with CAN specification 2.0B.
IO
The function and use of the CAN Controller is detailed in the Bosch CAN User’s Guide. The User’s Guide should be
used as a reference to configure and use the CAN controller. This Cygnal datasheet describes how to access the CAN
controller.
AD
VA
NC
ED
IN
FO
RM
AT
The CAN Control Register (CAN0CN), CAN Test Register (CAN0TST), and CAN Status Register (CAN0STA) in
the CAN controller can be accessed directly or indirectly via CIP-51 SFR’s. All other CAN registers must be
accessed via an indirect indexing method. See “Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN
Registers” on page 217.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 215
C8051F060/1/2/3
18.2.
Advanced
Information
CAN Registers
CAN registers are classified as follows:
FO
18.2.1. CAN Controller Protocol Registers
RM
AT
IO
N
1. CAN Controller Protocol Registers: CAN control, interrupt, error control, bus status, test
modes.
2. Message Object Interface Registers: Used to configure 32 Message Objects, send and
receive data to and from Message Objects. The C8051 MCU accesses the CAN message
RAM via the Message Object Interface Registers. Upon writing a message object number
to an IF1 or IF2 Command Request Register, the contents of the associated Interface
Registers (IF1 or IF2) will be transferred to or from the message object in CAN RAM.
3. Message Handler Registers: These read only registers are used to provide information to
the CIP-51 MCU about the message objects (MSGVLD flags, Transmission Request
Pending, New Data Flags) and Interrupts Pending (which Message Objects have caused
an interrupt or status interrupt condition).
4. C8051 MCU Special Function Registers (SFR): Five registers located in the C8051 MCU
memory map that allow direct access to certain CAN Controller Protocol Registers, and
Indexed indirect access to all CAN registers.
IN
The CAN Control Protocol Registers are used to configure the CAN controller, process interrupts, monitor bus status,
and place the controller in test modes. The CAN controller protocol registers are accessible using C8051 MCU SFR’s
by an indexed method, and some can be accessed directly by addressing the SFR’s in the C8051 SFR map for convenience.
ED
The registers are: CAN Control Register (CAN0CN), CAN Status Register (CAN0STA), CAN Test Register
(CAN0TST), Error Counter Register, Bit Timing Register, and the Baud Rate Prescaler (BRP) Extension Register.
CAN0STA, CAN0CN, and CAN0TST can be accessed via C8051 MCU SFR’s. All others are accessed indirectly
using the CAN address indexed method via CAN0ADR, CAN0DATH, and CAN0DATL.
VA
NC
Please refer to the Bosch CAN User’s Guide for information on the function and use of the CAN Control Protocol Registers.
18.2.2. Message Object Interface Registers
There are two sets of Message Object Interface Registers used to configure the 32 Message Objects that transmit and
receive data to and from the CAN bus. Message objects can be configured for transmit or receive, and are assigned
arbitration message identifiers for acceptance filtering by all CAN nodes.
AD
Message Objects are stored in Message RAM, and are accessed and configured using the Message Object Interface
Registers. These registers are accessed via the C8051’s CAN0ADR and CAN0DAT registers using the indirect
indexed address method.
Please refer to the Bosch CAN User’s Guide for information on the function and use of the Message Object
Interface Registers.
18.2.3. Message Handler Registers
The Message Handler Registers are read only registers. Their flags can be read via the indexed access method with
CAN0ADR, CAN0DATH, and CAN0DATL. The message handler registers provide interrupt, error, transmit/receive
requests, and new data information.
Page 216
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Please refer to the Bosch CAN User’s Guide for information on the function and use of the Message Handler
Registers.
N
18.2.4. CIP-51 MCU Special Function Registers
AT
IO
C8051F06x family peripherals are modified, monitored, and controlled using Special Function Registers (SFR’s).
Most of the CAN Controller registers cannot be accessed directly using the SFR’s. Three of the CAN Controller’s
registers may be accessed directly with SFR’s. All other CAN Controller registers are accessed indirectly using three
CIP-51 MCU SFR’s: the CAN Data Registers (CAN0DATH and CAN0DATL) and CAN Address Register
(CAN0ADR). In this way, there are a total of five CAN registers used to configure and run the CAN Controller.
18.2.5. Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN Registers
FO
// Load Bit Timing Register’s index (Table 18.1)
// Move the upper byte into data reg high byte
// Move the lower byte into data reg low byte
IN
CAN0ADR = 0x03;
CAN0DATH = 0x23;
CAN0DATL = 0x04;
RM
Each CAN Controller Register has an index number (see Table 18.1 below). The CAN register address space is 128
words (256 bytes). A CAN register is accessed via the CAN Data Registers (CAN0DATH and CAN0DATL) when a
CAN register’s index number is placed into the CAN Address Register (CAN0ADR). For example, if the Bit Timing
Register is to be configured with a new value, CAN0ADR is loaded with 0x03. The low byte of the desired value is
accessed using CAN0DATL and the high byte of the bit timing register is accessed using CAN0DATH. CAN0DATL
is bit addressable for convenience. To load the value 0x2304 into the Bit Timing Register:
Note: CAN0CN, CAN0STA, and CAN0TST may be accessed either by using the index method, or by direct access
with the CIP-51 MCU SFR’s. CAN0CN is located at SFR location 0xF8/SFR page 1 (Figure 18.6), CAN0TST at
0xDB/SFR page 1 (Figure 18.7), and CAN0STA at 0xC0/SFR page 1 (Figure 18.8).
ED
18.2.6. CAN0ADR Autoincrement Feature
VA
NC
For ease of programming message objects, CAN0ADR features autoincrementing for the index ranges 0x08 to 0x12
(Interface Registers 1) and 0x20 to 0x2A (Interface Registers 2). When the CAN0ADR register has an index in these
ranges, the CAN0ADR will autoincrement by 1 to point to the next CAN register 16-bit word upon a read/write
of CAN0DATL. This speeds programming of the frequently programmed interface registers when configuring message objects.
NOTE: Table 18.1 below supersedes Figure 5 in section 3, “Programmer’s Model” of the Bosch CAN User’s
Guide.
Table 18.1. CAN Register Index and Reset Values
AD
CAN REGISTER
INDEX
REGISTER NAME
RESET
VALUE
NOTES
0x00
CAN Control Register
0x0001
Accessible in CIP-51 SFR Map
0x01
Status Register
0x0000
Accessible in CIP-51 SFR Map
0x02
Error Register
0x0000
Read Only
0x03
Bit Timing Register
0x2301
Write Enabled by CCE Bit in CAN0CN
0x04
Interrupt Register
0x0000
Read Only
0x05
Test Register
0x0000
Bit 7 (RX) is determined by CAN bus
0x06
BRP Extension Register
0x0000
Write Enabled by TEST bit in CAN0CN
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 217
Advanced
Information
C8051F060/1/2/3
CAN REGISTER
INDEX
RESET
VALUE
NOTES
IF1 Command Request
0x0001
CAN0ADR autoincrements in IF1 index
space (0x08 - 0x12) upon write to
CAN0DATL
0x09
IF1 Command Mask
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x0A
IF1 Mask 1
0xFFFF
CAN0ADR autoincrement upon write to
CAN0DATL
0x0B
IF1 Mask 2
0xFFFF
0x0C
IF1 Arbitration 1
0x0000
0x0D
IF1 Arbitration 2
0x0E
IF1 Message Control
0x0F
IF1 Data A1
0x10
IF1 Data A2
0x11
IF1 Data B1
0x12
IF1 Data B2
0x20
IF2 Command Request
AT
IO
N
0x08
CAN0ADR autoincrement upon write to
CAN0DATL
RM
CAN0ADR autoincrement upon write to
CAN0DATL
CAN0ADR autoincrement upon write to
CAN0DATL
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
FO
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x0001
CAN0ADR autoincrements in IF1 index
space (0x08 - 0x12) upon write to
CAN0DATL
IF2 Command Mask
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
IF2 Mask 1
0xFFFF
CAN0ADR autoincrement upon write to
CAN0DATL
IF2 Mask 2
0xFFFF
CAN0ADR autoincrement upon write to
CAN0DATL
IF2 Arbitration 1
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x25
IF2 Arbitration 2
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x26
IF2 Message Control
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x27
IF2 Data A1
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x28
IF2 Data A2
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x23
ED
AD
0x24
VA
NC
0x22
IN
0x0000
0x21
Page 218
REGISTER NAME
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
CAN REGISTER
INDEX
REGISTER NAME
C8051F060/1/2/3
RESET
VALUE
NOTES
IF2 Data B1
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x2A
IF2 Data B2
0x0000
CAN0ADR autoincrement upon write to
CAN0DATL
0x40
Transmission Request 1
0x0000
Transmission request flags for message
objects (read only)
0x41
Transmission Request 2
0x0000
Transmission request flags for message
objects (read only)
0x48
New Data 1
0x0000 New Data flags for message objects (read
only)
0x49
New Data 2
0x0000 New Data flags for message objects (read
only)
0x50
Interrupt Pending 1
0x51
Interrupt Pending 2
0x58
Message Valid 1
0x59
Message Valid 2
RM
AT
IO
N
0x29
Interrupt pending flags for message
objects (read only)
0x0000
Interrupt pending flags for message
objects (read only)
0x0000
Message valid flags for message objects
(read only)
0x0000
Message valid flags for message objects
(read only)
AD
VA
NC
ED
IN
FO
0x0000
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 219
C8051F060/1/2/3
Advanced
Information
Figure 18.3. CAN0DATH: CAN Data Access Register High Byte
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
Bit1
R/W
N
Bit7
R/W
Reset Value
00000000
Bit0
IO
R/W
SFR Address: 0xD9
SFR Page: 1
AT
CAN0DATH: CAN Data Access Register High Byte.
The CAN0DAT Registers are used to read/write register values and data to and from the CAN Registers pointed to with the index number in the CAN0ADR Register.
The CAN0ADR Register is used to point the [CAN0DATH:CAN0DATL] to a desired CAN Register.
The desired CAN Register’s index number is moved into CAN0ADR. The CAN0DAT Register can
then read/write to and from the CAN Register.
RM
Bit7-0:
Bit7
Bit6
R/W
R/W
Bit5
R/W
Bit4
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0xD8
SFR Page: 1
CAN0DATL: CAN Data Access Register Low Byte.
The CAN0DAT Registers are used to read/write register values and data to and from the CAN Registers pointed to with the index number in the CAN0ADR Register.
The CAN0ADR Register is used to point the [CAN0DATH:CAN0DATL] to a desired CAN Register.
The desired CAN Register’s index number is moved into CAN0ADR. The CAN0DAT Register can
then read/write to and from the CAN Register.
AD
VA
NC
ED
Bit7-0:
R/W
IN
R/W
FO
Figure 18.4. CAN0DATL: CAN Data Access Register Low Byte
Page 220
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 18.5. CAN0ADR: CAN Address Index Register
Bit6
R/W
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
Bit2
Bit1
R/W
N
Bit7
R/W
Reset Value
00000000
Bit0
IO
R/W
SFR Address: 0xDA
SFR Page: 1
AT
CAN0ADR: CAN Address Index Register.
The CAN0ADR Register is used to point the [CAN0DATH:CAN0DATL] to a desired CAN Register.
The desired CAN Register’s index number is moved into CAN0ADR. The CAN0DAT Register can
then read/write to and from the CAN Register.
RM
Bit7-0:
Note: When the value of CAN0ADR is 0x08-0x12 and 0x20-2A (IF1 and IF2 registers), this register
will autoincrement by 1 upon a write to CAN0DATL. See Section “18.2.6. CAN0ADR Autoincrement Feature” on page 217.
IN
FO
All CAN registers’ functions/definitions are listed and described in the Bosch CAN User’s
Guide.
Figure 18.6. CAN0CN: CAN Control Register
R/W
*
*
Bit7
Bit6
Bit5
Bit 4:
R/W
R/W
R/W
R/W
CANIF
R
*
*
*
*
Bit4
Bit3
Bit2
Bit1
ED
R/W
*
Reset Value
Bit0
SFR Address: 0xF8
SFR Page: 1
VA
NC
R/W
CANIF: CAN Interrupt Flag. Write = don’t care.
0: CAN interrupt has not occured.
1: CAN interrupt has occured and is active.
AD
CANIF is controlled by the CAN controller and is cleared by hardware once all interrupt conditions
have been cleared in the CAN controller. See section 3.4.1 in the Bosch CAN User’s Guide (page 24)
for more information concerning CAN controller interrupts.
*All CAN registers’ functions/definitions are listed and described in the Bosch CAN User’s
Guide with the exception of the CANIF bit.
This register may be accessed directly in the CIP-51 SFR register space, or through the indirect, index
method (See Section “18.2.5. Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN
Registers” on page 217).
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 221
C8051F060/1/2/3
Advanced
Information
Figure 18.7. CAN0TST: CAN Test Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
N
R/W
Reset Value
Please see the Bosch CAN User’s Guide for a complete definition of this register
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
IO
Bit7
SFR Address: 0xDB
SFR Page: 1
RM
AT
All CAN registers’ functions/definitions are listed and described in the Bosch CAN User’s
Guide.
This register may be accessed directly in the CIP-51 SFR register space, or through the indirect, index
method (See Section “18.2.5. Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN
Registers” on page 217).
R/W
R/W
R/W
FO
Figure 18.8. CAN0STA: CAN Status Register
R/W
R/W
R/W
R/W
R/W
Reset Value
Bit7
Bit6
IN
Please see the Bosch CAN User’s Guide for a complete definition of this register
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0xC0
SFR Page: 1
AD
VA
NC
ED
All CAN registers’ functions/definitions are listed and described in the Bosch CAN User’s
Guide.
This register may be accessed directly in the CIP-51 SFR register space, or through the indirect, index
method (See Section “18.2.5. Using CAN0ADR, CAN0DATH, and CANDATL To Access CAN
Registers” on page 217).
Page 222
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
SYSTEM MANAGEMENT BUS / I2C BUS (SMBUS0)
19.
IO
N
The SMBus0 I/O interface is a two-wire, bi-directional serial bus. SMBus0 is compliant with the System Management Bus Specification, version 1.1, and compatible with the I2C serial bus. Reads and writes to the interface by the
system controller are byte oriented with the SMBus0 interface autonomously controlling the serial transfer of the
data. A method of extending the clock-low duration is available to accommodate devices with different speed capabilities on the same bus.
RM
AT
SMBus0 may operate as a master and/or slave, and may function on a bus with multiple masters. SMBus0 provides
control of SDA (serial data), SCL (serial clock) generation and synchronization, arbitration logic, and START/STOP
control and generation.
Figure 19.1. SMBus0 Block Diagram
SFR Bus
SMB0STA
S
T
A
7
S
T
A
6
S
T
A
5
S
T
A
4
S
T
A
3
S
T
A
2
SMB0CR
S
T
A
1
S
T
A
0
C C C C C C C C
R R R R R R R R
7 6 5 4 3 2 1 0
IN
E S S S A F T
N T T I A T O
S A O
E E
M
B
FO
SMB0CN
B
U
S
Y
Clock Divide
Logic
SYSCLK
SCL
FILTER
SMBUS
IRQ
ED
SMBUS CONTROL LOGIC
Arbitration
SCL Synchronization
Status Generation
SCL Generation (Master Mode)
IRQ Generation
B
SCL
Control
Data Path
Control
N
SDA
Control
C
R
O
S
S
B
A
R
A=B
A=B
VA
NC
Interrupt
Request
A
B
A
Port I/O
0000000b
7 MSBs
8
AD
7
S
L
V
6
S
L
V
5
S
L
V
4
S
L
V
3
S
L
V
2
S
L
V
1
SMB0DAT
7 6 5 4 3 2 1 0
8
8
SDA
FILTER
1
S
L
V G
0 C
N
0
Read
SMB0DAT
SMB0ADR
Write to
SMB0DAT
SFR Bus
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 223
Advanced
Information
C8051F060/1/2/3
IO
N
Figure 19.2 shows a typical SMBus configuration. The SMBus0 interface will work at any voltage between 3.0 V and
5.0 V and different devices on the bus may operate at different voltage levels. The bi-directional SCL (serial clock)
and SDA (serial data) lines must be connected to a positive power supply voltage through a pull-up resistor or similar
circuit. Every device connected to the bus must have an open-drain or open-collector output for both the SCL and
SDA lines, so that both are pulled high when the bus is free. The maximum number of devices on the bus is limited
only by the requirement that the rise and fall times on the bus will not exceed 300 ns and 1000 ns, respectively.
Figure 19.2. Typical SMBus Configuration
Master
Device
Slave
Device 1
VDD = 3V
AT
VDD = 5V
RM
VDD = 3V
Slave
Device 2
19.1. Supporting Documents
SDA
SCL
IN
FO
VDD = 5V
It is assumed the reader is familiar with or has access to the following supporting documents:
19.2.
ED
The I2C-bus and how to use it (including specifications), Philips Semiconductor.
The I2C-Bus Specification -- Version 2.0, Philips Semiconductor.
System Management Bus Specification -- Version 1.1, SBS Implementers Forum.
VA
NC
1.
2.
3.
SMBus Protocol
AD
Two types of data transfers are possible: data transfers from a master transmitter to an addressed slave receiver
(WRITE), and data transfers from an addressed slave transmitter to a master receiver (READ). The master device initiates both types of data transfers and provides the serial clock pulses on SCL. Note: multiple master devices on the
same bus are supported. If two or more masters attempt to initiate a data transfer simultaneously, an arbitration
scheme is employed with a single master always winning the arbitration. Note that it is not necessary to specify one
device as the master in a system; any device who transmits a START and a slave address becomes the master for that
transfer.
A typical SMBus transaction consists of a START condition followed by an address byte (Bits7-1: 7-bit slave
address; Bit0: R/W direction bit), one or more bytes of data, and a STOP condition. Each byte that is received (by a
master or slave) must be acknowledged (ACK) with a low SDA during a high SCL (see Figure 19.3). If the receiving
device does not ACK, the transmitting device will read a “not acknowledge” (NACK), which is a high SDA during a
high SCL.
The direction bit (R/W) occupies the least-significant bit position of the address. The direction bit is set to logic 1 to
indicate a "READ" operation and cleared to logic 0 to indicate a "WRITE" operation.
Page 224
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
SDA
START
SLA5-0
R/W
D7
D6-0
RM
SLA6
AT
SCL
Slave Address + R/W
ACK
Data Byte
NACK
STOP
FO
19.2.1. Arbitration
IO
Figure 19.3. SMBus Transaction
N
All transactions are initiated by a master, with one or more addressed slave devices as the target. The master generates the START condition and then transmits the slave address and direction bit. If the transaction is a WRITE operation from the master to the slave, the master transmits the data a byte at a time waiting for an ACK from the slave at
the end of each byte. For READ operations, the slave transmits the data waiting for an ACK from the master at the
end of each byte. At the end of the data transfer, the master generates a STOP condition to terminate the transaction
and free the bus. Figure 19.3 illustrates a typical SMBus transaction.
19.2.2. Clock Low Extension
ED
IN
A master may start a transfer only if the bus is free. The bus is free after a STOP condition or after the SCL and SDA
lines remain high for a specified time (see Section 19.2.4). In the event that two or more devices attempt to begin a
transfer at the same time, an arbitration scheme is employed to force one master to give up the bus. The master
devices continue transmitting until one attempts a HIGH while the other transmits a LOW. Since the bus is opendrain, the bus will be pulled LOW. The master attempting the HIGH will detect a LOW SDA and give up the bus. The
winning master continues its transmission without interruption; the losing master becomes a slave and receives the
rest of the transfer. This arbitration scheme is non-destructive: one device always wins, and no data is lost.
VA
NC
SMBus provides a clock synchronization mechanism, similar to I2C, which allows devices with different speed capabilities to coexist on the bus. A clock-low extension is used during a transfer in order to allow slower slave devices to
communicate with faster masters. The slave may temporarily hold the SCL line LOW to extend the clock low period,
effectively decreasing the serial clock frequency.
19.2.3. SCL Low Timeout
AD
If the SCL line is held low by a slave device on the bus, no further communication is possible. Furthermore, the master cannot force the SCL line high to correct the error condition. To solve this problem, the SMBus protocol specifies
that devices participating in a transfer must detect any clock cycle held low longer than 25 ms as a “timeout” condition. Devices that have detected the timeout condition must reset the communication no later than 10 ms after detecting the timeout condition.
19.2.4. SCL High (SMBus Free) Timeout
The SMBus specification stipulates that if the SCL and SDA lines remain high for more that 50 µs, the bus is designated as free. If an SMBus device is waiting to generate a Master START, the START will be generated following the
bus free timeout.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 225
Advanced
Information
C8051F060/1/2/3
19.3.
SMBus Transfer Modes
IO
N
The SMBus0 interface may be configured to operate as a master and/or a slave. At any particular time, the interface
will be operating in one of the following modes: Master Transmitter, Master Receiver, Slave Transmitter, or Slave
Receiver. See Table 19.1 for transfer mode status decoding using the SMB0STA status register. The following mode
descriptions illustrate an interrupt-driven SMBus0 application; SMBus0 may alternatively be operated in polled
mode.
19.3.1. Master Transmitter Mode
RM
AT
Serial data is transmitted on SDA while the serial clock is output on SCL. SMBus0 generates a START condition and
then transmits the first byte containing the address of the target slave device and the data direction bit. In this case the
data direction bit (R/W) will be logic 0 to indicate a "WRITE" operation. The SMBus0 interface transmits one or
more bytes of serial data, waiting for an acknowledge (ACK) from the slave after each byte. To indicate the end of the
serial transfer, SMBus0 generates a STOP condition.
Figure 19.4. Typical Master Transmitter Sequence
W
Interrupt
A
Data Byte
Interrupt
A
Data Byte
FO
SLA
Interrupt
IN
S
Received by SMBus
Interface
P
Interrupt
S = START
P = STOP
A = ACK
W = WRITE
SLA = Slave Address
ED
Transmitted by
SMBus Interface
A
19.3.2. Master Receiver Mode
VA
NC
Serial data is received on SDA while the serial clock is output on SCL. The SMBus0 interface generates a START
followed by the first data byte containing the address of the target slave and the data direction bit. In this case the data
direction bit (R/W) will be logic 1 to indicate a "READ" operation. The SMBus0 interface receives serial data from
the slave and generates the clock on SCL. After each byte is received, SMBus0 generates an ACK or NACK depending on the state of the AA bit in register SMB0CN. SMBus0 generates a STOP condition to indicate the end of the
serial transfer.
Figure 19.5. Typical Master Receiver Sequence
AD
S
SLA
R
Interrupt
A
Interrupt
Received by SMBus
Interface
Transmitted by
SMBus Interface
Page 226
Data Byte
A
Data Byte
Interrupt
N
P
Interrupt
S = START
P = STOP
A = ACK
N = NACK
R = READ
SLA = Slave Address
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
19.3.3. Slave Transmitter Mode
IO
N
Serial data is transmitted on SDA while the serial clock is received on SCL. The SMBus0 interface receives a START
followed by data byte containing the slave address and direction bit. If the received slave address matches the address
held in register SMB0ADR, the SMBus0 interface generates an ACK. SMBus0 will also ACK if the general call
address (0x00) is received and the General Call Address Enable bit (SMB0ADR.0) is set to logic 1. In this case the
data direction bit (R/W) will be logic 1 to indicate a "READ" operation. The SMBus0 interface receives the clock on
SCL and transmits one or more bytes of serial data, waiting for an ACK from the master after each byte. SMBus0
exits slave mode after receiving a STOP condition from the master.
SLA
R
A
Data Byte
Interrupt
A
Data Byte
RM
S
AT
Figure 19.6. Typical Slave Transmitter Sequence
Interrupt
P
Interrupt
IN
Transmitted by
SMBus Interface
N
S = START
P = STOP
N = NACK
R = READ
SLA = Slave Address
FO
Received by SMBus
Interface
Interrupt
19.3.4. Slave Receiver Mode
VA
NC
ED
Serial data is received on SDA while the serial clock is received on SCL. The SMBus0 interface receives a START
followed by data byte containing the slave address and direction bit. If the received slave address matches the address
held in register SMB0ADR, the interface generates an ACK. SMBus0 will also ACK if the general call address
(0x00) is received and the General Call Address Enable bit (SMB0ADR.0) is set to logic 1. In this case the data direction bit (R/W) will be logic 0 to indicate a "WRITE" operation. The SMBus0 interface receives one or more bytes of
serial data; after each byte is received, the interface transmits an ACK or NACK depending on the state of the AA bit
in SMB0CN. SMBus0 exits Slave Receiver Mode after receiving a STOP condition from the master.
Figure 19.7. Typical Slave Receiver Sequence
AD
S
SLA
W
Interrupt
A
Interrupt
Data Byte
A
Data Byte
Interrupt
Received by SMBus
Interface
Transmitted by
SMBus Interface
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
A
P
Interrupt
S = START
P = STOP
A = ACK
W = WRITE
SLA = Slave Address
Page 227
C8051F060/1/2/3
19.4.
Advanced
Information
SMBus Special Function Registers
IO
N
The SMBus0 serial interface is accessed and controlled through five SFR’s: SMB0CN Control Register, SMB0CR
Clock Rate Register, SMB0ADR Address Register, SMB0DAT Data Register and SMB0STA Status Register. The
five special function registers related to the operation of the SMBus0 interface are described in the following sections.
19.4.1. Control Register
AT
The SMBus0 Control register SMB0CN is used to configure and control the SMBus0 interface. All of the bits in the
register can be read or written by software. Two of the control bits are also affected by the SMBus0 hardware. The
Serial Interrupt flag (SI, SMB0CN.3) is set to logic 1 by the hardware when a valid serial interrupt condition occurs.
It can only be cleared by software. The Stop flag (STO, SMB0CN.4) is set to logic 1 by software. It is cleared to logic
0 by hardware when a STOP condition is detected on the bus.
FO
RM
Setting the ENSMB flag to logic 1 enables the SMBus0 interface. Clearing the ENSMB flag to logic 0 disables the
SMBus0 interface and removes it from the bus. Momentarily clearing the ENSMB flag and then resetting it to logic 1
will reset SMBus0 communication. However, ENSMB should not be used to temporarily remove a device from the
bus since the bus state information will be lost. Instead, the Assert Acknowledge (AA) flag should be used to temporarily remove the device from the bus (see description of AA flag below).
IN
Setting the Start flag (STA, SMB0CN.5) to logic 1 will put SMBus0 in a master mode. If the bus is free, SMBus0 will
generate a START condition. If the bus is not free, SMBus0 waits for a STOP condition to free the bus and then generates a START condition after a 5 µs delay per the SMB0CR value (In accordance with the SMBus protocol, the
SMBus0 interface also considers the bus free if the bus is idle for 50 µs and no STOP condition was recognized). If
STA is set to logic 1 while SMBus0 is in master mode and one or more bytes have been transferred, a repeated
START condition will be generated.
VA
NC
ED
When the Stop flag (STO, SMB0CN.4) is set to logic 1 while the SMBus0 interface is in master mode, the interface
generates a STOP condition. In a slave mode, the STO flag may be used to recover from an error condition. In this
case, a STOP condition is not generated on the bus, but the SMBus hardware behaves as if a STOP condition has been
received and enters the "not addressed" slave receiver mode. Note that this simulated STOP will not cause the bus to
appear free to SMBus0. The bus will remain occupied until a STOP appears on the bus or a Bus Free Timeout occurs.
Hardware automatically clears the STO flag to logic 0 when a STOP condition is detected on the bus.
The Serial Interrupt flag (SI, SMB0CN.3) is set to logic 1 by hardware when the SMBus0 interface enters one of 27
possible states. If interrupts are enabled for the SMBus0 interface, an interrupt request is generated when the SI flag
is set. The SI flag must be cleared by software.
AD
Important Note: If SI is set to logic 1 while the SCL line is low, the clock-low period of the serial clock will be
stretched and the serial transfer is suspended until SI is cleared to logic 0. A high level on SCL is not affected by the
setting of the SI flag.
The Assert Acknowledge flag (AA, SMB0CN.2) is used to set the level of the SDA line during the acknowledge
clock cycle on the SCL line. Setting the AA flag to logic 1 will cause an ACK (low level on SDA) to be sent during
the acknowledge cycle if the device has been addressed. Setting the AA flag to logic 0 will cause a NACK (high level
on SDA) to be sent during acknowledge cycle. After the transmission of a byte in slave mode, the slave can be temporarily removed from the bus by clearing the AA flag. The slave's own address and general call address will be
ignored. To resume operation on the bus, the AA flag must be reset to logic 1 to allow the slave's address to be recognized.
Setting the SMBus0 Free Timer Enable bit (FTE, SMB0CN.1) to logic 1 enables the timer in SMB0CR. When SCL
goes high, the timer in SMB0CR counts up. A timer overflow indicates a free bus timeout: if SMBus0 is waiting to
Page 228
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
generate a START, it will do so after this timeout. The bus free period should be less than 50 µs (see Figure 19.9,
SMBus0 Clock Rate Register).
IO
N
When the TOE bit in SMB0CN is set to logic 1, Timer 4 is used to detect SCL low timeouts. If Timer 4 is enabled
(see Section “23.2. Timer 2, Timer 3, and Timer 4” on page 279), Timer 4 is forced to reload when SCL is high,
and forced to count when SCL is low. With Timer 4 enabled and configured to overflow after 25 ms (and TOE set), a
Timer 4 overflow indicates a SCL low timeout; the Timer 4 interrupt service routine can then be used to reset
SMBus0 communication in the event of an SCL low timeout.
R/W
R/W
R/W
R/W
R/W
BUSY
ENSMB
STA
STO
SI
AA
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit4:
FTE
TOE
00000000
Bit1
Bit0
Bit
Addressable
SFR Address: 0xC0
SFR Page: 0
FO
BUSY: Busy Status Flag.
0: SMBus0 is free.
1: SMBus0 is busy.
ENSMB: SMBus Enable.
This bit enables/disables the SMBus serial interface.
0: SMBus0 disabled.
1: SMBus0 enabled.
STA: SMBus Start Flag.
0: No START condition is transmitted.
1: When operating as a master, a START condition is transmitted if the bus is free. (If the bus is not
free, the START is transmitted after a STOP is received.) If STA is set after one or more bytes have
been transmitted or received and before a STOP is received, a repeated START condition is transmitted.
STO: SMBus Stop Flag.
0: No STOP condition is transmitted.
1: Setting STO to logic 1 causes a STOP condition to be transmitted. When a STOP condition is
received, hardware clears STO to logic 0. If both STA and STO are set, a STOP condition is transmitted followed by a START condition. In slave mode, setting the STO flag causes SMBus to behave as
if a STOP condition was received.
SI: SMBus Serial Interrupt Flag.
This bit is set by hardware when one of 27 possible SMBus0 states is entered. (Status code 0xF8 does
not cause SI to be set.) When the SI interrupt is enabled, setting this bit causes the CPU to vector to
the SMBus interrupt service routine. This bit is not automatically cleared by hardware and must be
cleared by software.
AA: SMBus Assert Acknowledge Flag.
This bit defines the type of acknowledge returned during the acknowledge cycle on the SCL line.
0: A "not acknowledge" (high level on SDA) is returned during the acknowledge cycle.
1: An "acknowledge" (low level on SDA) is returned during the acknowledge cycle.
FTE: SMBus Free Timer Enable Bit.
0: No timeout when SCL is high.
1: Timeout when SCL high time exceeds limit specified by the SMB0CR value.
TOE: SMBus Timeout Enable Bit.
0: No timeout when SCL is low.
1: Timeout when SCL low time exceeds limit specified by Timer 4, if enabled.
AD
Bit3:
Reset Value
IN
Bit5:
R/W
ED
Bit6:
R/W
VA
NC
Bit7:
RM
R
AT
Figure 19.8. SMB0CN: SMBus0 Control Register
Bit2:
Bit1:
Bit0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 229
C8051F060/1/2/3
Advanced
Information
19.4.2. Clock Rate Register
Bit7
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
R/W
Reset Value
00000000
IO
R/W
N
Figure 19.9. SMB0CR: SMBus0 Clock Rate Register
Bit2
Bit1
Bit0
SMB0CR.[7:0]: SMBus0 Clock Rate Preset.
The SMB0CR Clock Rate register controls the frequency of the serial clock SCL in master mode. The
8-bit word stored in the SMB0CR Register preloads a dedicated 8-bit timer. The timer counts up, and
when it rolls over to 0x00, the SCL logic state toggles.
RM
Bits7-0:
AT
SFR Address: 0xCF
SFR Page: 0
The SMB0CR setting should be bounded by the following equation , where SMB0CR is the unsigned
8-bit value in register SMB0CR, and SYSCLK is the system clock frequency in Hz:
FO
SMB0CR < ( ( 288 – 0.85 ⋅ SYSCLK ) ⁄ 1.125 )
IN
The resulting SCL signal high and low times are given by the following equations:
ED
T LOW = ( 256 – SMB0CR ) ⁄ SYSCLK
VA
NC
T HIGH ≅ ( 258 – SMB0CR ) ⁄ SYSCLK + 625ns
Using the same value of SMB0CR from above, the Bus Free Timeout period is given in the following
equation:
AD
( 256 – SMB0CR ) + 1
T BFT ≅ 10 × ----------------------------------------------------SYSCLK
Page 230
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
19.4.3. Data Register
N
The SMBus0 Data register SMB0DAT holds a byte of serial data to be transmitted or one that has just been received.
Software can read or write to this register while the SI flag is set to logic 1; software should not attempt to access the
SMB0DAT register when the SMBus is enabled and the SI flag reads logic 0 since the hardware may be in the process of shifting a byte of data in or out of the register.
AT
IO
Data in SMB0DAT is always shifted out MSB first. After a byte has been received, the first bit of received data is
located at the MSB of SMB0DAT. While data is being shifted out, data on the bus is simultaneously being shifted in.
Therefore, SMB0DAT always contains the last data byte present on the bus. In the event of lost arbitration, the transition from master transmitter to slave receiver is made with the correct data in SMB0DAT.
Figure 19.10. SMB0DAT: SMBus0 Data Register
Bits7-0:
Bit6
R/W
Bit5
Bit4
R/W
Bit3
R/W
RM
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
SFR Address: 0xC2
SFR Page: 0
FO
Bit7
R/W
SMB0DAT: SMBus0 Data.
The SMB0DAT register contains a byte of data to be transmitted on the SMBus0 serial interface or a
byte that has just been received on the SMBus0 serial interface. The CPU can read from or write to
this register whenever the SI serial interrupt flag (SMB0CN.3) is set to logic 1. When the SI flag is
not set, the system may be in the process of shifting data and the CPU should not attempt to access
this register.
IN
R/W
ED
19.4.4. Address Register
VA
NC
The SMB0ADR Address register holds the slave address for the SMBus0 interface. In slave mode, the seven mostsignificant bits hold the 7-bit slave address. The least significant bit (Bit0) is used to enable the recognition of the
general call address (0x00). If Bit0 is set to logic 1, the general call address will be recognized. Otherwise, the general
call address is ignored. The contents of this register are ignored when SMBus0 is operating in master mode.
Figure 19.11. SMB0ADR: SMBus0 Address Register
R/W
SLV6
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
SLV4
SLV3
SLV2
SLV1
SLV0
GC
00000000
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0xC3
SFR Page: 0
AD
Bit7
R/W
SLV5
Bits7-1:
SLV6-SLV0: SMBus0 Slave Address.
These bits are loaded with the 7-bit slave address to which SMBus0 will respond when operating as a
slave transmitter or slave receiver. SLV6 is the most significant bit of the address and corresponds to
the first bit of the address byte received.
Bit0:
GC: General Call Address Enable.
This bit is used to enable general call address (0x00) recognition.
0: General call address is ignored.
1: General call address is recognized.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 231
C8051F060/1/2/3
Advanced
Information
19.4.5. Status Register
IO
N
The SMB0STA Status register holds an 8-bit status code indicating the current state of the SMBus0 interface. There
are 28 possible SMBus0 states, each with a corresponding unique status code. The five most significant bits of the
status code vary while the three least-significant bits of a valid status code are fixed at zero when SI = ‘1’. Therefore,
all possible status codes are multiples of eight. This facilitates the use of status codes in software as an index used to
branch to appropriate service routines (allowing 8 bytes of code to service the state or jump to a more extensive service routine).
AT
For the purposes of user software, the contents of the SMB0STA register is only defined when the SI flag is logic 1.
Software should never write to the SMB0STA register; doing so will yield indeterminate results. The 28 SMBus0
states, along with their corresponding status codes, are given in Table 1.1.
R/W
R/W
R/W
R/W
STA6
STA5
STA4
STA3
Bit7
Bit6
Bit5
Bit4
Bit3
FO
R/W
STA7
RM
Figure 19.12. SMB0STA: SMBus0 Status Register
R/W
R/W
R/W
Reset Value
STA2
STA1
STA0
11111000
Bit2
Bit1
Bit0
SFR Address: 0xC1
SFR Page: 0
STA7-STA3: SMBus0 Status Code.
These bits contain the SMBus0 Status Code. There are 28 possible status codes; each status code corresponds to a single SMBus state. A valid status code is present in SMB0STA when the SI flag
(SMB0CN.3) is set to logic 1. The content of SMB0STA is not defined when the SI flag is logic 0.
Writing to the SMB0STA register at any time will yield indeterminate results.
Bits2-0:
STA2-STA0: The three least significant bits of SMB0STA are always read as logic 0 when the SI flag
is logic 1.
AD
VA
NC
ED
IN
Bits7-3:
Page 232
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
SMBus State
Typical Action
IO
Status
Code
START condition transmitted.
Load SMB0DAT with Slave Address +
R/W. Clear STA.
0x10
Repeated START condition transmitted.
Load SMB0DAT with Slave Address +
R/W. Clear STA.
0x18
Slave Address + W transmitted. ACK
received.
0x20
Slave Address + W transmitted. NACK
received.
0x28
Data byte transmitted. ACK received.
0x30
Data byte transmitted. NACK received.
0x38
Arbitration Lost.
0x40
Slave Address + R transmitted. ACK received.
0x48
Slave Address + R transmitted. NACK
received.
Acknowledge poll to retry. Set STO +
STA.
0x50
Data byte received. ACK transmitted.
Read SMB0DAT. Wait for next byte. If
next byte is last byte, clear AA.
ED
IN
FO
RM
Load SMB0DAT with data to be transmitted.
Data byte received. NACK transmitted.
Acknowledge poll to retry. Set STO +
STA.
1) Load SMB0DAT with next byte, OR
2) Set STO, OR
3) Clear STO then set STA for repeated
START.
1) Retry transfer OR
2) Set STO.
Save current data.
If only receiving one byte, clear AA (send
NACK after received byte). Wait for
received data.
Set STO.
AD
0x58
AT
0x08
VA
NC
Master Receiver
Master Transmitter
MT/
MR
Mode
N
Table 19.1. SMB0STA Status Codes and States
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 233
Advanced
Information
C8051F060/1/2/3
Table 19.1. SMB0STA Status Codes and States
All
Page 234
SMBus State
Typical Action
N
Status
Code
Own slave address + W received. ACK transmitted.
Wait for data.
0x68
Arbitration lost in sending SLA + R/W as master. Own address + W received. ACK transmitted.
Save current data for retry when bus is
free. Wait for data.
0x70
General call address received. ACK transmitted.
0x78
Arbitration lost in sending SLA + R/W as master. General call address received. ACK transmitted.
0x80
Data byte received. ACK transmitted.
0x88
Data byte received. NACK transmitted.
Set STO to reset SMBus.
0x90
Data byte received after general call address.
ACK transmitted.
Read SMB0DAT. Wait for next byte or
STOP.
0x98
Data byte received after general call address.
NACK transmitted.
Set STO to reset SMBus.
0xA0
STOP or repeated START received.
No action necessary.
0xA8
Own address + R received. ACK transmitted.
Load SMB0DAT with data to transmit.
0xB0
Arbitration lost in transmitting SLA + R/W as
master. Own address + R received. ACK
transmitted.
Save current data for retry when bus is
free. Load SMB0DAT with data to transmit.
0xB8
Data byte transmitted. ACK received.
Load SMB0DAT with data to transmit.
0xC0
Data byte transmitted. NACK received.
Wait for STOP.
0xC8
Last data byte transmitted (AA=0). ACK
received.
Set STO to reset SMBus.
0xD0
SCL Clock High Timer per SMB0CR timed out
Set STO to reset SMBus.
0x00
Bus Error (illegal START or STOP)
Set STO to reset SMBus.
0xF8
Idle
State does not set SI.
AT
Wait for data.
Save current data for retry when bus is
free.
RM
FO
IN
ED
VA
NC
IO
0x60
AD
Slave
Slave Transmitter
Slave Receiver
Mode
Read SMB0DAT. Wait for next byte or
STOP.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
20.
C8051F060/1/2/3
ENHANCED SERIAL PERIPHERAL INTERFACE (SPI0)
AT
Figure 20.1. SPI Block Diagram
SFR Bus
SPIF
WCOL
MODF
RXOVRN
NSSMD1
NSSMD0
TXBMT
SPIEN
FO
SCR7
SCR6
SCR5
SCR4
SCR3
SCR2
SCR1
SCR0
Clock Divide
Logic
IN
SYSCLK
SPI0CN
RM
SPI0CFG
SPIBSY
MSTEN
CKPHA
CKPOL
SLVSEL
NSSIN
SRMT
RXBMT
SPI0CKR
IO
N
The Enhanced Serial Peripheral Interface (SPI0) provides access to a flexible, full-duplex synchronous serial bus.
SPI0 can operate as a master or slave device in both 3-wire or 4-wire modes, and supports multiple masters and slaves
on a single SPI bus. The slave-select (NSS) signal can be configured as an input to select SPI0 in slave mode, or to
disable Master Mode operation in a multi-master environment, avoiding contention on the SPI bus when more than
one master attempts simultaneous data transfers. NSS can also be configured as a chip-select output in master mode,
or disabled for 3-wire operation. Additional general purpose port I/O pins can be used to select multiple slave devices
in master mode.
SPI CONTROL LOGIC
ED
Data Path
Control
SPI IRQ
Pin Interface
Control
MOSI
Tx Data
VA
NC
SPI0DAT
SCK
Transmit Data Buffer
Shift Register
7 6 5 4 3 2 1 0
Rx Data
Pin
Control
Logic
AD
Receive Data Buffer
Write
SPI0DAT
MISO
C
R
O
S
S
B
A
R
Port I/O
NSS
Read
SPI0DAT
SFR Bus
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 235
C8051F060/1/2/3
20.1.
Advanced
Information
Signal Descriptions
The four signals used by SPI0 (MOSI, MISO, SCK, NSS) are described below.
N
20.1.1. Master Out, Slave In (MOSI)
AT
IO
The master-out, slave-in (MOSI) signal is an output from a master device and an input to slave devices. It is used to
serially transfer data from the master to the slave. This signal is an output when SPI0 is operating as a master and an
input when SPI0 is operating as a slave. Data is transferred most-significant bit first. When configured as a master,
MOSI is driven by the MSB of the shift register in both 3- and 4-wire mode.
20.1.2. Master In, Slave Out (MISO)
RM
The master-in, slave-out (MISO) signal is an output from a slave device and an input to the master device. It is used
to serially transfer data from the slave to the master. This signal is an input when SPI0 is operating as a master and an
output when SPI0 is operating as a slave. Data is transferred most-significant bit first. The MISO pin is placed in a
high-impedance state when the SPI module is disabled and when the SPI operates in 4-wire mode as a slave that is
not selected. When acting as a slave in 3-wire mode, MISO is always driven by the MSB of the shift register.
20.1.3. Serial Clock (SCK)
IN
FO
The serial clock (SCK) signal is an output from the master device and an input to slave devices. It is used to synchronize the transfer of data between the master and slave on the MOSI and MISO lines. SPI0 generates this signal when
operating as a master. The SCK signal is ignored by a SPI slave when the slave is not selected (NSS = 1) in 4-wire
slave mode.
20.1.4. Slave Select (NSS)
ED
The function of the slave-select (NSS) signal is dependent on the setting of the NSSMD1 and NSSMD0 bits in the
SPI0CN register. There are three possible modes that can be selected with these bits:
AD
VA
NC
1. NSSMD[1:0] = 00: 3-Wire Master or 3-Wire Slave Mode: SPI0 operates in 3-wire mode, and NSS is
disabled. When operating as a slave device, SPI0 is always selected in 3-wire mode. Since no select signal is
present, SPI0 must be the only slave on the bus in 3-wire mode. This is intended for point-to-point communication between a master and one slave.
2. NSSMD[1:0] = 01: 4-Wire Slave or Multi-Master Mode: SPI0 operates in 4-wire mode, and NSS is
enabled as an input. When operating as a slave, NSS selects the SPI0 device. When operating as a master, a
1-to-0 transition of the NSS signal disables the master function of SPI0 so that multiple master devices can
be used on the same SPI bus.
3. NSSMD[1:0] = 1x: 4-Wire Master Mode: SPI0 operates in 4-wire mode, and NSS is enabled as an output. The setting of NSSMD0 determines what logic level the NSS pin will output. This configuration should
only be used when operating SPI0 as a master device.
See Figure 20.2, Figure 20.3, and Figure 20.4 for typical connection diagrams of the various operational modes. Note
that the setting of NSSMD bits affects the pinout of the device. When in 3-wire master or 3-wire slave mode, the
NSS pin will not be mapped by the crossbar. In all other modes, the NSS signal will be mapped to a pin on the device.
See Section “17.1. Ports 0 through 3 and the Priority Crossbar Decoder” on page 193 for general purpose port I/
O and crossbar information.
Page 236
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
20.2. SPI0 Master Mode Operation
AT
IO
N
A SPI master device initiates all data transfers on a SPI bus. SPI0 is placed in master mode by setting the Master
Enable flag (MSTEN, SPI0CN.6). Writing a byte of data to the SPI0 data register (SPI0DAT) when in master mode
writes to the transmit buffer. If the SPI shift register is empty, the byte in the transmit buffer is moved to the shift register, and a data transfer begins. The SPI0 master immediately shifts out the data serially on the MOSI line while providing the serial clock on SCK. The SPIF (SPI0CN.7) flag is set to logic 1 at the end of the transfer. If interrupts are
enabled, an interrupt request is generated when the SPIF flag is set. While the SPI0 master transfers data to a slave on
the MOSI line, the addressed SPI slave device simultaneously transfers the contents of its shift register to the SPI
master on the MISO line in a full-duplex operation. Therefore, the SPIF flag serves as both a transmit-complete and
receive-data-ready flag. The data byte received from the slave is transferred MSB-first into the master's shift register.
When a byte is fully shifted into the register, it is moved to the receive buffer where it can be read by the processor by
reading SPI0DAT.
FO
RM
When configured as a master, SPI0 can operate in one of three different modes: multi-master mode, 3-wire singlemaster mode, and 4-wire single-master mode. The default, multi-master mode is active when NSSMD1 (SPI0CN.3) =
0 and NSSMD0 (SPI0CN.2) = 1. In this mode, NSS is an input to the device, and is used to disable the master SPI0
when another master is accessing the bus. When NSS is pulled low in this mode, MSTEN (SPI0CN.6) and SPIEN
(SPI0CN.0) are set to 0 to disable the SPI master device, and a Mode Fault is generated (MODF, SPI0CN.5 = 1).
Mode Fault will generate an interrupt if enabled. SPI0 must be manually re-enabled in software under these circumstances. In multi-master systems, devices will typically default to being slave devices while they are not acting as the
system master device. In multi-master mode, slave devices can be addressed individually (if needed) using generalpurpose I/O pins. Figure 20.2 shows a connection diagram between two master devices in multiple-master mode.
ED
IN
3-wire single-master mode is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 0. In this mode,
NSS is not used, and is not mapped to an external port pin through the crossbar. Any slave devices that must be
addressed in this mode should be selected using general-purpose I/O pins. Figure 20.3 shows a connection diagram
between a master device in 3-wire master mode and a slave device.
AD
VA
NC
4-wire single-master mode is active when NSSMD1 (SPI0CN.3) = 1. In this mode, NSS is configured as an output
pin, and can be used as a slave-select signal for a single SPI device. In this mode, the output value of NSS is controlled (in software) with the bit NSSMD0 (SPI0CN.2). Additional slave devices can be addressed using general-purpose I/O pins. Figure 20.4 shows a connection diagram for a master device in 4-wire master mode and two slave
devices.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 237
Advanced
Information
C8051F060/1/2/3
MISO
MOSI
MOSI
SCK
SCK
GPIO
NSS
Master
Device 2
IO
GPIO
AT
Master
Device 1
NSS
MISO
N
Figure 20.2. Multiple-Master Mode Connection Diagram
Master
Device
RM
Figure 20.3. 3-Wire Single Master and 3-Wire Single Slave Mode Connection Diagram
MISO
MISO
MOSI
Slave
Device
MOSI
SCK
FO
SCK
Master
Device
MISO
MISO
MOSI
MOSI
SCK
SCK
NSS
NSS
MISO
MOSI
Slave
Device
Slave
Device
SCK
NSS
AD
VA
NC
ED
GPIO
IN
Figure 20.4. 4-Wire Single Master Mode and 4-Wire Slave Mode Connection Diagram
Page 238
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
20.3.
C8051F060/1/2/3
SPI0 Slave Mode Operation
AT
IO
N
When SPI0 is enabled and not configured as a master, it will operate as a SPI slave. As a slave, bytes are shifted in
through the MOSI pin and out through the MISO pin by a master device controlling the SCK signal. A bit counter in
the SPI0 logic counts SCK edges. When 8 bits have been shifted through the shift register, the SPIF flag is set to logic
1, and the byte is copied into the receive buffer. Data is read from the receive buffer by reading SPI0DAT. A slave
device cannot initiate transfers. Data to be transferred to the master device is pre-loaded into the shift register by writing to SPI0DAT. Writes to SPI0DAT are double-buffered, and are placed in the transmit buffer first. If the shift register is empty, the contents of the transmit buffer will immediately be transferred into the shift register. When the shift
register already contains data, the SPI will wait until the byte is transferred before loading it with the transmit buffer’s
contents.
RM
When configured as a slave, SPI0 can be configured for 4-wire or 3-wire operation. The default, 4-wire slave mode,
is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 1. In 4-wire mode, the NSS signal is routed to
a port pin and configured as a digital input. SPI0 is enabled when NSS is logic 0, and disabled when NSS is logic 1.
The bit counter is reset on a falling edge of NSS. Note that the NSS signal must be driven low at least 2 system clocks
before the first active edge of SCK for each byte transfer. Figure 20.4 shows a connection diagram between two slave
devices in 4-wire slave mode and a master device.
20.4.
SPI0 Interrupt Sources
IN
FO
3-wire slave mode is active when NSSMD1 (SPI0CN.3) = 0 and NSSMD0 (SPI0CN.2) = 0. NSS is not used in this
mode, and is not mapped to an external port pin through the crossbar. Since there is no way of uniquely addressing
the device in 3-wire slave mode, SPI0 must be the only slave device present on the bus. It is important to note that in
3-wire slave mode there is no external means of resetting the bit counter that determines when a full byte has been
received. The bit counter can only be reset by disabling and re-enabling SPI0 with the SPIEN bit. Figure 20.3 shows
a connection diagram between a slave device in 3-wire slave mode and a master device.
ED
When SPI0 interrupts are enabled, the following four flags will generate an interrupt when they are set to logic 1:
Note all of the following bits are cleared in software.
AD
VA
NC
1. The SPI Interrupt Flag, SPIF (SPI0CN.7) is set to logic 1 at the end of each byte transfer. This flag can
occur in all SPI0 modes.
2. The Write Collision Flag, WCOL (SPI0CN.6) is set to logic 1 if a write to SPI0DAT is attempted when
the transmit buffer has not been emptied to the SPI shift register. When this occurs, the write to SPI0DAT
will be ignored, and the transmit buffer will not be written.This flag can occur in all SPI0 modes.
3. The Mode Fault Flag MODF (SPI0CN.5) is set to logic 1 when SPI0 is configured as a master, and for
multi-master mode and the NSS pin is pulled low. When a Mode Fault occurs, the MSTEN and SPIEN bits
in SPI0CN are set to logic 0 to disable SPI0 and allow another master device to access the bus.
4. The Receive Overrun Flag RXOVRN (SPI0CN.4) is set to logic 1 when configured as a slave, and a
transfer is completed and the receive buffer still holds an unread byte from a previous transfer. The new byte
is not transferred to the receive buffer, allowing the previously received data byte to be read. The data byte
which caused the overrun is lost.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 239
Advanced
Information
C8051F060/1/2/3
20.5.
Serial Clock Timing
IO
N
As shown in Figure 20.5, four combinations of serial clock phase and polarity can be selected using the clock control
bits in the SPI0 Configuration Register (SPI0CFG). The CKPHA bit (SPI0CFG.5) selects one of two clock phases
(edge used to latch the data). The CKPOL bit (SPI0CFG.4) selects between an active-high or active-low clock. Both
master and slave devices must be configured to use the same clock phase and polarity. Note: SPI0 should be disabled
(by clearing the SPIEN bit, SPI0CN.0) when changing the clock phase or polarity.
FO
RM
AT
The SPI0 Clock Rate Register (SPI0CKR) as shown in Figure 20.8 controls the master mode serial clock frequency.
This register is ignored when operating in slave mode. When the SPI is configured as a master, the maximum data
transfer rate (bits/sec) is one-half the system clock frequency. When the SPI is configured as a slave, the maximum
data transfer rate (bits/sec) for full-duplex operation is 1/10 the system clock frequency, provided that the master
issues SCK, NSS (in 4-wire slave mode), and the serial input data synchronously with the system clock. If the master
issues SCK, NSS, and the serial input data asynchronously, the maximum data transfer rate (bits/sec) must be less
than 1/10 the system clock frequency. In the special case where the master only wants to transmit data to the slave and
does not need to receive data from the slave (i.e. half-duplex operation), the SPI slave can receive data at a maximum
data transfer rate (bits/sec) of 1/4 the system clock frequency. This is provided that the master issues SCK, NSS, and
the serial input data synchronously with the system clock.
Figure 20.5. Data/Clock Timing Diagram
IN
SCK
(CKPOL=0, CKPHA=0)
ED
SCK
(CKPOL=0, CKPHA=1)
VA
NC
SCK
(CKPOL=1, CKPHA=0)
SCK
(CKPOL=1, CKPHA=1)
MISO/MOSI
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
AD
NSS
MSB
Page 240
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
20.6.
C8051F060/1/2/3
SPI Special Function Registers
N
SPI0 is accessed and controlled through four special function registers in the system controller: SPI0CN Control Register, SPI0DAT Data Register, SPI0CFG Configuration Register, and SPI0CKR Clock Rate Register. The four special
function registers related to the operation of the SPI0 Bus are described in the following figures.
R/W
R/W
R/W
R
R
R
R
Reset Value
MSTEN
CKPHA
CKPOL
SLVSEL
NSSIN
SRMT
RXBMT
00000111
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit 3:
Bit 2:
Bit 1:
RM
FO
AD
Bit 0:
IN
Bit 4:
SPIBSY: SPI Busy (read only).
This bit is set to logic 1 when a SPI transfer is in progress (Master or slave Mode).
MSTEN: Master Mode Enable.
0: Disable master mode. Operate in slave mode.
1: Enable master mode. Operate as a master.
CKPHA: SPI0 Clock Phase.
This bit controls the SPI0 clock phase.
0: Data centered on first edge of SCK period.†
1: Data centered on second edge of SCK period.†
CKPOL: SPI0 Clock Polarity.
This bit controls the SPI0 clock polarity.
0: SCK line low in idle state.
1: SCK line high in idle state.
SLVSEL: Slave Selected Flag (read only).
This bit is set to logic 1 whenever the NSS pin is low indicating SPI0 is the selected slave. It is
cleared to logic 0 when NSS is high (slave not selected). This bit does not indicate the instantaneous
value at the NSS pin, but rather a de-glitched version of the pin input.
NSSIN: NSS Instantaneous Pin Input (read only).
This bit mimics the instantaneous value that is present on the NSS port pin at the time that the register
is read. This input is not de-glitched.
SRMT: Shift Register Empty (Valid in Slave Mode, read only).
This bit will be set to logic 1 when all data has been transferred in/out of the shift register, and there is
no new information available to read from the transmit buffer or write to the receive buffer. It returns
to logic 0 when a data byte is transferred to the shift register from the transmit buffer or by a transition
on SCK.
NOTE: SRMT = 1 when in Master Mode.
RXBMT: Receive Buffer Empty (Valid in Slave Mode, read only).
This bit will be set to logic 1 when the receive buffer has been read and contains no new information.
If there is new information available in the receive buffer that has not been read, this bit will return to
logic 0.
NOTE: RXBMT = 1 when in Master Mode.
ED
Bit 5:
Bit0
SFR Address: 0x9A
SFR Page: 0
VA
NC
Bit 6:
AT
R
SPIBSY
Bit 7:
†
IO
Figure 20.6. SPI0CFG: SPI0 Configuration Register
In slave mode, data on MOSI is sampled in the center of each data bit. In master mode, data on MISO is sampled one
SYSCLK before the end of each data bit, to provide maximum settling time for the slave device. See Table 20.1 for
timing parameters.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 241
Advanced
Information
C8051F060/1/2/3
Figure 20.7. SPI0CN: SPI0 Control Register
R/W
R/W
R/W
SPIF
WCOL
MODF
Bit7
Bit6
Bit5
R/W
RXOVRN NSSMD1
R
R/W
Reset Value
NSSMD0
TXBMT
SPIEN
00000110
Bit2
Bit1
Bit0
Bit
Addressable
Bit3
IO
Bit4
R/W
N
R/W
SFR Address: 0xF8
SFR Page: 0
Bit 4:
Bit 1:
AT
AD
Bit 0:
VA
NC
ED
Bits 3-2:
RM
Bit 5:
FO
Bit 6:
SPIF: SPI0 Interrupt Flag.
This bit is set to logic 1 by hardware at the end of a data transfer. If interrupts are enabled, setting this
bit causes the CPU to vector to the SPI0 interrupt service routine. This bit is not automatically cleared
by hardware. It must be cleared by software.
WCOL: Write Collision Flag.
This bit is set to logic 1 by hardware (and generates a SPI0 interrupt) to indicate a write to the SPI0
data register was attempted while a data transfer was in progress. It must be cleared by software.
MODF: Mode Fault Flag.
This bit is set to logic 1 by hardware (and generates a SPI0 interrupt) when a master mode collision is
detected (NSS is low, MSTEN = 1, and NSSMD[1:0] = 01). This bit is not automatically cleared by
hardware. It must be cleared by software.
RXOVRN: Receive Overrun Flag (Slave Mode only).
This bit is set to logic 1 by hardware (and generates a SPI0 interrupt) when the receive buffer still
holds unread data from a previous transfer and the last bit of the current transfer is shifted into the
SPI0 shift register. This bit is not automatically cleared by hardware. It must be cleared by software.
NSSMD1-NSSMD0: Slave Select Mode.
Selects between the following NSS operation modes:
(See Section “20.2. SPI0 Master Mode Operation” on page 237 and Section “20.3. SPI0 Slave
Mode Operation” on page 239).
00: 3-Wire Slave or 3-wire Master Mode. NSS signal is not routed to a port pin.
01: 4-Wire Slave or Multi-Master Mode (Default). NSS is always an input to the device.
1x: 4-Wire Single-Master Mode. NSS signal is mapped as an output from the device and will assume
the value of NSSMD0.
TXBMT: Transmit Buffer Empty.
This bit will be set to logic 0 when new data has been written to the transmit buffer. When data in the
transmit buffer is transferred to the SPI shift register, this bit will be set to logic 1, indicating that it is
safe to write a new byte to the transmit buffer.
SPIEN: SPI0 Enable.
This bit enables/disables the SPI.
0: SPI disabled.
1: SPI enabled.
IN
Bit 7:
Page 242
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 20.8. SPI0CKR: SPI0 Clock Rate Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
SCR7
SCR6
SCR5
SCR4
SCR3
SCR2
SCR1
SCR0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
SCR7-SCR0: SPI0 Clock Rate.
These bits determine the frequency of the SCK output when the SPI0 module is configured for master
mode operation. The SCK clock frequency is a divided version of the system clock, and is given in the
following equation, where SYSCLK is the system clock frequency and SPI0CKR is the 8-bit value
held in the SPI0CKR register.
AT
Bits 7-0:
IO
SFR Address: 0x9D
SFR Page: 0
FO
for 0 <= SPI0CKR <= 255
RM
SYSCLK
f SCK = ------------------------------------------------2 × ( SPI0CKR + 1 )
IN
Example: If SYSCLK = 2 MHz and SPI0CKR = 0x04,
AD
VA
NC
f SCK = 200kHz
ED
2000000
f SCK = -------------------------2 × (4 + 1)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 243
C8051F060/1/2/3
Advanced
Information
Figure 20.9. SPI0DAT: SPI0 Data Register
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
N
R/W
Reset Value
00000000
Bit0
SPI0DAT: SPI0 Transmit and Receive Data.
The SPI0DAT register is used to transmit and receive SPI0 data. Writing data to SPI0DAT places the
data into the transmit buffer and initiates a transfer when in Master Mode. A read of SPI0DAT returns
the contents of the receive buffer.
AD
VA
NC
ED
IN
FO
RM
AT
Bits 7-0:
IO
SFR Address: 0x9B
SFR Page: 0
Page 244
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
N
Figure 20.10. SPI Slave Timing (CKPHA = 0)
T
IO
NSS
T
CKL
SCK*
T
CKH
T
SD
RM
T
T
AT
SE
SIS
SIH
T
FO
MOSI
SOH
IN
MISO
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
ED
Figure 20.11. SPI Slave Timing (CKPHA = 1)
NSS
T
T
SCK*
T
CKL
VA
NC
SE
SD
T
CKH
T
AD
SIS
T
SIH
MOSI
T
SOH
MISO
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 245
Advanced
Information
C8051F060/1/2/3
N
Figure 20.12. SPI Master Timing (CKPHA = 0)
T
T
MCKH
MCKL
T
T
MIS
IO
SCK*
AT
MIH
RM
MISO
MOSI
FO
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
IN
Figure 20.13. SPI Master Timing (CKPHA = 1)
SCK*
T
T
MCKL
ED
MCKH
T
MISO
MOSI
T
MIH
VA
NC
MIS
AD
* SCK is shown for CKPOL = 0. SCK is the opposite polarity for CKPOL = 1.
Page 246
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 20.1. SPI Slave Timing Parameters
TSYSCLK
DESCRIPTION
MIN
System Clock Period
40
IO
SLAVE MODE TIMING†
MAX
N
PARAMETER
UNITS
ns
NSS Falling to First SCK Edge (Slave Enable)
2*TSYSCLK
ns
TSD
Last SCK Edge to NSS Rising (Slave Disable)
2*TSYSCLK
ns
TCKH
SCK High Time
5*TSYSCLK
ns
TCKL
SCK Low Time
5*TSYSCLK
ns
TSIS
MOSI Valid to SCK Sample Edge (MOSI Setup)
2*TSYSCLK
ns
TSIH
SCK Sample Edge to MOSI Change (MOSI Hold)
2*TSYSCLK
ns
TSOH
SCK Shift Edge to MISO Change (MISO Hold)
RM
AT
TSE
FO
MASTER MODE TIMING††
SCK High Time
TMCKL
SCK Low Time
TMIS
MISO Valid to SCK Shift Edge (MOSI Setup)
TMIH
SCK Shift Edge to MISO Change (MISO Hold)
IN
TMCKH
†
4*TSYSCLK
ns
1*TSYSCLK
ns
1*TSYSCLK
ns
1*TSYSCLK + 20
ns
0
ns
See Figure 20.10 and Figure 20.11 for Slave Mode Timing Diagrams.
See Figure 20.12 and Figure 20.13 for Master Mode Timing Diagrams.
AD
VA
NC
ED
††
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 247
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 248
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
21.
C8051F060/1/2/3
UART0
IO
N
UART0 is an enhanced serial port with frame error detection and address recognition hardware. UART0 may operate
in full-duplex asynchronous or half-duplex synchronous modes, and mutiproccessor communication is fully supported. Receive data is buffered in a holding register, allowing UART0 to start reception of a second incoming data
byte before software has finished reading the previous data byte. A Receive Overrun bit indicates when new received
data is latched into the receive buffer before the previously received byte has been read.
AT
UART0 is accessed via its associated SFR’s, Serial Control (SCON0) and Serial Data Buffer (SBUF0). The single
SBUF0 location provides access to both transmit and receive registers. Reading SCON0 accesses the Receive register
and writing SCON0 accesses the Transmit register.
RM
UART0 may be operated in polled or interrupt mode. UART0 has two sources of interrupts: a Transmit Interrupt flag,
TI0 (SCON0.1) set when transmission of a data byte is complete, and a Receive Interrupt flag, RI0 (SCON0.0) set
when reception of a data byte is complete. UART0 interrupt flags are not cleared by hardware when the CPU vectors
to the interrupt service routine; they must be cleared manually by software. This allows software to determine the
cause of the UART0 interrupt (transmit complete or receive complete).
Figure 21.1. UART0 Block Diagram
FO
SFR Bus
Write to
SBUF0
IN
TB80
SET
D
SSTA0
S
0
T
C
L
K
1
S
0
T
C
L
K
1
S
0
R
C
L
K
1
S
0
R
C
L
K
1
Shift
Stop Bit
Gen.
Crossbar
Data
Tx Control
Start
VA
NC
Tx Clock
UART0
Baud Rate Generation
Logic
Send
Tx IRQ
SCON0
S
M
0
0
Rx Clock
Start
AD
TX0
Zero Detector
ED
F R T S
E X X M
0 O C O
V O D
0 L 0
0
SBUF0
Q
CLR
Frame Error
Detection
S
M
1
0
S
M
2
0
R
E
N
0
T
B
8
0
TI0
R T R
B I I
8 0 0
0
EN
Serial Port
(UART0) Interrupt
RI0
Rx IRQ
Rx Control
Shift
Load
SBUF
Address
Match
Port I/O
0x1FF
Input Shift Register
(9 bits)
Load
SBUF0
RB80
SBUF0
Match Detect
SADDR0
SADEN0
Read
SBUF0
SFR Bus
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
RX0
Crossbar
Page 249
Advanced
Information
C8051F060/1/2/3
21.1.
UART0 Operational Modes
N
UART0 provides four operating modes (one synchronous and three asynchronous) selected by setting configuration
bits in the SCON0 register. These four modes offer different baud rates and communication protocols. The four
modes are summarized in Table 21.1.
Baud Clock
SYSCLK / 12
Timer 1, 2, 3, or 4 Overflow
SYSCLK / 32 or SYSCLK / 64
Timer 1, 2, 3, or 4 Overflow
Data Bits
8
8
9
9
AT
Synchronization
Synchronous
Asynchronous
Asynchronous
Asynchronous
IO
Table 21.1. UART0 Modes
Mode
0
1
2
3
RM
21.1.1. Mode 0: Synchronous Mode
Start/Stop Bits
None
1 Start, 1 Stop
1 Start, 1 Stop
1 Start, 1 Stop
Mode 0 provides synchronous, half-duplex communication. Serial data is transmitted and received on the RX0 pin.
The TX0 pin provides the shift clock for both transmit and receive. The MCU must be the master since it generates
the shift clock for transmission in both directions (see the interconnect diagram in Figure 21.3).
IN
FO
Data transmission begins when an instruction writes a data byte to the SBUF0 register. Eight data bits are transferred
LSB first (see the timing diagram in Figure 21.2), and the TI0 Transmit Interrupt Flag (SCON0.1) is set at the end of
the eighth bit time. Data reception begins when the REN0 Receive Enable bit (SCON0.4) is set to logic 1 and the RI0
Receive Interrupt Flag (SCON0.0) is cleared. One cycle after the eighth bit is shifted in, the RI0 flag is set and reception stops until software clears the RI0 bit. An interrupt will occur if enabled when either TI0 or RI0 are set.
The Mode 0 baud rate is SYSCLK / 12. RX0 is forced to open-drain in Mode 0, and an external pull-up will typically
be required.
D0
VA
NC
RX (data out)
ED
Figure 21.2. UART0 Mode 0 Timing Diagram
MODE 0 TRANSMIT
D1
D2
D3
D4
D5
D6
D7
TX (clk out)
RX (data in)
MODE 0 RECEIVE
D0
D1
D2
D3
D4
D5
D6
D7
AD
TX (clk out)
Figure 21.3. UART0 Mode 0 Interconnect
TX
CLK
RX
DATA
C8051Fxxx
Shift
Reg.
8 Extra Outputs
Page 250
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
21.1.2. Mode 1: 8-Bit UART, Variable Baud Rate
N
Mode 1 provides standard asynchronous, full duplex communication using a total of 10 bits per data byte: one start
bit, eight data bits (LSB first), and one stop bit. Data are transmitted from the TX0 pin and received at the RX0 pin.
On receive, the eight data bits are stored in SBUF0 and the stop bit goes into RB80 (SCON0.2).
AT
IO
Data transmission begins when an instruction writes a data byte to the SBUF0 register. The TI0 Transmit Interrupt
Flag (SCON0.1) is set at the end of the transmission (the beginning of the stop-bit time). Data reception can begin
any time after the REN0 Receive Enable bit (SCON0.4) is set to logic 1. After the stop bit is received, the data byte
will be loaded into the SBUF0 receive register if the following conditions are met: RI0 must be logic 0, and if SM20
is logic 1, the stop bit must be logic 1.
RM
If these conditions are met, the eight bits of data is stored in SBUF0, the stop bit is stored in RB80 and the RI0 flag is
set. If these conditions are not met, SBUF0 and RB80 will not be loaded and the RI0 flag will not be set. An interrupt
will occur if enabled when either TI0 or RI0 are set.
Figure 21.4. UART0 Mode 1 Timing Diagram
MARK
SPACE
D0
D1
D2
D3
D4
D5
D6
D7
STOP
BIT
FO
START
BIT
BIT TIMES
IN
BIT SAMPLING
ED
The baud rate generated in Mode 1 is a function of timer overflow, shown in Equation 21.1 and Equation 21.2.
UART0 can use Timer 1 operating in 8-Bit Auto-Reload Mode, or Timer 2, 3, or 4 operating in Auto-reload Mode to
generate the baud rate (note that the TX and RX clocks are selected separately). On each timer overflow event (a rollover from all ones - (0xFF for Timer 1, 0xFFFF for Timer 2) - to zero) a clock is sent to the baud rate logic.
VA
NC
Timers 1, 2, 3, and 4 are selected as the baud rate source with bits in the SSTA0 register (see Figure 21.9). The transmit baud rate clock is selected using the S0TCLK1 and S0TCLK0 bits, and the receive baud rate clock is selected
using the S0RCLK1 and S0RCLK0 bits.
The Mode 1 baud rate equations are shown below, where T1M is bit4 of register CKCON, TH1 is the 8-bit reload register for Timer 1, and [RCAPnH , RCAPnL] is the 16-bit reload register for Timer 2, 3, or 4.
Equation 21.1. Mode 1 Baud Rate using Timer 1
SMOD0
( T1M – 1 ) )
AD
2
SYSCLK × 12
BaudRate =  ------------------- ×  --------------------------------------------------------
( 256 – TH1 )
32
Equation 21.2. Mode 1 Baud Rate using Timer 2, 3, or 4
SYSCLK
BaudRate = --------------------------------------------------------------------------------------------16 × ( 65536 – [ RCAPnH, RCAPnL ] )
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 251
Advanced
Information
C8051F060/1/2/3
21.1.3. Mode 2: 9-Bit UART, Fixed Baud Rate
IO
N
Mode 2 provides asynchronous, full-duplex communication using a total of eleven bits per data byte: a start bit, 8 data
bits (LSB first), a programmable ninth data bit, and a stop bit. Mode 2 supports multiprocessor communications and
hardware address recognition (see Section 21.2). On transmit, the ninth data bit is determined by the value in TB80
(SCON0.3). It can be assigned the value of the parity flag P in the PSW or used in multiprocessor communications.
On receive, the ninth data bit goes into RB80 (SCON0.2) and the stop bit is ignored.
SM20 is logic 0
SM20 is logic 1, the received 9th bit is logic 1, and the received address matches the UART0 address as
described in Section 21.2.
RM
1.
2.
AT
Data transmission begins when an instruction writes a data byte to the SBUF0 register. The TI0 Transmit Interrupt
Flag (SCON0.1) is set at the end of the transmission (the beginning of the stop-bit time). Data reception can begin
any time after the REN0 Receive Enable bit (SCON0.4) is set to logic 1. After the stop bit is received, the data byte
will be loaded into the SBUF0 receive register if RI0 is logic 0 and one of the following requirements are met:
FO
If the above conditions are satisfied, the eight bits of data are stored in SBUF0, the ninth bit is stored in RB80 and the
RI0 flag is set. If these conditions are not met, SBUF0 and RB80 will not be loaded and the RI0 flag will not be set.
An interrupt will occur if enabled when either TI0 or RI0 are set.
The baud rate in Mode 2 is either SYSCLK / 32 or SYSCLK / 64, according to the value of the SMOD0 bit in register
SSTA0.
ED
IN
Equation 21.3. Mode 2 Baud Rate
SMOD0  SYSCLK
BaudRate = 2
×  ----------------------
64
Figure 21.5. UART0 Modes 2 and 3 Timing Diagram
SPACE
BIT TIMES
D0
D1
D2
D3
D4
D5
D6
D7
D8
STOP
BIT
AD
BIT SAMPLING
START
BIT
VA
NC
MARK
Page 252
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 21.6. UART0 Modes 1, 2, and 3 Interconnect Diagram
TX
N
C8051Fxxx
RX
IO
RS-232
LEVEL
XLTR
RS-232
TX
TX
RX
RX
C8051Fxxx
21.1.4. Mode 3: 9-Bit UART, Variable Baud Rate
RM
MCU
AT
OR
AD
VA
NC
ED
IN
FO
Mode 3 uses the Mode 2 transmission protocol with the Mode 1 baud rate generation. Mode 3 operation transmits 11
bits: a start bit, 8 data bits (LSB first), a programmable ninth data bit, and a stop bit. The baud rate is derived from
Timer 1 or Timer 2, 3, or 4 overflows, as defined by Equation 21.1 and Equation 21.2. Multiprocessor communications and hardware address recognition are supported, as described in Section 21.2.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 253
C8051F060/1/2/3
21.2.
Advanced
Information
Multiprocessor Communications
IO
N
Modes 2 and 3 support multiprocessor communication between a master processor and one or more slave processors
by special use of the ninth data bit and the built-in UART0 address recognition hardware. When a master processor
wants to transmit to one or more slaves, it first sends an address byte to select the target(s). An address byte differs
from a data byte in that its ninth bit is logic 1; in a data byte, the ninth bit is always set to logic 0. UART0 will recognize as “valid” (i.e., capable of causing an interrupt) two types of addresses: (1) a masked address and (2) a broadcast
address at any given time. Both are described below.
AT
21.2.1. Configuration of a Masked Address
RM
The UART0 address is configured via two SFR’s: SADDR0 (Serial Address) and SADEN0 (Serial Address Enable).
SADEN0 sets the bit mask for the address held in SADDR0: bits set to logic 1 in SADEN0 correspond to bits in
SADDR0 that are checked against the received address byte; bits set to logic 0 in SADEN0 correspond to “don’t
care” bits in SADDR0.
Example 2, SLAVE #2
SADDR0
= 00110101
SADEN0
= 11110011
UART0 Address = 0011xx01
Example 3, SLAVE #3
SADDR0
= 00110101
SADEN0
= 11000000
UART0 Address = 00xxxxxx
FO
Example 1, SLAVE #1
SADDR0
= 00110101
SADEN0
= 00001111
UART0 Address = xxxx0101
IN
Setting the SM20 bit (SCON0.5) configures UART0 such that when a stop bit is received, UART0 will generate an
interrupt only if the ninth bit is logic 1 (RB80 = ‘1’) and the received data byte matches the UART0 slave address.
Following the received address interrupt, the slave will clear its SM20 bit to enable interrupts on the reception of the
following data byte(s). Once the entire message is received, the addressed slave resets its SM20 bit to ignore all transmissions until it receives the next address byte. While SM20 is logic 1, UART0 ignores all bytes that do not match the
UART0 address and include a ninth bit that is logic 1.
ED
21.2.2. Broadcast Addressing
VA
NC
Multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple slaves,
thereby enabling "broadcast" transmissions to more than one slave simultaneously. The broadcast address is the logical OR of registers SADDR0 and SADEN0, and ‘0’s of the result are treated as “don’t cares”. Typically a broadcast
address of 0xFF (hexadecimal) is acknowledged by all slaves, assuming “don’t care” bits as ‘1’s. The master processor can be configured to receive all transmissions or a protocol can be implemented such that the master/slave role is
temporarily reversed to enable half-duplex transmission between the original master and slave(s)..
AD
Example 4, SLAVE #1
Example 5, SLAVE #2
Example 6, SLAVE #3
SADDR0
= 00110101
SADDR0
= 00110101
SADDR0
= 00110101
SADEN0
= 00001111
SADEN0
= 11110011
SADEN0
= 11000000
Broadcast Address = 00111111
Broadcast Address = 11110111
Broadcast Address = 11110101
Where all ZEROES in the Broadcast address are don’t cares.
Note in the above examples 4, 5, and 6, each slave would recognize as “valid” an address of 0xFF as a broadcast
address. Also note that examples 4, 5, and 6 uses the same SADDR0 and SADEN0 register values as shown in the
examples 1, 2, and 3 respectively (slaves #1, 2, and 3). Thus, a master could address each slave device individually
using a masked address, and also broadcast to all three slave devices. For example, if a Master were to send an
address “11110101”, only slave #1 would recognize the address as valid. If a master were to then send an address of
“11111111”, all three slave devices would recognize the address as a valid broadcast address.
Page 254
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
21.3.
TX
RX
TX
RX
Frame and Transmission Error Detection
TX
Slave
Device
IO
Slave
Device
AT
RX
Slave
Device
RX
+5V
TX
RM
Master
Device
N
Figure 21.7. UART Multi-Processor Mode Interconnect Diagram
FO
All Modes:
The Transmit Collision bit (TXCOL0 bit in register SCON0) reads ‘1’ if user software writes data to the SBUF0 register while a transmit is in progress. Note that the TXCOL0 bit is also used as the SM20 bit when written by user software. This bit does not generate an interrupt.
AD
VA
NC
ED
IN
Modes 1, 2, and 3:
The Receive Overrun bit (RXOV0 in register SCON0) reads ‘1’ if a new data byte is latched into the receive buffer
before software has read the previous byte. Note that the RXOV0 bit is also used as the SM10 bit when written by
user software. The Frame Error bit (FE0 in register SCON0) reads ‘1’ if an invalid (low) STOP bit is detected. Note
that the FE0 bit is also used as the SM00 bit when written by user software. The RXOV0 and FE0 bits do not generate
interrupts.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 255
C8051F060/1/2/3
Advanced
Information
Table 21.2. Oscillator Frequencies for Standard Baud Rates
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Oscillator frequency Divide Factor Timer 1 Reload Timer 2, 3, or 4 Resulting Baud Rate (Hz)**
(MHz)
Value*
Reload Value
24.0
208
0xF3
0xFFF3
115200 (115384)
22.1184
192
0xF4
0xFFF4
115200
18.432
160
0xF6
0xFFF6
115200
11.0592
96
0xFA
0xFFFA
115200
3.6864
32
0xFE
0xFFFE
115200
1.8432
16
0xFF
0xFFFF
115200
24.0
832
0xCC
0xFFCC
28800 (28846)
22.1184
768
0xD0
0xFFD0
28800
18.432
640
0xD8
0xFFD8
28800
11.0592
348
0xE8
0xFFE8
28800
3.6864
128
0xF8
0xFFF8
28800
1.8432
64
0xFC
0xFFFC
28800
24.0
2496
0x64
0xFF64
9600 (9615)
22.1184
2304
0x70
0xFF70
9600
18.432
1920
0x88
0xFF88
9600
11.0592
1152
0xB8
0xFFB8
9600
3.6864
384
0xE8
0xFFE8
9600
1.8432
192
0xF4
0xFFF4
9600
* Assumes SMOD0=1 and T1M=1.
** Numbers in parenthesis show the actual baud rate.
Page 256
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 21.8. SCON0: UART0 Control Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
SM00
SM10
SM20
REN0
TB80
RB80
TI0
RI0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0x98
SFR Page: 0
Mode
Mode 0: Synchronous Mode
Mode 1: 8-Bit UART, Variable Baud Rate
Mode 2: 9-Bit UART, Fixed Baud Rate
Mode 3: 9-Bit UART, Variable Baud Rate
Reading these bits returns the current UART0 mode as defined above.
SM20: Multiprocessor Communication Enable.
The function of this bit is dependent on the Serial Port Operation Mode.
Mode 0: No effect.
Mode 1: Checks for valid stop bit.
0: Logic level of stop bit is ignored.
1: RI0 will only be activated if stop bit is logic level 1.
Mode 2 and 3: Multiprocessor Communications Enable.
0: Logic level of ninth bit is ignored.
1: RI0 is set and an interrupt is generated only when the ninth bit is logic 1 and the received
address matches the UART0 address or the broadcast address.
REN0: Receive Enable.
This bit enables/disables the UART0 receiver.
0: UART0 reception disabled.
1: UART0 reception enabled.
TB80: Ninth Transmission Bit.
The logic level of this bit will be assigned to the ninth transmission bit in Modes 2 and 3. It is not used
in Modes 0 and 1. Set or cleared by software as required.
RB80: Ninth Receive Bit.
The bit is assigned the logic level of the ninth bit received in Modes 2 and 3. In Mode 1, if SM20 is
logic 0, RB80 is assigned the logic level of the received stop bit. RB8 is not used in Mode 0.
TI0: Transmit Interrupt Flag.
Set by hardware when a byte of data has been transmitted by UART0 (after the 8th bit in Mode 0, or
at the beginning of the stop bit in other modes). When the UART0 interrupt is enabled, setting this bit
causes the CPU to vector to the UART0 interrupt service routine. This bit must be cleared manually
by software.
RI0: Receive Interrupt Flag.
Set by hardware when a byte of data has been received by UART0 (as selected by the SM20 bit).
When the UART0 interrupt is enabled, setting this bit causes the CPU to vector to the UART0 interrupt service routine. This bit must be cleared manually by software.
Bit3:
Bit2:
AD
Bit1:
VA
NC
Bit4:
ED
IN
Bit5:
SM10
0
1
0
1
FO
SM00
0
0
1
1
AT
SM00-SM10: Serial Port Operation Mode:
Write:
When written, these bits select the Serial Port Operation Mode as follows:
RM
Bits7-6:
Bit0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 257
Advanced
Information
C8051F060/1/2/3
Figure 21.9. SSTA0: UART0 Status and Clock Selection Register
R/W
R/W
R/W
FE0
RXOV0
TXCOL0
Bit7
Bit6
Bit5
R/W
R/W
R/W
R/W
Reset Value
SMOD0 S0TCLK1 S0TCLK0 S0RCLK1 S0RCLK0 00000000
Bit4
Bit3
Bit2
N
R/W
Bit1
Bit0
IO
SFR Address: 0x91
SFR Page: 0
FE0: Frame Error Flag.†
This flag indicates if an invalid (low) STOP bit is detected.
0: Frame Error has not been detected.
1: Frame Error has been detected.
RXOV0: Receive Overrun Flag.†
This flag indicates new data has been latched into the receive buffer before software has read the previous byte.
0: Receive overrun has not been detected.
1: Receive Overrun has been detected.
TXCOL0: Transmit Collision Flag.†
This flag indicates user software has written to the SBUF0 register while a transmission is in
progress.
0: Transmission Collision has not been detected.
1: Transmission Collision has been detected.
SMOD0: UART0 Baud Rate Doubler Enable.
This bit enables/disables the divide-by-two function of the UART0 baud rate logic for configurations
described in the UART0 section.
0: UART0 baud rate divide-by-two enabled.
1: UART0 baud rate divide-by-two disabled.
AT
Bit7:
RM
Bit6:
Bit4:
Bits3-2:
UART0 Transmit Baud Rate Clock Selection Bits.
AD
Page 258
Serial Transmit Baud Rate Clock Source
Timer 1 generates UART0 TX Baud Rate
Timer 2 Overflow generates UART0 TX baud rate
Timer 3 Overflow generates UART0 TX baud rate
Timer 4 Overflow generates UART0 TX baud rate
UART0 Receive Baud Rate Clock Selection Bits.
S0RCLK1
0
0
1
1
† Note:
S0TCLK0
0
1
0
1
VA
NC
S0TCLK1
0
0
1
1
Bits1-0:
ED
IN
FO
Bit5:
S0RCLK0
0
1
0
1
Serial Receive Baud Rate Clock Source
Timer 1 generates UART0 RX Baud Rate
Timer 2 Overflow generates UART0 RX baud rate
Timer 3 Overflow generates UART0 RX baud rate
Timer 4 Overflow generates UART0 RX baud rate
FE0, RXOV0, and TXCOL0 are flags only, and no interrupt is generated by these conditions.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Bit7
R/W
Bit6
R/W
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
R/W
IO
R/W
N
Figure 21.10. SBUF0: UART0 Data Buffer Register
Bit2
Bit1
Reset Value
00000000
Bit0
SBUF0.[7:0]: UART0 Buffer Bits 7-0 (MSB-LSB).
This is actually two registers; a transmit and a receive buffer register. When data is moved to SBUF0,
it goes to the transmit buffer and is held for serial transmission. Moving a byte to SBUF0 is what initiates the transmission. When data is moved from SBUF0, it comes from the receive buffer.
FO
RM
Bits7-0:
AT
SFR Address: 0x99
SFR Page: 0
Bits7-0:
Bit6
R/W
R/W
Bit5
Bit4
R/W
Bit3
R/W
R/W
R/W
Reset Value
00000000
Bit2
Bit1
Bit0
SFR Address: 0xA9
SFR Page: 0
ED
Bit7
R/W
SADDR0.[7:0]: UART0 Slave Address.
The contents of this register are used to define the UART0 slave address. Register SADEN0 is a bit
mask to determine which bits of SADDR0 are checked against a received address: corresponding bits
set to logic 1 in SADEN0 are checked; corresponding bits set to logic 0 are “don’t cares”.
VA
NC
R/W
IN
Figure 21.11. SADDR0: UART0 Slave Address Register
Figure 21.12. SADEN0: UART0 Slave Address Enable Register
R/W
AD
R/W
Bit7
Bits7-0:
Bit6
R/W
Bit5
R/W
R/W
R/W
R/W
R/W
Reset Value
00000000
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: 0xB9
SFR Page: 0
SADEN0.[7:0]: UART0 Slave Address Enable.
Bits in this register enable corresponding bits in register SADDR0 to determine the UART0 slave
address.
0: Corresponding bit in SADDR0 is a “don’t care”.
1: Corresponding bit in SADDR0 is checked against a received address.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 259
C8051F060/1/2/3
Advanced
Information
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
Notes
Page 260
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
22.
C8051F060/1/2/3
UART1
IO
N
UART1 is an asynchronous, full duplex serial port offering modes 1 and 3 of the standard 8051 UART. Enhanced
baud rate support allows a wide range of clock sources to generate standard baud rates (details in Section
“22.1. Enhanced Baud Rate Generation” on page 262). Received data buffering allows UART1 to start reception
of a second incoming data byte before software has finished reading the previous data byte.
AT
UART1 has two associated SFRs: Serial Control Register 1 (SCON1) and Serial Data Buffer 1 (SBUF1). The single
SBUF1 location provides access to both transmit and receive registers. Reading SBUF1 accesses the buffered
Receive register; writing SBUF1 accesses the Transmit register.
RM
With UART1 interrupts enabled, an interrupt is generated each time a transmit is completed (TI1 is set in SCON1), or
a data byte has been received (RI1 is set in SCON1). The UART1 interrupt flags are not cleared by hardware when
the CPU vectors to the interrupt service routine. They must be cleared manually by software, allowing software to
determine the cause of the UART1 interrupt (transmit complete or receive complete).
Figure 22.1. UART1 Block Diagram
FO
SFR Bus
Write to
SBUF1
TB81
SBUF1
(TX Shift)
SET
D
Q
IN
CLR
TX1
Crossbar
Zero Detector
Stop Bit
Shift
Start
Data
ED
Tx Control
Tx Clock
Tx IRQ
Send
TI1
Serial
Port
Interrupt
MCE1
REN1
TB81
RB81
TI1
RI1
S1MODE
VA
NC
SCON1
UART1 Baud
Rate Generator
Port I/O
RI1
Rx IRQ
Rx Clock
Rx Control
Shift
AD
Start
0x1FF
RB81
Load
SBUF1
Input Shift Register
(9 bits)
Load SBUF1
SBUF1
(RX Latch)
Read
SBUF1
SFR Bus
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
RX1
Crossbar
Page 261
Advanced
Information
C8051F060/1/2/3
22.1.
Enhanced Baud Rate Generation
AT
Figure 22.2. UART1 Baud Rate Logic
IO
N
The UART1 baud rate is generated by Timer 1 in 8-bit auto-reload mode. The TX clock is generated by TL1; the RX
clock is generated by a copy of TL1 (shown as RX Timer in Figure 22.2), which is not user-accessible. Both TX and
RX Timer overflows are divided by two to generate the TX and RX baud rates. The RX Timer runs when Timer 1 is
enabled, and uses the same reload value (TH1). However, an RX Timer reload is forced when a START condition is
detected on the RX pin. This allows a receive to begin any time a START is detected, independent of the TX Timer
state.
Timer 1
UART1
Overflow
2
TX Clock
2
RX Clock
RM
TL1
FO
TH1
Start
Detected
Overflow
IN
RX Timer
ED
Timer 1 should be configured for Mode 2, 8-bit auto-reload (see Section “23.1.3. Mode 2: 8-bit Counter/Timer
with Auto-Reload” on page 273). The Timer 1 reload value should be set so that overflows will occur at two times
the desired baud rate. Note that Timer 1 may be clocked by one of five sources: SYSCLK, SYSCLK / 4, SYSCLK /
12, SYSCLK / 48, or the external oscillator clock / 8. For any given Timer 1 clock source, the UART1 baud rate is
determined by Equation 22.1.
VA
NC
Equation 22.1. UART1 Baud Rate
T1 CLK
1
UartBaudRate = ------------------------------- × --( 256 – T1H ) 2
AD
Where T1CLK is the frequency of the clock supplied to Timer 1, and T1H is the high byte of Timer 1 (reload value).
Timer 1 clock frequency is selected as described in Section “23.1. Timer 0 and Timer 1” on page 271. A quick reference for typical baud rates and system clock frequencies is given in Table 22.1 through Table 22.6. Note that the
internal oscillator may still generate the system clock when the external oscillator is driving Timer 1 (see Section
“23.1. Timer 0 and Timer 1” on page 271 for more details).
Page 262
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
22.2. Operational Modes
TX
RS-232
LEVEL
XLTR
RX
C8051Fxxx
AT
RS-232
IO
Figure 22.3. UART Interconnect Diagram
N
UART1 provides standard asynchronous, full duplex communication. The UART mode (8-bit or 9-bit) is selected by
the S1MODE bit (SCON1.7). Typical UART connection options are shown below.
RM
OR
TX
TX
MCU
C8051Fxxx
RX
FO
RX
22.2.1. 8-Bit UART
IN
8-Bit UART mode uses a total of 10 bits per data byte: one start bit, eight data bits (LSB first), and one stop bit. Data
are transmitted LSB first from the TX1 pin and received at the RX1 pin. On receive, the eight data bits are stored in
SBUF1 and the stop bit goes into RB81 (SCON1.2).
VA
NC
ED
Data transmission begins when software writes a data byte to the SBUF1 register. The TI1 Transmit Interrupt Flag
(SCON1.1) is set at the end of the transmission (the beginning of the stop-bit time). Data reception can begin any
time after the REN1 Receive Enable bit (SCON1.4) is set to logic 1. After the stop bit is received, the data byte will
be loaded into the SBUF1 receive register if the following conditions are met: RI1 must be logic 0, and if MCE1 is
logic 1, the stop bit must be logic 1. In the event of a receive data overrun, the first received 8 bits are latched into the
SBUF1 receive register and the following overrun data bits are lost.
If these conditions are met, the eight bits of data is stored in SBUF1, the stop bit is stored in RB81 and the RI1 flag is
set. If these conditions are not met, SBUF1 and RB81 will not be loaded and the RI1 flag will not be set. An interrupt
will occur if enabled when either TI1 or RI1 is set.
Figure 22.4. 8-Bit UART Timing Diagram
START
BIT
AD
MARK
SPACE
D0
D1
D2
D3
D4
D5
D6
D7
STOP
BIT
BIT TIMES
BIT SAMPLING
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 263
Advanced
Information
C8051F060/1/2/3
22.2.2. 9-Bit UART
IO
N
9-bit UART mode uses a total of eleven bits per data byte: a start bit, 8 data bits (LSB first), a programmable ninth
data bit, and a stop bit. The state of the ninth transmit data bit is determined by the value in TB81 (SCON1.3), which
is assigned by user software. It can be assigned the value of the parity flag (bit P in register PSW) for error detection,
or used in multiprocessor communications. On receive, the ninth data bit goes into RB81 (SCON1.2) and the stop bit
is ignored.
RM
AT
Data transmission begins when an instruction writes a data byte to the SBUF1 register. The TI1 Transmit Interrupt
Flag (SCON1.1) is set at the end of the transmission (the beginning of the stop-bit time). Data reception can begin
any time after the REN1 Receive Enable bit (SCON1.4) is set to ‘1’. After the stop bit is received, the data byte will
be loaded into the SBUF1 receive register if the following conditions are met: (1) RI1 must be logic 0, and (2) if
MCE1 is logic 1, the 9th bit must be logic 1 (when MCE1 is logic 0, the state of the ninth data bit is unimportant). If
these conditions are met, the eight bits of data are stored in SBUF1, the ninth bit is stored in RB81, and the RI1 flag is
set to ‘1’. If the above conditions are not met, SBUF1 and RB81 will not be loaded and the RI1 flag will not be set to
‘1’. A UART1 interrupt will occur if enabled when either TI1 or RI1 is set to ‘1’.
Figure 22.5. 9-Bit UART Timing Diagram
START
BIT
D0
D1
D2
D3
D4
FO
MARK
SPACE
BIT TIMES
D6
D7
D8
STOP
BIT
AD
VA
NC
ED
IN
BIT SAMPLING
D5
Page 264
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
22.3.
C8051F060/1/2/3
Multiprocessor Communications
IO
N
9-Bit UART mode supports multiprocessor communication between a master processor and one or more slave processors by special use of the ninth data bit. When a master processor wants to transmit to one or more slaves, it first
sends an address byte to select the target(s). An address byte differs from a data byte in that its ninth bit is logic 1; in
a data byte, the ninth bit is always set to logic 0.
RM
AT
Setting the MCE1 bit (SCON.5) of a slave processor configures its UART such that when a stop bit is received, the
UART will generate an interrupt only if the ninth bit is logic one (RB81 = 1) signifying an address byte has been
received. In the UART interrupt handler, software should compare the received address with the slave's own assigned
8-bit address. If the addresses match, the slave should clear its MCE1 bit to enable interrupts on the reception of the
following data byte(s). Slaves that weren't addressed leave their MCE1 bits set and do not generate interrupts on the
reception of the following data bytes, thereby ignoring the data. Once the entire message is received, the addressed
slave should reset its MCE1 bit to ignore all transmissions until it receives the next address byte.
Multiple addresses can be assigned to a single slave and/or a single address can be assigned to multiple slaves,
thereby enabling "broadcast" transmissions to more than one slave simultaneously. The master processor can be configured to receive all transmissions or a protocol can be implemented such that the master/slave role is temporarily
reversed to enable half-duplex transmission between the original master and slave(s).
TX
RX
TX
Slave
Device
RX
Slave
Device
+5V
TX
RX
TX
AD
VA
NC
RX
Slave
Device
ED
Master
Device
IN
FO
Figure 22.6. UART Multi-Processor Mode Interconnect Diagram
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 265
C8051F060/1/2/3
Advanced
Information
Figure 22.7. SCON1: Serial Port 1 Control Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
S1MODE
-
MCE1
REN1
TB81
RB81
TI1
RI1
01000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0x98
SFR Page: 1
Bit3:
Bit2:
Bit1:
AT
RM
FO
AD
Bit0:
IN
Bit4:
ED
Bit6:
Bit5:
S1MODE: Serial Port 1 Operation Mode.
This bit selects the UART1 Operation Mode.
0: 8-bit UART with Variable Baud Rate.
1: 9-bit UART with Variable Baud Rate.
UNUSED. Read = 1b. Write = don’t care.
MCE1: Multiprocessor Communication Enable.
The function of this bit is dependent on the Serial Port 0 Operation Mode.
S1MODE = 0: Checks for valid stop bit.
0: Logic level of stop bit is ignored.
1: RI1 will only be activated if stop bit is logic level 1.
S1MODE = 1: Multiprocessor Communications Enable.
0: Logic level of ninth bit is ignored.
1: RI1 is set and an interrupt is generated only when the ninth bit is logic 1.
REN1: Receive Enable.
This bit enables/disables the UART receiver.
0: UART1 reception disabled.
1: UART1 reception enabled.
TB81: Ninth Transmission Bit.
The logic level of this bit will be assigned to the ninth transmission bit in 9-bit UART Mode. It is not
used in 8-bit UART Mode. Set or cleared by software as required.
RB81: Ninth Receive Bit.
RB81 is assigned the value of the STOP bit in Mode 0; it is assigned the value of the 9th data bit in
Mode 1.
TI1: Transmit Interrupt Flag.
Set by hardware when a byte of data has been transmitted by UART1 (after the 8th bit in 8-bit UART
Mode, or at the beginning of the STOP bit in 9-bit UART Mode). When the UART1 interrupt is
enabled, setting this bit causes the CPU to vector to the UART1 interrupt service routine. This bit
must be cleared manually by software.
RI1: Receive Interrupt Flag.
Set to ‘1’ by hardware when a byte of data has been received by UART1 (set at the STOP bit sampling time). When the UART1 interrupt is enabled, setting this bit to ‘1’ causes the CPU to vector to
the UART1 interrupt service routine. This bit must be cleared manually by software.
VA
NC
Bit7:
Page 266
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Bit7
R/W
Bit6
R/W
R/W
Bit5
Bit4
R/W
R/W
Bit3
R/W
R/W
Reset Value
00000000
IO
R/W
N
Figure 22.8. SBUF1: Serial (UART1) Port Data Buffer Register
Bit2
Bit1
Bit0
SBUF1[7:0]: Serial Data Buffer Bits 7-0 (MSB-LSB).
This SFR accesses two registers; a transmit shift register and a receive latch register. When data is
written to SBUF1, it goes to the transmit shift register and is held for serial transmission. Writing a
byte to SBUF1 is what initiates the transmission. A read of SBUF1 returns the contents of the receive
latch.
AD
VA
NC
ED
IN
FO
RM
Bits7-0:
AT
SFR Address: 0x99
SFR Page: 1
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 267
Advanced
Information
C8051F060/1/2/3
-0.32%
-0.32%
0.15%
-0.32%
0.15%
-0.32%
-0.32%
0.15%
X = Don’t care
†SCA1-SCA0
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
T1M† Timer 1
Reload
Value (hex)
1
0xCB
1
0x96
1
0x2B
0
0x96
0
0xB9
0
0x96
0
0x96
0
0x2B
N
Oscillator
Divide
Factor
106
212
426
848
1704
2544
10176
20448
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 4
SYSCLK / 12
SYSCLK / 12
SYSCLK / 48
SYSCLK / 48
IO
Baud Rate
% Error
XX
XX
XX
01
00
00
10
10
AT
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
RM
SYSCLK from
Internal Osc.
Table 22.1. Timer Settings for Standard Baud Rates Using The Internal Oscillator
Frequency: 24.5 MHz
and T1M bit definitions can be found in Section 23.1.
9600
FO
-0.47%
0.45%
-0.01%
0.45%
-0.01%
0.15%
0.45%
-0.01%
-0.47%
-0.47%
0.45%
Oscillator
Divide
Factor
108
218
434
872
1736
2608
10464
20832
432
864
1744
0.15%
2608
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
IN
Baud Rate
% Error
ED
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
57600
28800
14400
VA
NC
SYSCLK from
Internal Osc.
SYSCLK from
External Osc.
Table 22.2. Timer Settings for Standard Baud Rates Using an External Oscillator
Frequency: 25.0 MHz
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 4
SYSCLK / 4
EXTCLK / 8
SYSCLK / 48
SYSCLK / 48
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
XX
XX
XX
01
01
11
10
10
11
11
11
EXTCLK / 8
11
T1M† Timer 1
Reload
Value (hex)
1
0xCA
1
0x93
1
0x27
0
0x93
0
0x27
0
0x5D
0
0x93
0
0x27
0
0xE5
0
0xCA
0
0x93
0
0x5D
AD
X = Don’t care
Page 268
†SCA1-SCA0
and T1M bit definitions can be found in Section 23.1.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
†
T1M† Timer 1
Reload
Value (hex)
1
0xD0
1
0xA0
1
0x40
0
0xE0
0
0xC0
0
0xA0
0
0xA0
0
0x40
0
0xFA
0
0xF4
0
0xE8
0
0xD0
0
0xA0
0
0x70
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 12
SYSCLK / 12
SYSCLK / 12
SYSCLK / 48
SYSCLK / 48
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
IO
N
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
XX
XX
XX
00
00
00
10
10
11
11
11
11
11
11
AT
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
X = Don’t care
Oscillator
Divide
Factor
96
192
384
768
1536
2304
9216
18432
96
192
384
768
1536
2304
RM
Baud Rate
% Error
FO
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
230400
115200
57600
28800
14400
9600
IN
SYSCLK from
Internal Osc.
SYSCLK from
External Osc.
Table 22.3. Timer Settings for Standard Baud Rates Using an External Oscillator
Frequency: 22.1184 MHz
SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
Oscillator
Divide
Factor
80
160
320
640
1280
1920
7680
15360
80
160
320
640
1280
1920
ED
Baud Rate
% Error
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
X = Don’t care
VA
NC
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
230400
115200
57600
28800
14400
9600
AD
SYSCLK from
Internal Osc.
SYSCLK from
External Osc.
Table 22.4. Timer Settings for Standard Baud Rates Using an External Oscillator
Frequency: 18.432 MHz
†
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 4
SYSCLK / 4
SYSCLK / 12
SYSCLK / 48
SYSCLK / 48
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
XX
XX
XX
01
01
00
10
10
11
11
11
11
11
11
T1M† Timer 1
Reload
Value (hex)
1
0xD8
1
0xB0
1
0x60
0
0xB0
0
0x60
0
0xB0
0
0xB0
0
0x60
0
0xFB
0
0xF6
0
0xEC
0
0xD8
0
0xB0
0
0x88
SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 269
C8051F060/1/2/3
Advanced
Information
†
T1M† Timer 1
Reload
Value (hex)
1
0xE8
1
0xD0
1
0xA0
1
0x40
0
0xE0
0
0xD0
0
0x40
0
0xA0
0
0xFD
0
0xFA
0
0xF4
0
0xE8
0
0xD0
0
0xB8
SYSCLK
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 12
SYSCLK / 12
SYSCLK / 12
SYSCLK / 48
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
IO
N
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
XX
XX
XX
XX
00
00
00
10
11
11
11
11
11
11
AT
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
X = Don’t care
Oscillator
Divide
Factor
48
96
192
384
768
1152
4608
9216
48
96
192
384
768
1152
RM
Baud Rate
% Error
FO
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
230400
115200
57600
28800
14400
9600
IN
SYSCLK from
Internal Osc.
SYSCLK from
External Osc.
Table 22.5. Timer Settings for Standard Baud Rates Using an External Oscillator
Frequency: 11.0592 MHz
SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
0.00%
X = Don’t care
†
Page 270
Oscillator
Divide
Factor
16
32
64
128
256
384
1536
3072
16
32
64
128
256
384
ED
Baud Rate
% Error
VA
NC
Target
Baud Rate
(bps)
230400
115200
57600
28800
14400
9600
2400
1200
230400
115200
57600
28800
14400
9600
AD
SYSCLK from
Internal Osc.
SYSCLK from
External Osc.
Table 22.6. Timer Settings for Standard Baud Rates Using an External Oscillator
Frequency: 3.6864 MHz
Timer Clock SCA1-SCA0
Source
(pre-scale select)†
SYSCLK
SYSCLK
SYSCLK
SYSCLK
SYSCLK
SYSCLK
SYSCLK / 12
SYSCLK / 12
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
EXTCLK / 8
XX
XX
XX
XX
XX
XX
00
00
11
11
11
11
11
11
T1M† Timer 1
Reload
Value (hex)
1
0xF8
1
0xF0
1
0xE0
1
0xC0
1
0x80
1
0x40
0
0xC0
0
0x80
0
0xFF
0
0xFE
0
0xFC
0
0xF8
0
0xF0
0
0xE8
SCA1-SCA0 and T1M bit definitions can be found in Section 23.1.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
23.
C8051F060/1/2/3
TIMERS
RM
AT
Timer 0 and Timer 1 Modes:
Timer 2, 3, and 4 Modes:
13-bit counter/timer
16-bit counter/timer with auto-reload
16-bit counter/timer
16-bit counter/timer with capture
8-bit counter/timer with auto-reload
Toggle Output
Two 8-bit counter/timers (Timer 0 only)
IO
N
Each MCU includes 5 counter/timers: Timer 0 and Timer 1 are 16-bit counter/timers compatible with those found in
the standard 8051. Timer 2, Timer 3, and Timer 4 are 16-bit auto-reload and capture counter/timers for use with the
ADC, DAC’s, square-wave generation, or for general-purpose use. These timers can be used to measure time intervals, count external events and generate periodic interrupt requests. Timer 0 and Timer 1 are nearly identical and have
four primary modes of operation. Timers 2, 3, and 4 are identical, and offer not only 16-bit auto-reload and capture,
but have the ability to produce a 50% duty-cycle square-wave (toggle output) at an external port pin.
Timers 0 and 1 may be clocked by one of five sources, determined by the Timer Mode Select bits (T1M-T0M) and
the Clock Scale bits (SCA1-SCA0). The Clock Scale bits define a pre-scaled clock by which Timer 0 and/or Timer 1
may be clocked (See Figure 23.6 for pre-scaled clock selection).
FO
Timer 0/1 may then be configured to use this pre-scaled clock signal or the system clock. Timers 2, 3, and 4 may be
clocked by the system clock, the system clock divided by 12, or the external oscillator clock source divided by 8.
Timer 0 and Timer 1
ED
23.1.
IN
Timer 0 and Timer 1 may also be operated as counters. When functioning as a counter, a counter/timer register is
incremented on each high-to-low transition at the selected input pin. Events with a frequency of up to one-fourth the
system clock's frequency can be counted. The input signal need not be periodic, but it should be held at a given logic
level for at least two full system clock cycles to ensure the level is properly sampled.
VA
NC
Each timer is implemented as 16-bit register accessed as two separate bytes: a low byte (TL0 or TL1) and a high byte
(TH0 or TH1). The Counter/Timer Control register (TCON) is used to enable Timer 0 and Timer 1 as well as indicate
their status. Timer 0 interrupts can be enabled by setting the ET0 bit in the IE register (Section “12.3.5. Interrupt
Register Descriptions” on page 146); Timer 1 interrupts can be enabled by setting the ET1 bit in the IE register
(Section 12.3.5). Both counter/timers operate in one of four primary modes selected by setting the Mode Select bits
T1M1-T0M0 in the Counter/Timer Mode register (TMOD). Each timer can be configured independently.
23.1.1. Mode 0: 13-bit Counter/Timer
Timer 0 and Timer 1 operate as 13-bit counter/timers in Mode 0. The following describes the configuration and operation of Timer 0. However, both timers operate identically, and Timer 1 is configured in the same manner as
described for Timer 0.
AD
The TH0 register holds the eight MSBs of the 13-bit counter/timer. TL0 holds the five LSBs in bit positions TL0.4TL0.0. The three upper bits of TL0 (TL0.7-TL0.5) are indeterminate and should be masked out or ignored when reading. As the 13-bit timer register increments and overflows from 0x1FFF (all ones) to 0x0000, the timer overflow flag
TF0 (TCON.5) is set and an interrupt will occur if Timer 0 interrupts are enabled.
The C/T0 bit (TMOD.2) selects the counter/timer's clock source. When C/T0 is set to logic 1, high-to-low transitions
at the selected Timer 0 input pin (T0) increment the timer register (Refer to Section “17.1. Ports 0 through 3 and
the Priority Crossbar Decoder” on page 193 for information on selecting and configuring external I/O pins). Clearing C/T selects the clock defined by the T0M bit (CKCON.3). When T0M is set, Timer 0 is clocked by the system
clock. When T0M is cleared, Timer 0 is clocked by the source selected by the Clock Scale bits in CKCON (see
Figure 23.6).
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 271
Advanced
Information
C8051F060/1/2/3
Setting the TR0 bit (TCON.4) enables the timer when either GATE0 (TMOD.3) is logic 0 or the input signal /INT0 is
logic-level 1. Setting GATE0 to ‘1’ allows the timer to be controlled by the external input signal /INT0 (see Section
“12.3.5. Interrupt Register Descriptions” on page 146), facilitating pulse width measurements.
N
Counter/Timer
Disabled
Enabled
Disabled
Enabled
IO
/INT0
X
X
0
1
AT
TR0
GATE0
0
X
1
0
1
1
1
1
X = Don't Care
Setting TR0 does not force the timer to reset. The timer registers should be loaded with the desired initial value before
the timer is enabled.
RM
TL1 and TH1 form the 13-bit register for Timer 1 in the same manner as described above for TL0 and TH0. Timer 1
is configured and controlled using the relevant TCON and TMOD bits just as with Timer 0. The input signal /INT1 is
used with Timer 1.
CKCON
Pre-scaled Clock
0
TMOD
SS
CC
AA
1 0
G
A
T
E
1
IN
TT
1 0
MM
FO
Figure 23.1. T0 Mode 0 Block Diagram
C
/
T
1
T TG
1 1 A
MM T
1 0 E
0
C T T
/ 0 0
T MM
0 1 0
SYSCLK
ED
0
1
TR0
GATE0
Crossbar
TL0
(5 bits)
TH0
(8 bits)
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
Interrupt
AD
/INT0
TCLK
TCON
T0
VA
NC
1
23.1.2. Mode 1: 16-bit Counter/Timer
Mode 1 operation is the same as Mode 0, except that the counter/timer registers use all 16 bits. The counter/timers are
enabled and configured in Mode 1 in the same manner as for Mode 0.
Page 272
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
23.1.3. Mode 2: 8-bit Counter/Timer with Auto-Reload
IO
N
Mode 2 configures Timer 0 and Timer 1 to operate as 8-bit counter/timers with automatic reload of the start value.
TL0 holds the count and TH0 holds the reload value. When the counter in TL0 overflows from 0xFF to 0x00, the
timer overflow flag TF0 (TCON.5) is set and the counter in TL0 is reloaded from TH0. If Timer 0 interrupts are
enabled, an interrupt will occur when the TF0 flag is set. The reload value in TH0 is not changed. TL0 must be initialized to the desired value before enabling the timer for the first count to be correct. When in Mode 2, Timer 1 operates
identically to Timer 0.
AT
Both counter/timers are enabled and configured in Mode 2 in the same manner as Mode 0. Setting the TR0 bit
(TCON.4) enables the timer when either GATE0 (TMOD.3) is logic 0 or when the input signal /INT0 is low.
Figure 23.2. T0 Mode 2 Block Diagram
CKCON
0
0
SYSCLK
IN
1
G
A
T
E
1
C
/
T
1
T TG
1 1 A
MM T
1 0 E
0
C
/
T
0
T T
0 0
MM
1 0
RM
Pre-scaled Clock
TMOD
SS
CC
AA
1 0
FO
TT
1 0
MM
1
TL0
(8 bits)
TCON
TCLK
ED
T0
TR0
TH0
(8 bits)
Interrupt
Reload
AD
/INT0
GATE0
VA
NC
Crossbar
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 273
Advanced
Information
C8051F060/1/2/3
23.1.4. Mode 3: Two 8-bit Counter/Timers (Timer 0 Only)
IO
N
In Mode 3, Timer 0 is configured as two separate 8-bit counter/timers held in TL0 and TH0. The counter/timer in TL0
is controlled using the Timer 0 control/status bits in TCON and TMOD: TR0, C/T0, GATE0 and TF0. TL0 can use
either the system clock or an external input signal as its timebase. The TH0 register is restricted to a timer function
sourced by the system clock or prescaled clock. TH0 is enabled using the Timer 1 run control bit TR1. TH0 sets the
Timer 1 overflow flag TF1 on overflow and thus controls the Timer 1 interrupt.
AT
Timer 1 is inactive in Mode 3. When Timer 0 is operating in Mode 3, Timer 1 can be operated in Modes 0, 1 or 2, but
cannot be clocked by external signals nor set the TF1 flag and generate an interrupt. However, the Timer 1 overflow
can be used to generate baud rates for the SMBus and/or UART, and/or initiate ADC conversions. While Timer 0 is
operating in Mode 3, Timer 1 run control is handled through its mode settings. To run Timer 1 while Timer 0 is in
Mode 3, set the Timer 1 Mode as 0, 1, or 2. To disable Timer 1, configure it for Mode 3.
CKCON
S
C
A
0
G
A
T
E
1
C
/
T
1
0
TR1
SYSCLK
T T G
1 1 A
MM T
1 0 E
0
C
/
T
0
T T
0 0
MM
1 0
1
IN
0
TH0
(8 bits)
TCON
Pre-scaled Clock
TMOD
S
C
A
1
FO
T T
1 0
MM
RM
Figure 23.3. T0 Mode 3 Block Diagram
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
Interrupt
Interrupt
1
ED
T0
TL0
(8 bits)
TR0
AD
/INT0
GATE0
VA
NC
Crossbar
Page 274
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 23.4. TCON: Timer Control Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Bit
Addressable
IO
N
R/W
SFR Address: 0x88
SFR Page: 0
Bit3:
Bit2:
Bit1:
AT
RM
AD
Bit0:
FO
Bit4:
IN
Bit5:
ED
Bit6:
TF1: Timer 1 Overflow Flag.
Set by hardware when Timer 1 overflows. This flag can be cleared by software but is automatically
cleared when the CPU vectors to the Timer 1 interrupt service routine.
0: No Timer 1 overflow detected.
1: Timer 1 has overflowed.
TR1: Timer 1 Run Control.
0: Timer 1 disabled.
1: Timer 1 enabled.
TF0: Timer 0 Overflow Flag.
Set by hardware when Timer 0 overflows. This flag can be cleared by software but is automatically
cleared when the CPU vectors to the Timer 0 interrupt service routine.
0: No Timer 0 overflow detected.
1: Timer 0 has overflowed.
TR0: Timer 0 Run Control.
0: Timer 0 disabled.
1: Timer 0 enabled.
IE1: External Interrupt 1.
This flag is set by hardware when an edge/level of type defined by IT1 is detected. It can be cleared
by software but is automatically cleared when the CPU vectors to the External Interrupt 1 service
routine if IT1 = 1. This flag is the inverse of the /INT1 signal.
IT1: Interrupt 1 Type Select.
This bit selects whether the configured /INT1 interrupt will be falling-edge sensitive or active-low.
0: /INT1 is level triggered, active-low.
1: /INT1 is edge triggered, falling-edge.
IE0: External Interrupt 0.
This flag is set by hardware when an edge/level of type defined by IT0 is detected. It can be cleared
by software but is automatically cleared when the CPU vectors to the External Interrupt 0 service
routine if IT0 = 1. This flag is the inverse of the /INT0 signal.
IT0: Interrupt 0 Type Select.
This bit selects whether the configured /INT0 interrupt will be falling-edge sensitive or active-low.
0: /INT0 is level triggered, active logic-low.
1: /INT0 is edge triggered, falling-edge.
VA
NC
Bit7:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 275
C8051F060/1/2/3
Advanced
Information
Figure 23.5. TMOD: Timer Mode Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
GATE1
C/T1
T1M1
T1M0
GATE0
C/T0
T0M1
T0M0
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
Bits5-4:
Bit2:
AT
Mode 0: 13-bit counter/timer
Mode 1: 16-bit counter/timer
Mode 2: 8-bit counter/timer with auto-reload
Mode 3: Timer 1 inactive
GATE0: Timer 0 Gate Control.
0: Timer 0 enabled when TR0 = 1 irrespective of /INT0 logic level.
1: Timer 0 enabled only when TR0 = 1 AND /INT0 = logic 1.
C/T0: Counter/Timer Select.
0: Timer Function: Timer 0 incremented by clock defined by T0M bit (CKCON.3).
1: Counter Function: Timer 0 incremented by high-to-low transitions on external input pin (T0).
T0M1-T0M0: Timer 0 Mode Select.
These bits select the Timer 0 operation mode.
VA
NC
Bits1-0:
Mode
ED
Bit3:
T1M0
0
1
0
1
IN
T1M1
0
0
1
1
RM
Bit6:
GATE1: Timer 1 Gate Control.
0: Timer 1 enabled when TR1 = 1 irrespective of /INT1 logic level.
1: Timer 1 enabled only when TR1 = 1 AND /INT1 = logic 1.
C/T1: Counter/Timer 1 Select.
0: Timer Function: Timer 1 incremented by clock defined by T1M bit (CKCON.4).
1: Counter Function: Timer 1 incremented by high-to-low transitions on external input pin (T1).
T1M1-T1M0: Timer 1 Mode Select.
These bits select the Timer 1 operation mode.
FO
Bit7:
IO
SFR Address: 0x89
SFR Page: 0
T0M0
0
1
0
1
Mode
Mode 0: 13-bit counter/timer
Mode 1: 16-bit counter/timer
Mode 2: 8-bit counter/timer with auto-reload
Mode 3: Two 8-bit counter/timers
AD
T0M1
0
0
1
1
Page 276
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 23.6. CKCON: Clock Control Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
SCA0
00000000
-
-
-
T1M
T0M
-
SCA1
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
AT
RM
SCA1
0
0
1
1
Prescaled Clock
System clock divided by 12
System clock divided by 4
System clock divided by 48
External clock divided by 8†
External clock divided by 8 is synchronized with the system clock, and external clock must be less
than or equal to the system clock frequency to operate the timer in this mode.
AD
VA
NC
†Note:
SCA0
0
1
0
1
FO
Bit2:
Bits1-0:
IN
Bit3:
UNUSED. Read = 000b, Write = don’t care.
T1M: Timer 1 Clock Select.
This select the clock source supplied to Timer 1. T1M is ignored when C/T1 is set to logic 1.
0: Timer 1 uses the clock defined by the prescale bits, SCA1-SCA0.
1: Timer 1 uses the system clock.
T0M: Timer 0 Clock Select.
This bit selects the clock source supplied to Timer 0. T0M is ignored when C/T0 is set to logic 1.
0: Counter/Timer 0 uses the clock defined by the prescale bits, SCA1-SCA0.
1: Counter/Timer 0 uses the system clock.
UNUSED. Read = 0b, Write = don’t care.
SCA1-SCA0: Timer 0/1 Prescale Bits
These bits control the division of the clock supplied to Timer 0 and/or Timer 1 if configured to use
prescaled clock inputs.
ED
Bits7-5:
Bit4:
IO
SFR Address: 0x8E
SFR Page: 0
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 277
C8051F060/1/2/3
Advanced
Information
Figure 23.7. TL0: Timer 0 Low Byte
Bit7
R/W
Bit6
R/W
R/W
Bit5
R/W
Bit4
R/W
Bit3
R/W
Bit2
Bit1
R/W
N
R/W
Reset Value
00000000
Bit0
TL0: Timer 0 Low Byte.
The TL0 register is the low byte of the 16-bit Timer 0
AT
Bits 7-0:
IO
SFR Address: 0x8A
SFR Page: 0
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
R/W
R/W
Bit2
Bit1
Bit0
Reset Value
00000000
SFR Address: 0x8B
SFR Page: 0
TL1: Timer 1 Low Byte.
The TL1 register is the low byte of the 16-bit Timer 1.
IN
Bits 7-0:
R/W
FO
R/W
RM
Figure 23.8. TL1: Timer 1 Low Byte
Figure 23.9. TH0: Timer 0 High Byte
Bits 7-0:
Bit6
R/W
Bit5
R/W
R/W
ED
Bit7
R/W
VA
NC
R/W
Bit4
R/W
R/W
R/W
Reset Value
00000000
Bit3
Bit2
Bit1
Bit0
SFR Address: 0x8C
SFR Page: 0
TH0: Timer 0 High Byte.
The TH0 register is the high byte of the 16-bit Timer 0.
Figure 23.10. TH1: Timer 1 High Byte
R/W
AD
R/W
Bit7
Bits 7-0:
Page 278
Bit6
R/W
R/W
R/W
R/W
R/W
R/W
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
00000000
SFR Address: 0x8D
SFR Page: 0
TH1: Timer 1 High Byte.
The TH1 register is the high byte of the 16-bit Timer 1.
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
23.2. Timer 2, Timer 3, and Timer 4
RM
AT
IO
N
Timers 2, 3, and 4 are 16-bit counter/timers, each formed by two 8-bit SFR’s: TMRnL (low byte) and TMRnH (high
byte) where n = 2, 3, and 4 for timers 2, 3, and 4 respectively. These timers feature auto-reload, capture, and toggle
output modes with the ability to count up or down. Capture Mode and Auto-reload mode are selected using bits in the
Timer 2, 3, and 4 Control registers (TMRnCN). Toggle output mode is selected using the Timer 2, 3, and 4 Configuration registers (TMRnCF). These timers may also be used to generate a square-wave at an external pin. As with
Timers 0 and 1, Timers 2, 3, and 4 can use either the system clock (divided by one, two, or twelve), external clock
(divided by eight) or transitions on an external input pin as its clock source. The Counter/Timer Select bit C/Tn bit
(TMRnCN.1) configures the peripheral as a counter or timer. Clearing C/Tn configures the Timer to be in a timer
mode (i.e., the system clock or transitions on an external pin as the input for the timer). When C/Tn is set to 1, the
timer is configured as a counter (i.e., high-to-low transitions at the Tn input pin increment (or decrement) the counter/
timer register. Refer to Section “17.1. Ports 0 through 3 and the Priority Crossbar Decoder” on page 193 for
information on selecting and configuring external I/O pins for digital peripherals, such as the Tn pin. Timer 2 and 3
can be used to start an ADC Data Conversion and Timers 2, 3, and 4 can schedule DAC outputs. Only Timer 1 can be
used to generate baud rates for UART 1, and Timers 1, 2, 3, or 4 may be used to generate baud rates for UART 0.
IN
FO
Timer 2, 3, and 4 can use either SYSCLK, SYSCLK divided by 2, SYSCLK divided by 12, an external clock divided
by 8, or high-to-low transitions on the Tn input pin as its clock source when operating in Counter/Timer with Capture
mode. Clearing the C/Tn bit (TnCON.1) selects the system clock/external clock as the input for the timer. The Timer
Clock Select bits TnM0 and TnM1 in TMRnCF can be used to select the system clock undivided, system clock
divided by two, system clock divided by 12, or an external clock provided at the XTAL1/XTAL2 pins divided by 8
(see Figure 23.14). When C/Tn is set to logic 1, a high-to-low transition at the Tn input pin increments the counter/
timer register (i.e., configured as a counter).
23.2.1. Configuring Timer 2, 3, and 4 to Count Down
ED
Timers 2, 3, and 4 have the ability to count down. When the timer’s respective Decrement Enable Bit (DCEN) in the
Timer Configuration Register (See Figure 23.14) is set to ‘1’, the timer can then count up or down. When DCEN = 1,
the direction of the timer’s count is controlled by the TnEX pin’s logic level. When TnEX = 1, the counter/timer will
count up; when TnEX = 0, the counter/timer will count down. To use this feature, TnEX must be enabled in the digital crossbar and configured as a digital input.
AD
VA
NC
Note: When DCEN = 1, other functions of the TnEX input (i.e., capture and auto-reload) are not available.
TnEX will only control the direction of the timer when DCEN = 1.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 279
C8051F060/1/2/3
Advanced
Information
23.2.2. Capture Mode
IO
N
In Capture Mode, Timer 2, 3, and 4 will operate as a 16-bit counter/timer with capture facility. When the Timer External Enable bit (found in the TMRnCN register) is set to ‘1’, a high-to-low transition on the TnEX input pin causes the
16-bit value in the associated timer (THn, TLn) to be loaded into the capture registers (RCAPnH, RCAPnL). If a capture is triggered in the counter/timer, the Timer External Flag (TMRnCN.6) will be set to ‘1’ and an interrupt will
occur if the interrupt is enabled. See Section “12.3. Interrupt Handler” on page 143 for further information concerning the configuration of interrupt sources.
RM
AT
As the 16-bit timer register increments and overflows TMRnH:TMRnL, the TFn Timer Overflow/Underflow Flag
(TMRnCN.7) is set to ‘1’ and an interrupt will occur if the interrupt is enabled. The timer can be configured to count
down by setting the Decrement Enable Bit (TMRnCF.0) to ‘1’. This will cause the timer to decrement with every
timer clock/count event and underflow when the timer transitions from 0x0000 to 0xFFFF. Just as in overflows, the
Overflow/Underflow Flag (TFn) will be set to ‘1’, and an interrupt will occur if enabled.
FO
Counter/Timer with Capture mode is selected by setting the Capture/Reload Select bit CP/RLn (TMRnCN.0) and the
Timer 2, 3, and 4 Run Control bit TRn (TnCON.2) to logic 1. The Timer 2, 3, and 4 respective External Enable
EXENn (TnCON.3) must also be set to logic 1 to enable a captures. If EXENn is cleared, transitions on TnEX will
be ignored.
Figure 23.11. T2, 3, and 4 Capture Mode Block Diagram
IN
TMRnCF
TTTTD
n nOnC
MMG O E
1 0 nEN
ED
2
12
External Clock
(XTAL1)
0
0xFF
TMRnL
TMRnH
TCLK
RCAPnL
RCAPnH
TnCON
Crossbar
TRn
EXENn
Capture
CP/RLn
C/Tn
TRn
EXENn
EXFn
TFn
Interrupt
Crossbar
AD
TnEX
Tn
(Port Pin)
1
OVF
1
Tn
0xFF
0
8
VA
NC
SYSCLK
Toggle Logic
Page 280
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
23.2.3. Auto-Reload Mode
AT
IO
N
In Auto-Reload Mode, the counter/timer can be configured to count up or down and cause an interrupt/flag to occur
upon an overflow/underflow event. When counting up, the counter/timer will set its overflow/underflow flag (TFn)
and cause an interrupt (if enabled) upon overflow/underflow, and the values in the Reload/Capture Registers
(RCAPnH and RCAPnL) are loaded into the timer and the timer is restarted. When the Timer External Enable Bit
(EXENn) bit is set to ‘1’ and the Decrement Enable Bit (DCEN) is ‘0’, a falling edge (‘1’-to-‘0’ transition) on the
TnEX pin (configured as an input in the digital crossbar) will cause a timer reload (in addition to timer overflows
causing auto-reloads). When DCEN is set to ‘1’, the state of the TnEX pin controls whether the counter/timer counts
up (increments) or down (decrements), and will not cause an auto-reload or interrupt event. See Section 23.2.1 for
information concerning configuration of a timer to count down.
RM
When counting down, the counter/timer will set its overflow/underflow flag (TFn) and cause an interrupt (if enabled)
when the value in the timer (TMRnH and TMRnL registers) matches the 16-bit value in the Reload/Capture Registers
(RCAPnH and RCAPnL). This is considered an underflow event, and will cause the timer to load the value 0xFFFF.
The timer is automatically restarted when an underflow occurs.
Counter/Timer with Auto-Reload mode is selected by clearing the CP/RLn bit. Setting TRn to logic 1 enables and
starts the timer.
FO
In Auto-Reload Mode, the External Flag (EXFn) toggles upon every overflow or underflow and does not cause an
interrupt. The EXFn flag can be thought of as the most significant bit (MSB) of a 17-bit counter.
IN
.
Figure 23.12. T2, 3, and 4 Auto-reload Mode Block Diagram
TMRnCF
ED
TTTTD
n nOnC
MMG O E
1 0 n EN
VA
NC
2
Toggle Logic
12
SYSCLK
External Clock
(XTAL1)
0xFF
TMRnL
TMRnH
RCAPnL
RCAPnH
1
OVF
TCLK
TnCON
Crossbar
TRn
AD
EXENn
TnEX
Tn
(Port Pin)
0
8
1
Tn
0xFF
0
Crossbar
Reload
CP/RLn
C/Tn
TRn
EXENn
EXFn
TFn
Interrupt
SMBus
(Timer 4 Only)
23.2.4. Toggle Output Mode
Timer 2, 3, and 4 have the capability to toggle the state of their respective output port pins (T2, T3, or T4) to produce
a 50% duty cycle waveform output. The port pin state will change upon the overflow or underflow of the respective
timer (depending on whether the timer is counting up or down). The toggle frequency is determined by the clock
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 281
C8051F060/1/2/3
Advanced
Information
N
source of the timer and the values loaded into RCAPnH and RCAPnL. When counting DOWN, the auto-reload value
for the timer is 0xFFFF, and underflow will occur when the value in the timer matches the value stored in
RCAPnH:RCAPnL. When counting UP, the auto-reload value for the timer is RCAPnH:RCAPnL, and overflow will
occur when the value in the timer transitions from 0xFFFF to the reload value.
RM
AT
IO
To output a square wave, the timer is placed in reload mode (the Capture/Reload Select Bit in TMRnCN and the
Timer/Counter Select Bit in TMRnCN are cleared to ‘0’). The timer output is enabled by setting the Timer Output
Enable Bit in TMRnCF to ‘1’. The timer should be configured via the timer clock source and reload/underflow values
such that the timer overflow/underflows at 1/2 the desired output frequency. The port pin assigned by the crossbar as
the timer’s output pin should be configured as a digital output (see Section “17. PORT INPUT/OUTPUT” on
page 191). Setting the timer’s Run Bit (TRn) to ‘1’ will start the toggle of the pin. A Read/Write of the Timer’s Toggle Output State Bit (TMRnCF.2) is used to read the state of the toggle output, or to force a value of the output. This
is useful when it is desired to start the toggle of a pin in a known state, or to force the pin into a desired state when the
toggle mode is halted.
2
F sq = ----------------- ⋅ ( RCAPn )
F TCLK
AD
VA
NC
ED
If timer is configured to
count down:
2
F sq = ----------------- ⋅ ( 65535 – RCAPn )
F TCLK
IN
If timer is configured to
count up:
FO
Equation 23.1. Square Wave Frequency
Page 282
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 23.13. TMRnCN: Timer 2, 3, and 4 Control Registers
R/W
R/W
R/W
R/W
R/W
-
-
EXENn
TRn
C/Tn
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
SFR Address: TMR2CN: 0xC8; TMR3CN: 0xC8; TMR4CN: 0xC8
Bit
Addressable
RM
TFn: Timer 2, 3, and 4 Overflow/Underflow Flag.
Set by hardware when either the Timer overflows from 0xFFFF to 0x0000, underflows from the value
placed in RCAPnH:RCAPnL to 0XFFFF (in Auto-reload Mode), or underflows from 0x0000 to
0xFFFF (in Capture Mode). When the Timer interrupt is enabled, setting this bit causes the CPU to
vector to the Timer interrupt service routine. This bit is not automatically cleared by hardware and
must be cleared by software.
EXFn: Timer 2, 3, or 4 External Flag.
Set by hardware when either a capture or reload is caused by a high-to-low transition on the TnEX
input pin and EXENn is logic 1. When the Timer interrupt is enabled, setting this bit causes the CPU
to vector to the Timer Interrupt service routine. This bit is not automatically cleared by hardware and
must be cleared by software.
Reserved.
EXENn: Timer 2, 3, and 4 External Enable.
Enables high-to-low transitions on TnEX to trigger captures, reloads, and control the direction of the
timer/counter (up or down count). If DECEN = 1, TnEX will determine if the timer counts up or
down when in Auto-reload Mode. If EXENn = 1, TnEX should be configured as a digital input.
0: Transitions on the TnEX pin are ignored.
1: Transitions on the TnEX pin cause capture, reload, or control the direction of timer count (up or
down) as follows:
Capture Mode: ‘1’-to-’0’ Transition on TnEX pin causes RCAPnH:RCAPnL to capture timer value.
Auto-Reload Mode:
DCEN = 0: ‘1’-to-’0’ transition causes reload of timer and sets the EXFn Flag.
DCEN = 1: TnEX logic level controls direction of timer (up or down).
TRn: Timer 2, 3, and 4 Run Control.
This bit enables/disables the respective Timer.
0: Timer disabled.
1: Timer enabled and running/counting.
C/Tn: Counter/Timer Select.
0: Timer Function: Timer incremented by clock defined by TnM1:TnM0 (TMRnCF.4:TMRnCF.3).
1: Counter Function: Timer incremented by high-to-low transitions on external input pin.
CP/RLn: Capture/Reload Select.
This bit selects whether the Timer functions in capture or auto-reload mode.
0: Timer is in Auto-Reload Mode.
1: Timer is in Capture Mode.
Bit2:
Bit1:
AD
Bit0:
VA
NC
ED
IN
Bit5-4:
Bit3:
Bit0
FO
Bit6:
Reset Value
00000000
AT
SFR Page: TMR2CN: page 0; TMR3CN: page 1; TMR4CN: page 2
Bit7:
R/W
CP/RLn
N
R/W
EXFn
IO
R/W
TFn
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 283
C8051F060/1/2/3
Advanced
Information
Figure 23.14. TMRnCF: Timer 2, 3, and 4 Configuration Registers
R/W
R/W
R/W
R/W
Reset Value
DCEN
00000000
-
-
-
TnM1
TnM0
TOGn
TnOE
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
SFR Page TMR2CF: page 0; TMR3CF: page 1; TMR4CF: page 2
AT
AD
VA
NC
Bit0:
ED
IN
Bit1:
RM
Bit2:
Reserved.
TnM1 and TnM0: Timer Clock Mode Select Bits.
Bits used to select the Timer clock source. The sources can be the System Clock (SYSCLK),
SYSCLK divided by 2 or 12, or an external clock signal routed to Tn (port pin) divided by 8. Clock
source is selected as follows:
00: SYSCLK/12
01: SYSCLK
10: EXTERNAL CLOCK/8
11: SYSCLK/2
TOGn: Toggle output state bit.
When timer is used to toggle a port pin, this bit can be used to read the state of the output, or can be
written to in order to force the state of the output.
TnOE: Timer output enable bit.
This bit enables the timer to output a 50% duty cycle output to the timer’s assigned external port pin.
NOTE: A timer is configured for Square Wave Output as follows:
CP/RLn = 0
C/Tn
=1
TnOE = 1
Load RCAPnH:RCAPnL (See “Square Wave Frequency” on page 282.)
Configure Port Pin to output squarewave (See Section “17. PORT INPUT/OUTPUT” on page 191)
0: Output of toggle mode not available at Timers’s assigned port pin.
1: Output of toggle mode available at Timers’s assigned port pin.
DCEN: Decrement Enable Bit.
This bit enables the timer to count up or down as determined by the state of TnEX.
0: Timer will count up, regardless of the state of TnEX.
1: Timer will count up or down depending on the state of TnEX as follows:
if TnEX = 0, the timer counts DOWN
if TnEX = 1, the timer counts UP.
FO
Bit7-5:
Bit4-3:
Bit0
IO
SFR Address: TMR2CF: 0xC9; TMR3CF: 0xC9; TMR4CF: 0xC9
N
R/W
Page 284
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 23.15. RCAPnL: Timer 2, 3, and 4 Capture Register Low Byte
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
SFR Page: RCAP2L: page 0; RCAP3L: page 1; RCAP4L: page 2
00000000
Bit0
RCAP2, 3, and 4L: Timer 2, 3, and 4 Capture Register Low Byte.
The RCAP2, 3, and 4L register captures the low byte of Timer 2, 3, and 4 when Timer 2, 3, and 4 is
configured in capture mode. When Timer 2, 3, and 4 is configured in auto-reload mode, it holds the
low byte of the reload value.
RM
AT
Bits 7-0:
Reset Value
IO
SFR Address: RCAP2L: 0xCA; RCAP3L: 0xCA; RCAP4L: 0xCA
R/W
N
R/W
Figure 23.16. RCAPnH: Timer 2, 3, and 4 Capture Register High Byte
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
R/W
FO
R/W
Bit3
R/W
R/W
R/W
Bit2
Bit1
Bit0
Reset Value
00000000
SFR Address: RCAP2H: 0xCB; RCAP3H: 0xCB; RCAP4H: 0xCB
RCAP2, 3, and 4H: Timer 2, 3, and 4 Capture Register High Byte.
The RCAP2, 3, and 4H register captures the highballed of Timer 2, 3, and 4 when Timer 2, 3, and 4 is
configured in capture mode. When Timer 2, 3, and 4 is configured in auto-reload mode, it holds the
high byte of the reload value.
ED
Bits 7-0:
IN
SFR Page: RCAP2H: page 0; RCAP3H: page 1; RCAP4H: page 2
Figure 23.17. TMRnL: Timer 2, 3, and 4 Low Byte
Bit7
R/W
R/W
VA
NC
R/W
Bit6
Bit5
R/W
R/W
R/W
R/W
R/W
Reset Value
00000000
Bit4
Bit3
Bit2
Bit1
Bit0
SFR Address: TMR2L: 0xCC; TMR3L: 0xCC; TMR4L: 0xCC
SFR Page: TMR2L: page 0; TMR3L: page 1; TMR4L: page 2
TL2, 3, and 4: Timer 2, 3, and 4 Low Byte.
The TL2, 3, and 4 register contains the low byte of the 16-bit Timer 2, 3, and 4
AD
Bits 7-0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 285
C8051F060/1/2/3
Advanced
Information
Figure 23.18. TMRnH Timer 2, 3, and 4 High Byte
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
SFR Page: TMR2H: page 0; TMR3H: page 1; TMR4H: page 2
00000000
Bit0
TH2, 3, and 4: Timer 2, 3, and 4 High Byte.
The TH2, 3, and 4 register contains the high byte of the 16-bit Timer 2, 3, and 4
AD
VA
NC
ED
IN
FO
RM
AT
Bits 7-0:
Reset Value
IO
SFR Address: TMR2H: 0xCD; TMR3H: 0xCD; TMR4H: 0xCD
R/W
N
R/W
Page 286
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
24.
C8051F060/1/2/3
PROGRAMMABLE COUNTER ARRAY
AT
IO
N
The Programmable Counter Array (PCA0) provides enhanced timer functionality while requiring less CPU intervention than the standard 8051 counter/timers. PCA0 consists of a dedicated 16-bit counter/timer and six 16-bit capture/
compare modules. Each capture/compare module has its own associated I/O line (CEXn) which is routed through the
Crossbar to Port I/O when enabled (See Section “17.1. Ports 0 through 3 and the Priority Crossbar Decoder” on
page 193). The counter/timer is driven by a programmable timebase that can select between six inputs as its source:
system clock, system clock divided by four, system clock divided by twelve, the external oscillator clock source
divided by 8, Timer 0 overflow, or an external clock signal on the ECI line. Each capture/compare module may be
configured to operate independently in one of six modes: Edge-Triggered Capture, Software Timer, High-Speed Output, Frequency Output, 8-Bit PWM, or 16-Bit PWM (each is described in Section 24.2). The PCA is configured and
controlled through the system controller's Special Function Registers. The basic PCA block diagram is shown in
Figure 24.1.
RM
Figure 24.1. PCA Block Diagram
SYSCLK/12
ECI
PCA
CLOCK
MUX
FO
SYSCLK/4
Timer 0 Overflow
16-Bit Counter/Timer
SYSCLK
Capture/Compare
Module 1
Capture/Compare
Module 3
Capture/Compare
Module 4
Capture/Compare
Module 5
CEX5
CEX4
CEX3
AD
Capture/Compare
Module 2
CEX2
CEX1
CEX0
ECI
VA
NC
Capture/Compare
Module 0
ED
IN
External Clock/8
Crossbar
Port I/O
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 287
Advanced
Information
C8051F060/1/2/3
24.1. PCA Counter/Timer
IO
N
The 16-bit PCA counter/timer consists of two 8-bit SFRs: PCA0L and PCA0H. PCA0H is the high byte (MSB) of the
16-bit counter/timer and PCA0L is the low byte (LSB). Reading PCA0L automatically latches the value of PCA0H
into a “snapshot” register; the following PCA0H read accesses this “snapshot” register. Reading the PCA0L Register
first guarantees an accurate reading of the entire 16-bit PCA0 counter. Reading PCA0H or PCA0L does not disturb
the counter operation. The CPS2-CPS0 bits in the PCA0MD register select the timebase for the counter/timer as
shown in Table 24.1.
RM
AT
When the counter/timer overflows from 0xFFFF to 0x0000, the Counter Overflow Flag (CF) in PCA0MD is set to
logic 1 and an interrupt request is generated if CF interrupts are enabled. Setting the ECF bit in PCA0MD to logic 1
enables the CF flag to generate an interrupt request. The CF bit is not automatically cleared by hardware when the
CPU vectors to the interrupt service routine, and must be cleared by software (Note: PCA0 interrupts must be globally enabled before CF interrupts are recognized. PCA0 interrupts are globally enabled by setting the EA bit (IE.7)
and the EPCA0 bit in EIE1 to logic 1). Clearing the CIDL bit in the PCA0MD register allows the PCA to continue
normal operation while the CPU is in Idle mode.
Table 24.1. PCA Timebase Input Options
CPS0
0
1
0
1
0
1
0
1
Timebase
System clock divided by 12
System clock divided by 4
Timer 0 overflow
High-to-low transitions on ECI (max rate = system clock divided by 4)
System clock
External oscillator source divided by 8 (synchronized with system
clock)
FO
CPS1
0
0
1
1
0
IN
CPS2
0
0
0
0
1
VA
NC
IDLE
ED
Figure 24.2. PCA Counter/Timer Block Diagram
PCA0MD
C
P
S
2
CCE
PPC
SSF
1 0
AD
CWW
I D D
D T L
L E C
K
SYSCLK/12
SYSCLK/4
Timer 0 Overflow
ECI
SYSCLK
External Clock/8
Page 288
PCA0CN
CCC
FRC
F
5
CC
CC
F F
4 3
CC
CC
F F
2 1
C
C
F
0
To SFR Bus
PCA0L
read
Snapshot
Register
000
001
010
0
011
1
100
101
PCA0H
PCA0L
Overflow
To PCA Interrupt System
CF
To PCA Modules
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
24.2.
C8051F060/1/2/3
Capture/Compare Modules
IO
N
Each module can be configured to operate independently in one of six operation modes: Edge-triggered Capture,
Software Timer, High Speed Output, Frequency Output, 8-Bit Pulse Width Modulator, or 16-Bit Pulse Width Modulator. Each module has Special Function Registers (SFRs) associated with it in the CIP-51 system controller. These
registers are used to exchange data with a module and configure the module's mode of operation.
AT
Table 24.2 summarizes the bit settings in the PCA0CPMn registers used to select the PCA0 capture/compare module’s operating modes. Setting the ECCFn bit in a PCA0CPMn register enables the module's CCFn interrupt. Note:
PCA0 interrupts must be globally enabled before individual CCFn interrupts are recognized. PCA0 interrupts are globally enabled by setting the EA bit (IE.7) and the EPCA0 bit (EIE1.3) to logic 1. See Figure 24.3 for details on the
PCA interrupt configuration.
Table 24.2. PCA0CPM Register Settings for PCA Capture/Compare Modules
CAPP CAPN
MAT
TOG
X
1
0
0
0
X
X
0
1
0
0
X
X
1
1
0
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
0
1
0
1
0
1
0
1
0
1
0
X = Don’t Care
IN
X
X
X
0
1
FO
X
PWM ECCF Operation Mode
Capture triggered by positive edge on
0
X
CEXn
Capture triggered by negative edge on
0
X
CEXn
Capture triggered by transition on
0
X
CEXn
0
X
Software Timer
0
X
High Speed Output
1
X
Frequency Output
1
0
8-Bit Pulse Width Modulator
1
0
16-Bit Pulse Width Modulator
RM
PWM16 ECOM
(for n = 0 to 5)
PCA0CPMn
CMT P E
A A OWC
P TGMC
N n n n F
n
n
PCA Counter/
Timer Overflow
PCA0CN
CCC
FRC
F
5
C
C
F
4
C
C
F
3
C
C
F
2
C
C
F
1
PCA0MD
C
C
F
0
C
I
D
L
VA
NC
P EC
WCA
MOP
1 MP
6 n n
n
ED
Figure 24.3. PCA Interrupt Block Diagram
C
P
S
2
C
P
S
1
CE
PC
S F
0
0
1
ECCF0
PCA Module 0
0
1
EPCA0
(EIE.3)
EA
(IE.7)
0
0
1
1
Interrupt
Priority
Decoder
ECCF1
AD
PCA Module 1
0
1
ECCF2
0
PCA Module 2
1
ECCF3
0
PCA Module 3
1
ECCF4
0
PCA Module 4
1
ECCF5
0
PCA Module 5
1
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 289
C8051F060/1/2/3
Advanced
Information
24.2.1. Edge-triggered Capture Mode
IO
N
In this mode, a valid transition on the CEXn pin causes PCA0 to capture the value of the PCA0 counter/timer and
load it into the corresponding module's 16-bit capture/compare register (PCA0CPLn and PCA0CPHn). The CAPPn
and CAPNn bits in the PCA0CPMn register are used to select the type of transition that triggers the capture: low-tohigh transition (positive edge), high-to-low transition (negative edge), or either transition (positive or negative edge).
When a capture occurs, the Capture/Compare Flag (CCFn) in PCA0CN is set to logic 1 and an interrupt request is
generated if CCF interrupts are enabled. The CCFn bit is not automatically cleared by hardware when the CPU vectors to the interrupt service routine, and must be cleared by software.
AT
Figure 24.4. PCA Capture Mode Diagram
PCA Interrupt
PCA0CN
FO
RM
CCCCCCCC
FRCCCCCC
FF FFFF
5 4 3 2 1 0
0
Port I/O
Crossbar
(to CCFn)
PCA0CPMn
P ECCMT P E
WC A A AOWC
MOPP TGMC
1 MPN n n n F
6 n n n
n
n
1
CEXn
PCA0CPLn
PCA0CPHn
Capture
IN
0
1
PCA
Timebase
PCA0L
PCA0H
AD
VA
NC
ED
Note: The signal at CEXn must be high or low for at least 2 system clock cycles in order to be valid.
Page 290
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
24.2.2. Software Timer (Compare) Mode
IO
N
In Software Timer mode, the PCA0 counter/timer is compared to the module's 16-bit capture/compare register
(PCA0CPHn and PCA0CPLn). When a match occurs, the Capture/Compare Flag (CCFn) in PCA0CN is set to logic
1 and an interrupt request is generated if CCF interrupts are enabled. The CCFn bit is not automatically cleared by
hardware when the CPU vectors to the interrupt service routine, and must be cleared by software. Setting the ECOMn
and MATn bits in the PCA0CPMn register enables Software Timer mode.
Figure 24.5. PCA Software Timer Mode Diagram
Write to
PCA0CPLn
AT
0
ENB
Reset
Write to
PCA0CPHn
ENB
1
RM
PCA0CPMn
P ECCMT P E
WC A A AOWC
MOPP TGMC
1 MP N n n n F
6 n n n
n
n
0 0
0 0 x
Enable
IN
16-bit Comparator
PCA0L
Match
0
1
PCA0H
AD
VA
NC
ED
PCA
Timebase
PCA0CN
CCCCCCCC
FRCCCCCC
FFFFFF
5 4 3 2 1 0
PCA0CPHn
FO
x
PCA0CPLn
PCA
Interrupt
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 291
Advanced
Information
C8051F060/1/2/3
24.2.3. High Speed Output Mode
N
In High Speed Output mode, a module’s associated CEXn pin is toggled each time a match occurs between the PCA
Counter and the module's 16-bit capture/compare register (PCA0CPHn and PCA0CPLn) Setting the TOGn, MATn,
and ECOMn bits in the PCA0CPMn register enables the High-Speed Output mode.
Write to
PCA0CPLn
IO
Figure 24.6. PCA High Speed Output Mode Diagram
0
ENB
PCA0CPMn
1
x
0 0
0 x
ED
PCA0L
PCA0CN
Match
0
1
TOGn
Toggle
0 CEXn
1
Crossbar
Port I/O
PCA0H
AD
VA
NC
PCA
Timebase
16-bit Comparator
PCA
Interrupt
CCCCCCCC
FRCCCCCC
FFFFFF
5 4 3 2 1 0
PCA0CPHn
IN
PCA0CPLn
Enable
RM
P ECCMT P E
WC A A AOWC
MOPP TGMC
1 MP N n n n F
n
6 n n n
n
ENB
FO
Write to
PCA0CPHn
AT
Reset
Page 292
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
24.2.4. Frequency Output Mode
IO
Equation 24.1. Square Wave Frequency Output
N
Frequency Output Mode produces a programmable-frequency square wave on the module’s associated CEXn pin.
The capture/compare module high byte holds the number of PCA clocks to count before the output is toggled. The
frequency of the square wave is then defined by Equation 24.1.
AT
F PCA
Fsqr = ----------------------------------------2 × PCA0CPHn
RM
Where FPCA is the frequency of the clock selected by the CPS2-0 bits in the PCA mode register, PCA0MD. The
lower byte of the capture/compare module is compared to the PCA0 counter low byte; on a match, CEXn is toggled
and the offset held in the high byte is added to the matched value in PCA0CPLn. Frequency Output Mode is enabled
by setting the ECOMn, TOGn, and PWMn bits in the PCA0CPMn register.
Figure 24.7. PCA Frequency Output Mode
PCA0CPHn
Adder
Enable
IN
0 0 0 1
8-bit Adder
0
Enable
match
0 CEXn
1
Crossbar
Port I/O
PCA0L
AD
VA
NC
PCA Timebase
8-bit
Comparator
TOGn
Toggle
ED
0
PCA0CPLn
FO
PCA0CPMn
P ECCMT P E
WC A A AOWC
MOPP TGMC
1 MP N n n n F
6 n n n
n
n
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 293
C8051F060/1/2/3
Advanced
Information
24.2.5. 8-Bit Pulse Width Modulator Mode
AT
IO
N
Each module can be used independently to generate pulse width modulated (PWM) outputs on its associated CEXn
pin. The frequency of the output is dependent on the timebase for the PCA0 counter/timer. The duty cycle of the
PWM output signal is varied using the module's PCA0CPLn capture/compare register. When the value in the low
byte of the PCA0 counter/timer (PCA0L) is equal to the value in PCA0CPLn, the output on the CEXn pin will be
high. When the count value in PCA0L overflows, the CEXn output will be low (see Figure 24.8). Also, when the
counter/timer low byte (PCA0L) overflows from 0xFF to 0x00, PCA0CPLn is reloaded automatically with the value
stored in the counter/timer's high byte (PCA0H) without software intervention. Setting the ECOMn and PWMn bits
in the PCA0CPMn register enables 8-Bit Pulse Width Modulator mode. The duty cycle for 8-Bit PWM Mode is given
by Equation 24.2.
Equation 24.2. 8-Bit PWM Duty Cycle
RM
( 256 – PCA0CPHn )
DutyCycle = --------------------------------------------------256
FO
Figure 24.8. PCA 8-Bit PWM Mode Diagram
PCA0CPMn
P ECCMT P E
WC A A AOWC
MOPP TGMC
1 MPN n n n F
6 n n n
n
n
0 0 0 0
0
8-bit
Comparator
VA
NC
Enable
ED
0
PCA0CPLn
match
S
R
SET
CLR
Q
CEXn
Crossbar
Port I/O
Q
PCA0L
Overflow
AD
PCA Timebase
IN
PCA0CPHn
Page 294
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
24.2.6. 16-Bit Pulse Width Modulator Mode
IO
N
Each PCA0 module may also be operated in 16-Bit PWM mode. In this mode, the 16-bit capture/compare module
defines the number of PCA0 clocks for the low time of the PWM signal. When the PCA0 counter matches the module
contents, the output on CEXn is asserted high; when the counter overflows, CEXn is asserted low. To output a varying duty cycle, new value writes should be synchronized with PCA0 CCFn match interrupts. 16-Bit PWM Mode is
enabled by setting the ECOMn, PWMn, and PWM16n bits in the PCA0CPMn register. For a varying duty cycle,
CCFn should also be set to logic 1 to enable match interrupts. The duty cycle for 16-Bit PWM Mode is given by
Equation 24.3. 16-Bit PWM Duty Cycle
RM
AT
( 65536 – PCA0CPn )
DutyCycle = ----------------------------------------------------65536
Figure 24.9. PCA 16-Bit PWM Mode
PCA0CPMn
0 0 0 0
PCA0CPLn
0
Enable
PCA0H
match
S
R
SET
CLR
Q
CEXn
Crossbar
Port I/O
Q
PCA0L
Overflow
AD
VA
NC
ED
PCA Timebase
16-bit Comparator
IN
1
PCA0CPHn
FO
P ECCMT P E
WC A A A OWC
MOP P TGMC
1 MP N n n n F
6 n n n
n
n
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 295
C8051F060/1/2/3
Advanced
Information
24.3. Register Descriptions for PCA0
Figure 24.10. PCA0CN: PCA Control Register
R/W
R/W
R/W
R/W
R/W
CF
CR
CCF5
CCF4
CCF3
CCF2
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit4:
Bit3:
Bit2:
Bit1:
00000000
Bit0
AT
SFR Address: 0xD8
SFR Page: 0
RM
CF: PCA Counter/Timer Overflow Flag.
Set by hardware when the PCA0 Counter/Timer overflows from 0xFFFF to 0x0000. When the
Counter/Timer Overflow (CF) interrupt is enabled, setting this bit causes the CPU to vector to the CF
interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by
software.
CR: PCA0 Counter/Timer Run Control.
This bit enables/disables the PCA0 Counter/Timer.
0: PCA0 Counter/Timer disabled.
1: PCA0 Counter/Timer enabled.
CCF5: PCA0 Module 5 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
CCF4: PCA0 Module 4 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
CCF3: PCA0 Module 3 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
CCF2: PCA0 Module 2 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
CCF1: PCA0 Module 1 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
CCF0: PCA0 Module 0 Capture/Compare Flag.
This bit is set by hardware when a match or capture occurs. When the CCF interrupt is enabled, setting this bit causes the CPU to vector to the CCF interrupt service routine. This bit is not automatically cleared by hardware and must be cleared by software.
AD
Bit0:
CCF0
Bit1
FO
Bit5:
CCF1
IN
Bit6:
Reset Value
ED
Bit7:
R/W
IO
R/W
VA
NC
R/W
N
Following are detailed descriptions of the special function registers related to the operation of PCA0.
Page 296
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 24.11. PCA0MD: PCA0 Mode Register
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
ECF
00000000
CIDL
-
-
-
CPS2
CPS1
CPS0
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
AT
CPS0
0
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
1
RM
CPS1
0
0
1
Timebase
System clock divided by 12
System clock divided by 4
Timer 0 overflow
High-to-low transitions on ECI (max rate = system clock divided
by 4)
System clock
External clock divided by 8†
Reserved
Reserved
FO
CPS2
0
0
0
IN
Bits6-4:
Bits3-1:
CIDL: PCA0 Counter/Timer Idle Control.
Specifies PCA0 behavior when CPU is in Idle Mode.
0: PCA0 continues to function normally while the system controller is in Idle Mode.
1: PCA0 operation is suspended while the system controller is in Idle Mode.
UNUSED. Read = 000b, Write = don't care.
CPS2-CPS0: PCA0 Counter/Timer Pulse Select.
These bits select the timebase source for the PCA0 counter
ED
Bit7:
IO
SFR Address: 0xD9
SFR Page: 0
ECF: PCA Counter/Timer Overflow Interrupt Enable.
This bit sets the masking of the PCA0 Counter/Timer Overflow (CF) interrupt.
0: Disable the CF interrupt.
1: Enable a PCA0 Counter/Timer Overflow interrupt request when CF (PCA0CN.7) is set.
†Note:
External clock divided by 8 is synchronized with the system clock, and external clock must be less
than or equal to the system clock frequency to operate in this mode.
AD
VA
NC
Bit0:
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 297
Advanced
Information
C8051F060/1/2/3
Figure 24.12. PCA0CPMn: PCA0 Capture/Compare Mode Registers
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
PWM16n
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
EECFn
00000000
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
R/W
Bit0
IO
SFR Address: PCA0CPM0: 0xDA, PCA0CPM1: 0xDB, PCA0CPM2: 0xDC, PCA0CPM3: 0xDD, PCA0CPM4: 0xDE, PCA0CPM5: 0xDF
SFR Page: PCA0CPM0: page 0, PCA0CPM1: page 0, PCA0CPM2: page 0, PCA0CPM3: 0, PCA0CPM4: page 0, PCA0CPM5: page 0
Bit3:
Bit2:
AT
RM
AD
Bit1:
FO
Bit4:
IN
Bit5:
ED
Bit6:
PWM16n: 16-bit Pulse Width Modulation Enable.
This bit selects 16-bit mode when Pulse Width Modulation mode is enabled (PWMn = 1).
0: 8-bit PWM selected.
1: 16-bit PWM selected.
ECOMn: Comparator Function Enable.
This bit enables/disables the comparator function for PCA0 module n.
0: Disabled.
1: Enabled.
CAPPn: Capture Positive Function Enable.
This bit enables/disables the positive edge capture for PCA0 module n.
0: Disabled.
1: Enabled.
CAPNn: Capture Negative Function Enable.
This bit enables/disables the negative edge capture for PCA0 module n.
0: Disabled.
1: Enabled.
MATn: Match Function Enable.
This bit enables/disables the match function for PCA0 module n. When enabled, matches of the
PCA0 counter with a module's capture/compare register cause the CCFn bit in PCA0MD register to
be set to logic 1.
0: Disabled.
1: Enabled.
TOGn: Toggle Function Enable.
This bit enables/disables the toggle function for PCA0 module n. When enabled, matches of the
PCA0 counter with a module's capture/compare register cause the logic level on the CEXn pin to toggle. If the PWMn bit is also set to logic 1, the module operates in Frequency Output Mode.
0: Disabled.
1: Enabled.
PWMn: Pulse Width Modulation Mode Enable.
This bit enables/disables the PWM function for PCA0 module n. When enabled, a pulse width modulated signal is output on the CEXn pin. 8-bit PWM is used if PWM16n is logic 0; 16-bit mode is used
if PWM16n logic 1. If the TOGn bit is also set, the module operates in Frequency Output Mode.
0: Disabled.
1: Enabled.
ECCFn: Capture/Compare Flag Interrupt Enable.
This bit sets the masking of the Capture/Compare Flag (CCFn) interrupt.
0: Disable CCFn interrupts.
1: Enable a Capture/Compare Flag interrupt request when CCFn is set.
VA
NC
Bit7:
Bit0:
Page 298
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 24.13. PCA0L: PCA0 Counter/Timer Low Byte
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Reset Value
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
N
00000000
Bit0
PCA0L: PCA0 Counter/Timer Low Byte.
The PCA0L register holds the low byte (LSB) of the 16-bit PCA0 Counter/Timer.
AT
Bits 7-0:
IO
SFR Address: 0xF9
SFR Page: 0
Figure 24.14. PCA0H: PCA0 Counter/Timer High Byte
R/W
Bit5
Bit4
R/W
Bit3
R/W
Bit2
R/W
R/W
Reset Value
00000000
Bit1
Bit0
SFR Address: 0xFA
SFR Page: 0
PCA0H: PCA0 Counter/Timer High Byte.
The PCA0H register holds the high byte (MSB) of the 16-bit PCA0 Counter/Timer.
AD
VA
NC
ED
IN
Bits 7-0:
Bit6
R/W
RM
Bit7
R/W
FO
R/W
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 299
Advanced
Information
C8051F060/1/2/3
Figure 24.15. PCA0CPLn: PCA0 Capture Module Low Byte
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
R/W
N
R/W
Reset Value
00000000
Bit0
SFR Page:
IO
SFR Address: PCA0CPL0: 0xFB, PCA0CPL1: 0xFD, PCA0CPL2: 0xE9, PCA0CPL3: 0xEB, PCA0CPL4: 0xED, PCA0CPL5: 0xE1
PCA0CPL0: page 0, PCA0CPL1: page 0, PCA0CPL2: page 0, PCA0CPL3: page 0, PCA0CPL4: page 0, PCA0CPL5: page 0
PCA0CPLn: PCA0 Capture Module Low Byte.
The PCA0CPLn register holds the low byte (LSB) of the 16-bit capture module n.
FO
RM
Bits7-0:
AT
\
IN
Figure 24.16. PCA0CPHn: PCA0 Capture Module High Byte
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Bit7
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
Bit0
Reset Value
00000000
SFR Address: PCA0CPH0: 0xFC, PCA0CPH1: 0xFD, PCA0CPH2: 0xEA, PCA0CPH3: 0xEC, PCA0CPH4: 0xEE, PCA0CPH5: 0xE2
PCA0CPHn: PCA0 Capture Module High Byte.
The PCA0CPHn register holds the high byte (MSB) of the 16-bit capture module n.
AD
VA
NC
Bits7-0:
ED
SFR Page: PCA0CPH0: page 0, PCA0CPH1: page 0, PCA0CPH2: page 0, PCA0CPH3: page 0, PCA0CPH4: page 0, PCA0CPH5: page 0
Page 300
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
25.
C8051F060/1/2/3
JTAG (IEEE 1149.1)
IO
N
Each MCU has an on-chip JTAG interface and logic to support boundary scan for production and in-system testing,
Flash read/write operations, and non-intrusive in-circuit debug. The JTAG interface is fully compliant with the IEEE
1149.1 specification. Refer to this specification for detailed descriptions of the Test Interface and Boundary-Scan
Architecture. Access of the JTAG Instruction Register (IR) and Data Registers (DR) are as described in the Test
Access Port and Operation of the IEEE 1149.1 specification.
The JTAG interface is accessed via four dedicated pins on the MCU: TCK, TMS, TDI, and TDO.
AT
Through the 16-bit JTAG Instruction Register (IR), any of the eight instructions shown in Figure 25.1 can be commanded. There are three DR’s associated with JTAG Boundary-Scan, and four associated with Flash read/write operations on the MCU.
RM
Figure 25.1. IR: JTAG Instruction Register
Flash Control
0x0083
Flash Data
0x0084
Flash Address
0x0085
Flash Scale
IN
0x0082
AD
0x0002
Description
Selects the Boundary Data Register for control and observability of all device pins
Selects the Boundary Data Register for observability and presetting the scan-path
latches
Selects device ID Register
Selects Bypass Data Register
Selects FLASHCON Register to control how the interface logic responds to reads
and writes to the FLASHDAT Register
Selects FLASHDAT Register for reads and writes to the Flash memory
Selects FLASHADR Register which holds the address of all Flash read, write, and
erase operations
Selects FLASHSCL Register which controls the Flash one-shot timer and readalways enable
ED
0x0004
0xFFFF
Instruction
EXTEST
SAMPLE/
PRELOAD
IDCODE
BYPASS
VA
NC
IR Value
0x0000
0x0000
Bit0
FO
Bit15
Reset Value
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 301
C8051F060/1/2/3
25.1.
Advanced
Information
Boundary Scan
N
The DR in the Boundary Scan path is a 126-bit shift register for the C8051F060/2 and a 118-bit shift register for the
C8051F061/3. The Boundary DR provides control and observability of all the device pins as well as the SFR bus and
Weak Pullup feature via the EXTEST and SAMPLE commands.
IO
Table 25.1. Boundary Data Register Bit Definitions (C8051F060/2)
AD
VA
NC
ED
IN
FO
RM
AT
EXTEST provides access to both capture and update actions, while Sample only performs a capture.
Bit
Action
Target
0
Capture Reset Enable from MCU
Update
Reset Enable to /RST pin
1
Capture Reset Input from /RST pin
Update
Not used
2
Capture CAN RX Output Enable to pin
Update
CAN RX Output Enable to pin
3
Capture CAN RX Input from pin
Update
CAN RX Output to pin
4
Capture CAN TX Output Enable to pin
Update
CAN TX Output Enable to pin
5
Capture CAN TX Input from pin
Update
CAN TX Output to pin
6
Capture External Clock from XTAL1 pin
Update
Not used
7
Capture Weak Pullup Enable from MCU
Update
Weak Pullup Enable to Port Pins
8, 10, 12, 14, 16, 18, Capture P0.n output enable from MCU (e.g. Bit 8 = P0.0, Bit 10 = P0.1, etc.)
20, 22
Update
P0.n output enable to pin (e.g. Bit 8 = P0.0oe, Bit 10 = P0.1oe, etc.)
9, 11, 13, 15, 17, 19, Capture P0.n input from pin (e.g. Bit 9 = P0.0, Bit 11 = P0.1, etc.)
21, 23
Update
P0.n output to pin (e.g. Bit 9 = P0.0, Bit 11 = P0.1, etc.)
24, 26, 28, 30, 32, Capture P1.n output enable from MCU (follows P0.n numbering scheme)
34, 36, 38
Update
P1.n output enable to pin (follows P0.n numbering scheme)
25, 27, 29, 31, 33, Capture P1.n input from pin (follows P0.n numbering scheme)
35, 37, 39
Update
P1.n output to pin (follows P0.n numbering scheme)
40, 42, 44, 46, 48, Capture P2.n output enable from MCU (follows P0.n numbering scheme)
50, 52, 54
Update
P2.n output enable to pin (follows P0.n numbering scheme)
41, 43, 45, 47, 49, Capture P2.n input from pin (follows P0.n numbering scheme)
51, 53, 55
Update
P2.n output to pin (follows P0.n numbering scheme)
56, 58, 60, 62, 64, Capture P3.n output enable from MCU (follows P0.n numbering scheme)
66, 68, 70
Update
P3.n output enable to pin (follows P0.n numbering scheme)
57, 59, 61, 63, 65, Capture P3.n input from pin (follows P0.n numbering scheme)
67, 69, 71
Update
P3.n output to pin (follows P0.n numbering scheme)
72, 74, 76
Capture P4.5, P4.6, P4.7 (respectively) output enable from MCU
Update
P4.5, P4.6, P4.7 (respectively) output enable to pin
73, 75, 77
Capture P4.5, P4.6, P4.7 (respectively) input from pin
Update
P4.5, P4.6, P4.7 (respectively) output to pin
78, 80, 82, 84, 86, Capture P5.n output enable from MCU (follows P0.n numbering scheme)
88, 90, 92
Update
P5.n output enable to pin (follows P0.n numbering scheme)
79, 81, 83, 85, 87, Capture P5.n input from pin (follows P0.n numbering scheme)
89, 91, 93
Update
P5.n output to pin (follows P0.n numbering scheme)
Page 302
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 25.1. Boundary Data Register Bit Definitions (C8051F060/2)
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
EXTEST provides access to both capture and update actions, while Sample only performs a capture.
Bit
Action
Target
94, 96, 98, 100, 102, Capture P6.n output enable from MCU (follows P0.n numbering scheme)
104, 106, 108
Update
P6.n output enable to pin (follows P0.n numbering scheme)
95, 97, 99, 101, 103, Capture P6.n input from pin (follows P0.n numbering scheme)
105, 107, 109
Update
P6.n output to pin (follows P0.n numbering scheme)
110, 112, 114, 116, Capture P7.n output enable from MCU (follows P0.n numbering scheme)
118, 120, 122, 124 Update
P7.n output enable to pin (follows P0.n numbering scheme)
111, 113, 115, 117, Capture P7.n input from pin (follows P0.n numbering scheme)
119, 121, 123, 125 Update
P7.n output to pin (follows P0.n numbering scheme)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 303
C8051F060/1/2/3
Advanced
Information
Table 25.2. Boundary Data Register Bit Definitions (C8051F061/3)
AD
VA
NC
ED
IN
FO
RM
AT
IO
N
EXTEST provides access to both capture and update actions, while Sample only performs a capture.
Bit
Action
Target
0
Capture Not used
Update
Not used
1
Capture Not used
Update
Not used
2
Capture CAN RX Output Enable to pin
Update
CAN RX Output Enable to pin
3
Capture CAN RX Input from pin
Update
CAN RX Output to pin
4
Capture CAN TX Output Enable to pin
Update
CAN TX Output Enable to pin
5
Capture CAN TX Input from pin
Update
CAN TX Output to pin
6
Capture External Clock from XTAL1 pin
Update
Not used
7
Capture Weak Pullup Enable from MCU
Update
Weak Pullup Enable to Port Pins
8, 10, 12, 14, 16, 18, Capture P0.n output enable from MCU (e.g. Bit 8 = P0.0, Bit 10 = P0.1, etc.)
20, 22
Update
P0.n output enable to pin (e.g. Bit 8 = P0.0oe, Bit 10 = P0.1oe, etc.)
9, 11, 13, 15, 17, 19, Capture P0.n input from pin (e.g. Bit 9 = P0.0, Bit 11 = P0.1, etc.)
21, 23
Update
P0.n output to pin (e.g. Bit 9 = P0.0, Bit 11 = P0.1, etc.)
24, 26, 28, 30, 32, Capture P1.n output enable from MCU (follows P0.n numbering scheme)
34, 36, 38
Update
P1.n output enable to pin (follows P0.n numbering scheme)
25, 27, 29, 31, 33, Capture P1.n input from pin (follows P0.n numbering scheme)
35, 37, 39
Update
P1.n output to pin (follows P0.n numbering scheme)
40, 42, 44, 46, 48, Capture P2.n output enable from MCU (follows P0.n numbering scheme)
50, 52, 54
Update
P2.n output enable to pin (follows P0.n numbering scheme)
41, 43, 45, 47, 49, Capture P2.n input from pin (follows P0.n numbering scheme)
51, 53, 55
Update
P2.n output to pin (follows P0.n numbering scheme)
56, 58, 60, 62, 64, Capture P3.n output enable from MCU (follows P0.n numbering scheme)
66, 68, 70
Update
P3.n output enable to pin (follows P0.n numbering scheme)
57, 59, 61, 63, 65, Capture P3.n input from pin (follows P0.n numbering scheme)
67, 69, 71
Update
P3.n output to pin (follows P0.n numbering scheme)
72
Capture Reset Enable from MCU
Update
Reset Enable to /RST pin
73
Capture Reset Input from /RST pin
Update
Not used
74, 76, 78, 80, 82, 84 Capture P5.0, P5.1, P5.2, P5.3, P5.5, P5.7 (respectively) output enable from MCU†
Update
P5.0, P5.1, P5.2, P5.3, P5.5, P5.7 (respectively) output enable to pin†
75, 77, 79, 81, 83, 85 Capture P5.0, P5.1, P5.2, P5.3, P5.5, P5.7 (respectively) input from pin†
Update
P5.0, P5.1, P5.2, P5.3, P5.5, P5.7 (respectively) output to pin†
86, 88, 90, 92, 94, Capture P6.n output enable from MCU (follows P0.n numbering scheme)†
96, 98, 100
Update
P6.n output enable to pin (follows P0.n numbering scheme)†
Page 304
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Table 25.2. Boundary Data Register Bit Definitions (C8051F061/3)
AT
IO
N
EXTEST provides access to both capture and update actions, while Sample only performs a capture.
Bit
Action
Target
87, 89, 91, 93, 95, Capture P6.n input from pin (follows P0.n numbering scheme)†
97, 99, 101
Update
P6.n output to pin (follows P0.n numbering scheme)†
102, 104, 106, 108, Capture P7.n output enable from MCU (follows P0.n numbering scheme)†
110, 112, 114, 116 Update
P7.n output enable to pin (follows P0.n numbering scheme)†
103, 105, 107, 109, Capture P7.n input from pin (follows P0.n numbering scheme)†
111, 113, 115, 117 Update
P7.n output to pin (follows P0.n numbering scheme)†
† Not connected to pins in this device package.
25.1.1. EXTEST Instruction
RM
The EXTEST instruction is accessed via the IR. The Boundary DR provides control and observability of all the
device pins as well as the Weak Pullup feature. All inputs to on-chip logic are set to logic 1.
25.1.2. SAMPLE Instruction
FO
The SAMPLE instruction is accessed via the IR. The Boundary DR provides observability and presetting of the scanpath latches.
25.1.3. BYPASS Instruction
IN
The BYPASS instruction is accessed via the IR. It provides access to the standard JTAG Bypass data register.
25.1.4. IDCODE Instruction
The IDCODE instruction is accessed via the IR. It provides access to the 32-bit Device ID register.
Version
Part Number
Bit28 Bit27
VA
NC
Bit31
ED
Figure 25.2. DEVICEID: JTAG Device ID Register
Reset Value
Manufacturer ID
Bit12 Bit11
1
Bit1
0xn0006243
Bit0
Version = 0000b
Part Number = 0000 0000 0000 0110b (C8051F060/1/2/3)
AD
Manufacturer ID = 0010 0100 001b (Cygnal Integrated Products)
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 305
C8051F060/1/2/3
25.2.
Advanced
Information
Flash Programming Commands
17:0
IndOpCode
WriteData
AT
19:18
IO
N
The Flash memory can be programmed directly over the JTAG interface using the Flash Control, Flash Data, Flash
Address, and Flash Scale registers. These Indirect Data Registers are accessed via the JTAG Instruction Register.
Read and write operations on indirect data registers are performed by first setting the appropriate DR address in the
IR register. Each read or write is then initiated by writing the appropriate Indirect Operation Code (IndOpCode) to the
selected data register. Incoming commands to this register have the following format:
IndOpCode: These bit set the operation to perform according to the following table:
Operation
Poll
Read
Write
RM
IndOpCode
0x
10
11
FO
The Poll operation is used to check the Busy bit as described below. Although a Capture-DR is performed, no
Update-DR is allowed for the Poll operation. Since updates are disabled, polling can be accomplished by shifting in/
out a single bit.
IN
The Read operation initiates a read from the register addressed by the DRAddress. Reads can be initiated by shifting
only 2 bits into the indirect register. After the read operation is initiated, polling of the Busy bit must be performed to
determine when the operation is complete.
VA
NC
ED
The write operation initiates a write of WriteData to the register addressed by DRAddress. Registers of any width up
to 18 bits can be written. If the register to be written contains fewer than 18 bits, the data in WriteData should be leftjustified, i.e. its MSB should occupy bit 17 above. This allows shorter registers to be written in fewer JTAG clock
cycles. For example, an 8-bit register could be written by shifting only 10 bits. After a Write is initiated, the Busy bit
should be polled to determine when the next operation can be initiated. The contents of the Instruction Register
should not be altered while either a read or write operation is busy.
Outgoing data from the indirect Data Register has the following format:
19
0
18:1
0
ReadData
Busy
AD
The Busy bit indicates that the current operation is not complete. It goes high when an operation is initiated and
returns low when complete. Read and Write commands are ignored while Busy is high. In fact, if polling for Busy to
be low will be followed by another read or write operation, JTAG writes of the next operation can be made while
checking for Busy to be low. They will be ignored until Busy is read low, at which time the new operation will initiate. This bit is placed at bit 0 to allow polling by single-bit shifts. When waiting for a Read to complete and Busy is
0, the following 18 bits can be shifted out to obtain the resulting data. ReadData is always right-justified. This allows
registers shorter than 18 bits to be read using a reduced number of shifts. For example, the results from a byte-read
requires 9 bit shifts (Busy + 8 bits).
Page 306
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
C8051F060/1/2/3
Figure 25.3. FLASHCON: JTAG Flash Control Register
Reset Value
WRMD1
WRMD0
RDMD3
RDMD2
RDMD1
Bit6
Bit5
Bit4
Bit3
Bit2
Bit1
RDMD0
N
WRMD2
Bit7
00000000
Bit0
IO
WRMD3
WRMD3-0: Write Mode Select Bits.
The Write Mode Select Bits control how the interface logic responds to writes to the FLASHDAT
Register per the following values:
0000: A FLASHDAT write replaces the data in the FLASHDAT register, but is otherwise ignored.
0001: A FLASHDAT write initiates a write of FLASHDAT into the memory address by the
FLASHADR register. FLASHADR is incremented by one when complete.
0010: A FLASHDAT write initiates an erasure (sets all bytes to 0xFF) of the Flash page containing
the address in FLASHADR. The data written must be 0xA5 for the erase to occur.
FLASHADR is not affected. If FLASHADR = 0x7BFE - 0x7BFF, the entire user space will
be erased (i.e. entire Flash memory except for Reserved area 0x7C00 - 0x7FFF).
(All other values for WRMD3-0 are reserved.)
RDMD3-0: Read Mode Select Bits.
The Read Mode Select Bits control how the interface logic responds to reads to the FLASHDAT Register per the following values:
0000: A FLASHDAT read provides the data in the FLASHDAT register, but is otherwise ignored.
0001: A FLASHDAT read initiates a read of the byte addressed by the FLASHADR register if no
operation is currently active. This mode is used for block reads.
0010: A FLASHDAT read initiates a read of the byte addressed by FLASHADR only if no
operation is active and any data from a previous read has already been read from
FLASHDAT. This mode allows single bytes to be read (or the last byte of a block) without
initiating an extra read.
(All other values for RDMD3-0 are reserved.)
AD
VA
NC
ED
IN
Bits3-0:
FO
RM
Bits7-4:
AT
This register determines how the Flash interface logic will respond to reads and writes to the FLASHDAT
Register.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 307
C8051F060/1/2/3
Advanced
Information
Figure 25.5. FLASHADR: JTAG Flash Address Register
N
Reset Value
0x0000
Bit0
IO
Bit15
AT
This register holds the address for all JTAG Flash read, write, and erase operations. This register autoincrements
after each read or write, regardless of whether the operation succeeded or failed.
RM
Bits15-0: Flash Operation 16-bit Address.
FO
Figure 25.4. FLASHDAT: JTAG Flash Data Register
Bit0
IN
Bit9
Reset Value
0000000000
This register is used to read or write data to the Flash memory across the JTAG interface.
ED
AD
Bit0:
DATA7-0: Flash Data Byte.
FAIL: Flash Fail Bit.
0: Previous Flash memory operation was successful.
1: Previous Flash memory operation failed. Usually indicates the associated memory location
was locked.
BUSY: Flash Busy Bit.
0: Flash interface logic is not busy.
1: Flash interface logic is processing a request. Reads or writes while BUSY = 1 will not
initiate another operation
VA
NC
Bits9-2:
Bit1:
Page 308
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.
Advanced
Information
25.3.
C8051F060/1/2/3
Debug Support
IO
N
Each MCU has on-chip JTAG and debug logic that provides non-intrusive, full speed, in-circuit debug support using
the production part installed in the end application, via the four pin JTAG I/F. Cygnal's debug system supports inspection and modification of memory and registers, breakpoints, and single stepping. No additional target RAM, program
memory, or communications channels are required. All the digital and analog peripherals are functional and work
correctly (remain synchronized) while debugging. The Watchdog Timer (WDT) is disabled when the MCU is halted
during single stepping or at a breakpoint.
AD
VA
NC
ED
IN
FO
RM
AT
The C8051F060DK is a development kit with all the hardware and software necessary to develop application code
and perform in-circuit debug with each MCU in the C8051F06x family. Each kit includes an Integrated Development
Environment (IDE) which has a debugger and integrated 8051 assembler. The kit also includes an RS-232 to JTAG
interface module referred to as the Serial Adapter. There is also a target application board with a C8051F060
installed. RS-232 and JTAG cables and wall-mount power supply are also included.
© 2002 Cygnal Integrated Products, Inc. DS007-0.4-NOV02
Page 309
C8051F060/1/2/3
Advanced
Information
Disclaimers
N
Life support: These products are not designed for use in life support appliances or systems where malfunction of
these products can reasonably be expected to result in personal injury. Cygnal Integrated Products customers using or
selling these products for use in such applications do so at their own risk and agree to fully indemnify Cygnal Integrated Products for any damages resulting from such applications.
AT
IO
Right to make changes: Cygnal Integrated Products reserves the right to make changes, without notice, in the products, including circuits and/or software, described or contained herein in order to improve design and/or performance.
Cygnal Integrated Products assumes no responsibility or liability for the use of any of these products, conveys no
license or title under any patent, copyright, or mask work right to these products, and makes no representations or
warranties that these products are free from patent, copyright, or mask work infringement, unless otherwise specified.
IN
FO
RM
CYGNAL INTEGRATED PRODUCTS
4301 Westbank Drive
Suite B-100
Austin, TX 78746
www.cygnal.com
AD
VA
NC
ED
CIP-51 is a trademark of Cygnal Integrated Products, Inc.
MCS-51 and SMBus are trademarks of Intel Corporation.
SPI is a trademark of Motorola, Inc.
I2C is a trademark of Philips Semiconductor.
Page 310
DS007-0.4-NOV02 © 2002 Cygnal Integrated Products, Inc.