STC12C5410AD series MCU
STC12LE5410AD series MCU
Data Sheet
STC MCU Limited
Update date: 2011-7-15
STC MCU Limited.
1
CONTENTS
Chapter 1. Introduction ................................................................7
1.1
1.2
1.3
1.4
1.5
1.6
Features ................................................................................................. 7
Block diagram ....................................................................................... 8
Pin Configurations ................................................................................ 9
STC12C5410AD series Selection Table...............................................11
STC12C5410AD series Minimum Application System ...................... 12
STC12C5410AD series MCU Typical Application Circuit for ISP .... 13
1.6.1 STC12C5410AD series MCU (28 pin) Typical Application Circuit for ISP..... 13
1.6.2 STC12C5410AD series MCU (20 pin) Typical Application Circuit for ISP..... 15
1.6.3 STC12C5410AD series MCU (32 pin) Typical Application Circuit for ISP..... 17
1.7 Pin Descriptions .................................................................................. 18
1.8 Package Dimension Drawings............................................................. 20
1.9 STC12C5410AD series MCU naming rules ....................................... 26
1.10 Global Unique Identification Number (ID) ....................................... 27
Chapter 2. Clock, Power Management and Reset ...................30
2.1 Clock ................................................................................................... 30
2.1.1
2.1.2
2.1.3
2.1.4
On-Chip R/C Clock and External Crystal/Clcok are Optional in STC-ISP.exe 30
Divider for System Clock .................................................................................. 31
How to Know Internal RC Oscillator frequency(Internal clock frequency) ..... 32
Programmable Clock Output .............................................................................. 35
TC
S
CU
M
Li
ed
it
m
2.1.4.1 Timer 0 Programmable Clock-out on P1.0 ....................................................................... 36
2.1.4.2 Timer 1 Programmable Clock-out on P1.1 ....................................................................... 37
2.2 Power Management Modes ................................................................. 38
2.2.1 Slow Down Mode ............................................................................................... 39
2.2.2 Idle Mode ............................................................................................................ 40
2.2.3 Stop / Power Down (PD) Mode and Demo Program (C and ASM) ................... 41
2.3 RESET Sources ................................................................................... 47
2.3.1
2.3.2
2.3.3
2.3.4
2.3.5
2
RESET Pin .......................................................................................................... 47
Software RESET................................................................................................. 47
Power-On Reset (POR)....................................................................................... 48
MAX810 power-on-Reset delay ......................................................................... 48
Internal Low Voltage Detection Reset ................................................................ 48
2.3.6 Watch-Dog-Timer ............................................................................................... 52
2.3.7 Warm Boot and Cold Boot Reset ........................................................................ 56
Chapter 3. Memory Organization .............................................57
3.1 Program Memory ................................................................................ 57
3.2 Data Memory(SRAM) ......................................................................... 58
3.2.1 On-chip Scratch-Pad RAM ................................................................................. 58
3.2.2 Auxiliary RAM ................................................................................................... 61
3.3 Special Function Registers .................................................................. 64
3.3.1 Special Function Registers Address Map ........................................................... 64
3.3.2 Special Function Registers Bits Description ...................................................... 65
Chapter 4. Configurable I/O Ports of STC12C5410AD series 70
4.1 I/O Ports Configurations ..................................................................... 70
4.2 I/O ports Modes ................................................................................... 73
4.2.1
4.2.2
4.2.3
4.2.4
Quasi-bidirectional I/O ....................................................................................... 73
Push-pull Output ................................................................................................. 74
Input-only (High-Impedance)Mode.................................................................... 74
Open-drain Output .............................................................................................. 74
4.3 I/O port application notes .................................................................... 75
4.4 Typical transistor control circuit .......................................................... 75
4.5 Typical diode control circuit ................................................................ 75
4.6 3V/5V hybrid system ........................................................................... 76
4.7 How to make I/O port low after MCU reset ........................................ 77
4.8 I/O status while PWM outputing ......................................................... 77
4.9 I/O drive LED application circuit ........................................................ 78
4.10 I/O immediately drive LCD application circuit................................. 79
4.11 Using A/D Conversion to scan key application circuit...................... 80
TC
S
CU
M
L
ted
mi
i
Chapter 5. Instruction System ...................................................81
5.1 Addressing Modes ............................................................................... 81
5.2 Instruction Set Summary ..................................................................... 82
5.3 Instruction Definitions ......................................................................... 87
Chapter 6. Interrupt System ....................................................124
6.1 Interrupt Structure ............................................................................. 126
6.2 Interrupt Register ............................................................................... 128
6.3 Interrupt Priorities ............................................................................. 138
3
6.4
6.5
6.6
6.7
How Interrupts Are Handled ............................................................. 139
External Interrupts ............................................................................ 140
Response Time ................................................................................. 144
Demo Programs about Interrupts (C and ASM) ................................ 145
External Interrupt 0 (INT0 ) Demo Programs (C and ASM) ........................... 145
External Interrupt 1 (INT1 ) Demo Programs (C and ASM) ........................... 149
Programs of P3.4/T0 Interrupt(falling edge) used to wake up PD mode ......... 153
Programs of P3.5/T1 Interrupt(falling edge) used to wake up PD mode ......... 155
Program of P3.0/RxD Interrupt(falling edge) used to wake up PD mode ........ 157
Program of PCA Interrupt used to wake up Power Down mode ...................... 160
6.7.1
6.7.2
6.7.3
6.7.4
6.7.5
6.7.6
Chapter 7. Timer/Counter 0/1 .................................................164
7.1 Special Function Registers about Timer/Counter .............................. 164
7.2 Timer/Counter 0
Mode of Operation (Compatible with traditional 8051 MCU) ........ 168
7.2.1
7.2.2
7.2.3
7.2.4
Mode 0 (13-bit Timer/Counter) .....................................................................................168
Mode 1 (16-bit Timer/Counter) and Demo Programs (C and ASM) ............................. 169
Mode 2 (8-bit Auto-Reload Mode) and Demo Programs (C and ASM) ........................ 173
Mode 3 (Two 8-bit Timers/Couters) .............................................................................. 176
7.3 Timer/Counter 1 Mode of Operation ................................................. 177
7.3.1
Mode 0 (13-bit Timer/Counter) .....................................................................................177
7.3.2
Mode 1 (16-bit Timer/Counter) and Demo Programs (C and ASM) ............................. 178
7.3.3
Mode 2 (8-bit Auto-Reload Mode) and Demo Programs (C and ASM) ........................ 182
TC
S
CU
M
L
ted
mi
i
7.4 Programmable Clock Output and Demo Programs (C and ASM) .... 185
7.4.1 Timer 0 Programmable Clock-out on P1.0 and Demo Program(C and ASM) . 187
7.4.2 Timer 1 Programmable Clock-out on P1.1 and Demo Program(C and ASM) . 190
7.5 Application note for Timer in practice .............................................. 193
Chapter 8. UART with Enhanced Function ...........................194
8.1 Special Function Registers about UART........................................... 194
8.2 UART1 Operation Modes ................................................................. 198
8.2.1
8.2.2
8.2.3
8.2.4
Mode 0: 8-Bit Shift Register............................................................................. 198
Mode 1: 8-Bit UART with Variable Baud Rate ................................................ 200
Mode 2: 9-Bit UART with Fixed Baud Rate .................................................... 202
Mode 3: 9-Bit UART with Variable Baud Rate ................................................ 204
8.3 Frame Error Detection ....................................................................... 206
8.4 Multiprocessor Communications ...................................................... 206
8.5 Automatic Address Recognition ........................................................ 207
4
8.6 Buad Rates ......................................................................................... 209
8.7 Demo Programs about UART (C and ASM) ..................................... 210
Chapter 9. Analog to Digital Converter ..................................216
9.1
9.2
9.3
9.4
9.5
9.6
9.7
A/D Converter Structure .................................................................... 216
Registers for ADC ............................................................................. 218
Application Circuit of A/D Converter .............................................. 221
ADC Application Circuit for Key Scan ............................................. 222
A/D reference voltage source ............................................................ 223
Program using interrupts to demostrate A/D Conversion ................ 224
Program using polling to demostrate A/D Conversion .................... 230
Chapter 10. Programmable Counter Array(PCA) ................236
10.1 SFRs related with PCA.................................................................... 236
10.2 PCA/PWM Structure ....................................................................... 243
10.3 PCA Modules Operation Mode ...................................................... 245
10.3.1
10.3.2
10.3.3
10.3.4
PCA Capture Mode ......................................................................................... 245
16-bit Software Timer Mode .......................................................................... 246
High Speed Output Mode ............................................................................... 247
Pulse Width Modulator Mode (PWM mode).................................................. 248
10.4
10.5
10.6
10.7
10.8
10.9
Programs for PCA module extended external interrupt ................. 249
Demo Programs for PCA module acted as 16-bit Timer ................ 253
Programs for PCA module as 16-bit High Speed Output ............... 257
Demo Programs for PCA module as PWM Output (C and ASM) .. 261
Demo Program for PCA clock base on Timer 1 overflow rate....... 265
Using PWM achieve D/A Conversion function reference circuit ... 269
TC
S
CU
M
L
ted
mi
i
Chapter 11. Serial Peripheral Interface (SPI) ........................270
11.1 Special Function Registers related with SPI.................................... 270
11.2 SPI Structure .................................................................................... 273
11.3 SPI Data Communication ................................................................ 274
11.3.1 SPI Configuration ........................................................................................... 274
11.3.2 SPI Data Communication Modes ................................................................... 275
11.3.3 SPI Data Modes .............................................................................................. 277
11.4 SPI Function Demo Programs (Single Master — Single Slave) ..... 279
11.4.1 SPI Function Demo Programs using Interrupts (C and ASM)........................ 279
11.4.2 SPI Function Demo Programs using Polling (C and ASM)............................ 285
5