STC STC12C2052AD, STC12LE2052AD User Manual

STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
1
www.STCMCU.com
STC12C2052AD series MCU
Data Sheet
STC MCU Limited
www.STCMCU.com
Update date: 2011-7-15
STC MCU Limited
CONTENTS
Chapter 1. Introduction ................................................................7
1.1 Features ................................................................................................. 7
1.2 Block diagram ....................................................................................... 8
1.3 Pin Configurations ................................................................................ 9
1.4 STC12C2052AD series Selection Table.............................................. 10
1.5 STC12C2052AD series Minimum Application System .......................11
1.6 STC12C2052AD series MCU Typical Application Circuit for ISP .... 12
1.7 Pin Descriptions .................................................................................. 14
1.8 Package Dimension Drawings ............................................................. 16
1.9 STC12C2052AD series MCU naming rules ....................................... 18
1.10 Global Unique Identification Number (ID) ....................................... 19
Chapter 2. Clock, Power Management and Reset ...................22
2.1 Clock ................................................................................................... 22
2.1.1 On-Chip R/C Clock and External Crystal/Clcok are Optional in STC-ISP.exe 22
2.1.2 Divider for System Clock .................................................................................. 23
2.1.3 How to Know Internal RC Oscillator frequency(Internal clock frequency) .....24
2.1.4 Programmable Clock Output .............................................................................. 27
2.1.4.1 Timer 0 Programmable Clock-out on P1.0 ....................................................................... 28
2.1.4.2 Timer 1 Programmable Clock-out on P1.1 ....................................................................... 29
2.2 Power Management Modes ................................................................. 30
2.2.1 Slow Down Mode ............................................................................................... 31
2.2.2 Idle Mode ............................................................................................................ 32
2.2.3 Stop / Power Down (PD) Mode and Demo Program (C and ASM) ................... 33
2.3 RESET Sources ................................................................................... 39
2.3.1 RESET Pin .......................................................................................................... 39
2.3.2 Software RESET ................................................................................................. 39
2.3.3 Power-On Reset (POR) ....................................................................................... 40
2.3.4 MAX810 power-on-Reset delay ......................................................................... 40
2.3.5 Internal Low Voltage Detection Reset ................................................................ 41
2.3.6 Watch-Dog-Timer ............................................................................................... 44
2.3.7 Warm Boot and Cold Boot Reset ........................................................................ 48
STC MCU Limited
Chapter 3. Memory Organization .............................................49
3.1 Program Memory ................................................................................ 49
3.2 Data Memory(SRAM) ......................................................................... 50
3.3 Special Function Registers .................................................................. 53
3.3.1 Special Function Registers Address Map ........................................................... 53
3.3.2 Special Function Registers Bits Description ...................................................... 54
Chapter 4. Configurable I/O Ports of STC12C2052AD series 58
4.1 I/O Ports Configurations ..................................................................... 58
4.2 I/O ports Modes ................................................................................... 60
4.2.1 Quasi-bidirectional I/O ....................................................................................... 60
4.2.2 Push-pull Output ................................................................................................. 61
4.2.3 Input-only (High-Impedance) Mode................................................................... 61
4.2.4 Open-drain Output .............................................................................................. 61
4.3 I/O port application notes .................................................................... 62
4.4 Typical transistor control circuit .......................................................... 62
4.5 Typical diode control circuit ................................................................ 62
4.6 3V/5V hybrid system ........................................................................... 63
4.7 How to make I/O port low after MCU reset ........................................ 64
4.8 I/O status while PWM outputing ......................................................... 64
4.9 I/O drive LED application circuit ........................................................ 65
4.10 I/O immediately drive LCD application circuit................................. 66
4.11 Using A/D Conversion to scan key application circuit ...................... 67
Chapter 5. Instruction System ...................................................68
5.1 Addressing Modes ............................................................................... 68
5.2 Instruction Set Summary ..................................................................... 69
5.3 Instruction Definitions ......................................................................... 74
Chapter 6. Interrupt System .................................................... 111
6.1 Interrupt Structure ..............................................................................113
6.2 Interrupt Register ................................................................................115
6.3 Interrupt Priorities ............................................................................. 125
6.4 How Interrupts Are Handled ............................................................. 126
6.5 External Interrupts ............................................................................ 127
6.6 Response Time ................................................................................. 131
STC MCU Limited
6.7 Demo Programs about Interrupts (C and ASM) ................................ 132
6.7.1 External Interrupt 0 (
INT0
) Demo Programs (C and ASM) ........................... 132
6.7.2 External Interrupt 1 (
INT1
) Demo Programs (C and ASM) ........................... 136
6.7.3 Programs of P3.4/T0 Interrupt(falling edge) used to wake up PD mode .........140
6.7.4 Programs of P3.5/T1 Interrupt(falling edge) used to wake up PD mode .........142
6.7.5 Program of P3.0/RxD Interrupt(falling edge) used to wake up PD mode ........ 144
6.7.6 Program of PCA Interrupt used to wake up Power Down mode ...................... 147
Chapter 7. Timer/Counter 0/1 .................................................151
7.1 Special Function Registers about Timer/Counter .............................. 151
7.2 Timer/Counter 0
Mode of Operation (Compatible with traditional 8051 MCU) ........155
7.2.1
Mode 0 (13-bit Timer/Counter) ..................................................................................... 155
7.2.2
Mode 1 (16-bit Timer/Counter) and Demo Programs (C and ASM) ............................. 156
7.2.3
Mode 2 (8-bit Auto-Reload Mode) and Demo Programs (C and ASM) ........................160
7.2.4
Mode 3 (Two 8-bit Timers/Couters) .............................................................................. 163
7.3 Timer/Counter 1 Mode of Operation ................................................. 164
7.3.1
Mode 0 (13-bit Timer/Counter) ..................................................................................... 164
7.3.2
Mode 1 (16-bit Timer/Counter) and Demo Programs (C and ASM) ............................. 165
7.3.3
Mode 2 (8-bit Auto-Reload Mode) and Demo Programs (C and ASM) ........................169
7.4 Programmable Clock Output and Demo Programs (C and ASM) .... 172
7.4.1 Timer 0 Programmable Clock-out on P1.0 and Demo Program(C and ASM) . 174
7.4.2 Timer 1 Programmable Clock-out on P1.1 and Demo Program(C and ASM) . 177
7.5 Application note for Timer in practice .............................................. 180
Chapter 8. UART with Enhanced Function ...........................181
8.1 Special Function Registers about UART ........................................... 181
8.2 UART Operation Modes ................................................................... 185
8.2.1 Mode 0: 8-Bit Shift Register............................................................................. 185
8.2.2 Mode 1: 8-Bit UART with Variable Baud Rate ................................................ 187
8.2.3 Mode 2: 9-Bit UART with Fixed Baud Rate .................................................... 189
8.2.4 Mode 3: 9-Bit UART with Variable Baud Rate ................................................ 191
8.3 Frame Error Detection ....................................................................... 193
8.4 Multiprocessor Communications ...................................................... 193
8.5 Automatic Address Recognition ........................................................ 194
8.6 Buad Rates ......................................................................................... 196
8.7 Demo Programs about UART (C and ASM) ..................................... 197
STC MCU Limited
Chapter 9. Analog to Digital Converter ..................................203
9.1 A/D Converter Structure .................................................................... 203
9.2 Registers for ADC ............................................................................. 205
9.3 Application Circuit of A/D Converter .............................................. 208
9.4 ADC Application Circuit for Key Scan ............................................. 209
9.5 A/D reference voltage source ............................................................ 210
9.6 Program using interrupts to demostrate A/D Conversion .................211
9.7 Program using polling to demostrate A/D Conversion .................... 217
Chapter 10. Programmable Counter Array(PCA) ................223
10.1 SFRs related with PCA .................................................................... 223
10.2 PCA/PWM Structure ....................................................................... 228
10.3 PCA Modules Operation Mode ...................................................... 230
10.3.1 PCA Capture Mode ......................................................................................... 230
10.3.2 16-bit Software Timer Mode .......................................................................... 231
10.3.3 High Speed Output Mode ............................................................................... 232
10.3.4 Pulse Width Modulator Mode (PWM mode)..................................................233
10.4 Programs for PCA module extended external interrupt ................. 234
10.5 Demo Programs for PCA module acted as 16-bit Timer ................ 238
10.6 Programs for PCA module as 16-bit High Speed Output ................ 242
10.7 Demo Programs for PCA module as PWM Output ........................ 246
10.8 Demo Program for PCA clock base on Timer 1 overflow rate....... 250
10.9 Using PWM achieve D/A Conversion function reference circuit ... 254
Chapter 11. Serial Peripheral Interface (SPI) ........................255
11.1 Special Function Registers related with SPI .................................... 255
11.2 SPI Structure .................................................................................... 258
11.3 SPI Data Communication ................................................................ 259
11.3.1 SPI Configuration ........................................................................................... 259
11.3.2 SPI Data Communication Modes ................................................................... 260
11.3.3 SPI Data Modes .............................................................................................. 262
11.4 SPI Function Demo Programs (Single Master — Single Slave) ..... 264
11.4.1 SPI Function Demo Programs using Interrupts (C and ASM) ........................ 264
11.4.2 SPI Function Demo Programs using Polling (C and ASM) ............................ 270
11.5 SPI Function Demo Programs (Each other as the Master-Slave) .... 276
11.5.1 SPI Function Demo Programs using Interrupts (C and ASM) ........................ 276
11.5.2 SPI Function Demo Programs using Polling .................................................. 282
Chapter 12. IAP / EEPROM ....................................................288
12.1 IAP / EEPROM Special Function Registers.................................... 289
12.2 STC12C2052AD series Internal EEPROM Allocation Table ......... 292
12.3 IAP/EEPROM Assembly Language Program Introduction ............ 293
12.4 EEPROM Demo Program (C and ASM) ......................................... 296
Chapter 13. STC12 series Development/Programming Tool 304
13.1 In-System-Programming (ISP) principle ......................................... 304
13.2 STC12C2052AD series Typical Application Circuit for ISP .......... 305
13.3 PC side application usage ................................................................ 307
13.4 Compiler / Assembler Programmer and Emulator .......................... 309
13.5 Self-Defined ISP download Demo ................................................. 309
Appendix A: Assembly Language Programming ...................313
Appendix B: 8051 C Programming .........................................335
Appendix C:
STC12C2052AD series Electrical Characteristics
..............................................................................345
Appendix D: Program for indirect addressing inner 256B RAM
..............................................................................347
Appendix E: Using Serial port expand I/O interface ............348
Appendix F:
Use STC MCU common I/O driving LCD Display
..............................................................................350
Appendix G: LED driven by an I/O port and Key Scan ........357
Appendix H: How to reduce the Length of Code through Keil C
..............................................................................358
Appendix I: Notes of STC12C2052AD series Application ....359
Appendix J: Notes of STC12 series Replaced Traditional 8051 .
..............................................................................360
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
7
www.STCMCU.com

1.1 Features

Enhanced 8051 Central Processing Unit ,1T per machine cycle, faster 8~12 times than the rate of a standard
8051.
Operating voltage range: 5.5V ~ 3.5V or 2.2V ~ 3.6V (STC12LE2052AD).
Operating frequency range: 0- 35MHz, is equivalent to standard 8051:0~420MHz
On-chip 1K/2K/3K/4K/5K... FLASH program memory with flexible ISP/IAP capability
On-chip 256 byte RAM
Power control: idle mode(can be waked up by any interrupt) and power-down mode(can be waked up by external interrupts). Code protection for flash memory access
Excellent noise immunity, very low power consumption
Four 16-bit timer/counter, be compatible with Timer0/Timer1 of standard 8051, 2-channel PCA can be
available as two timers.
9 vector-address, 4 level priority interrupt capability
One enhanced UART with hardware address-recognition and frame-error detection function
One 15 bits Watch-Dog-Timer with 8-bit pre-scaler (one-time-enabled)
SPI Master/Slave communication interface
Two channel Programmable Counter Array (PCA)
8-bit, 8-channel high-speed Analog-to-Digital Converter (ADC), up to 100 thousands times per second
Simple internal RC oscillator and external crystal clock
Three power management modes: idle mode, slow down mode and power-down mode
Power down mode can be woken-up by P3.2/INT0, P3.3/INT1, P3.4/T0, P3.5/T1, P3.0/RxD, P3.7/PCA0, and P3.5/PCA1 Operation Temperature: -40 ~ + 85℃ (industrial) / 0 ~ 75℃ (Commercial)
15 common programmable I/O ports are available
Programmable clock output Function. T0 output the clock on P1.0, T1 output the clock on P1.1. Five package type : SOP-20, DIP-20, LSSOP-20.

Chapter 1. Introduction

STC12C2052AD is a single-chip microcontroller based on a high performance 1T architecture 8051 CPU, which is produced by STC MCU Limited. With the enhanced kernel, STC12C2052AD executes instructions in 1~6 clock cycles (about 8~12 times the rate of a standard 8051 device), and has a fully compatible instruction set with industrial-standard 8051 series microcontroller. In-System-Programming (ISP) and In-Application-Programming (IAP) support the users to upgrade the program and data in system. ISP allows the user to download new code without removing the microcontroller from the actual end product; IAP means that the device can write non­valatile data in Flash memory while the application program is running. The STC12C2052AD retains all features of the standard 80C51. In addition, the STC12C2052AD has a 9-sources, 4-priority-level interrupt structure, 8-bit ADC (100 thousands times per second), on-chip crystal oscillator, MAX810 special reset circuit, 2-channel PCA and PWM, SPI, a one-time enabled Watchdog Timer and so on.
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412
Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
8
www.STCMCU.com

1.2 Block diagram

The CPU kernel of STC12C2052AD is fully compatible to the standard 8051 microcontroller, maintains all instruction mnemonics and binary compatibility. With some great architecture enhancements, STC12C2052AD executes the fastest instructions per clock cycle. Improvement of individual programs depends on the actual instructions used.
STC12C2052AD Block Diagram
RAM 256B
FLASH
Program Counter
PCA
(2-channel)
SPI
B Register
ACC
TMP2
TMP1
Stack
Pointer
ALU
PSW
WDT
Control
Unit
XTAL2XTAL1
RESET
ISP/IAP
Address
Generator
Timer 0/1
Enhanced
UART
LVD/LVR
Port 3 Latch
Port 3
Driver
P3
Port1 Latch
Port 1 Driver
P1.0 ~ P1.7
ADC
P1.0 ~ P1.7
8
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
9
www.STCMCU.com

1.3 Pin Configurations

All packages meet the European Union RoHS standards. LQFP-32 also conform to the Green standard.
Packages such as SOP-20 are strongly recommended though the traditional DIP packages are steady supplied.
20
19
18
17
16
15
14
13
12
11
1
2
3
4
5
6
7
8
9
10
VCC
P1.3/ADC3
RST
TxD/P3.1
XTAL2
XTAL1
Gnd
INT1/P3.3
INT0/P3.2
SOP-20 / DIP-20
P1.7/SCLK/ADC7
P1.6/MISO/ADC6
P1.5/MOSI/ADC5
P1.2/ADC2
P1.1/ADC1/CLKOUT1
P1.0/ADC0/CLKOUT0
P3.7/PCA0/PWM0
RxD/P3.0
ECI/T0/P3.4
PWM1/PCA1/T1/P3.5
20
19
18
17
16
15
14
13
12
11
1
2
3
4
5
6
7
8
9
10
VCC
P1.3
RST
TxD/P3.1
XTAL2
XTAL1
Gnd
INT1/P3.3
INT0/P3.2
SOP-20 / DIP-20
P1.7/SCLK
P1.6/MISO
P1.5/MOSI
P1.2
P1.1/CLKOUT1
P1.0/CLKOUT0
P3.7/PCA0/PWM0
RxD/P3.0
ECI/T0/P3.4
PWM/PCA1/T1/P3.5
P1.4/SS
P1.4/SS/ADC4
TSSOP-20
TSSOP-20
Super small package : TSSOP-20, 6.4mm×6.4mm
STC12C2052AD series (with A/D Converter),20-Pin
15 I/O ports
STC12C2052 series (without A/D Converter),20-Pin
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
10
www.STCMCU.com

1.4 STC12C2052AD series Selection Table

Type
1T 8051
MCU
Operation
Voltage
(V)
Flash
(Byte)
SRAM
(Byte)
Timer
T0&T1
PCA
Timer
Programmable
Clock Output
U A R T
EEP
ROM
16-bit PCA/
8-bit
PWM
D/A
A/D 8-ch
W D
T
Built-in
Reset
SPI
Package of 20-Pin
(15 I/O ports)
STC12C2052AD
series Selection Table
STC12C1052 5.5-3.5 1K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12C1052AD 5.5-3.5 1K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12C2052 5.5-3.5 2K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12C2052AD 5.5-3.5 2K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12C3052 5.5-3.5 3K 256 Y 2 Y Y IAP 2-ch Y Y Y SOP/LSSOP/DIP
STC12C3052AD 5.5-3.5 3K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12C4052 5.5-3.5 4K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12C4052AD 5.5-3.5 4K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12C5052 5.5-3.5 5K 256 Y 2 Y Y Y 2-ch Y Y Y Application program
can be modified in
application program
area (AP area)
STC12C5052AD 5.5-3.5 6K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y
STC12LE2052AD
series Selection Table
STC12LE1052 3.6-2.2 1K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12LE1052AD 3.6-2.2 1K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12LE2052 3.6-2.2 2K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12LE2052AD 3.6-2.2 2K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12LE3052 3.6-2.2 3K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12LE3052AD 3.6-2.2 3K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12LE4052 3.6-2.2 4K 256 Y 2 Y Y Y 2-ch Y Y Y SOP/LSSOP/DIP
STC12LE4052AD 3.6-2.2 4K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y SOP/LSSOP/DIP
STC12LE5052 3.6-2.2 5K 256 Y 2 Y Y Y 2-ch Y Y Y Application program
can be modified in
application program
area (AP area)
STC12LE5052AD 3.6-2.2 5K 256 Y 2 Y Y Y 2-ch 8-bit Y Y Y
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
11
www.STCMCU.com

1.5 STC12C2052AD series Minimum Application System

When the frequency of crystal oscillator is lower than 12MHz,
it is suggested not to use C1 and R1 replaced by 1K resistor connect to ground. But R/C reset circuit is also suggest to reserve.
About crystals circuit:
If using internal R/C oscillator clock (4MHz ~ 8MHz, manufacturing error), XTAL1 and XTAL2 pin should
be floated.
If External clock frequency is higher than 33MHz, it is recommended to directly use external active crystals
which clock are input from XTAL1 pin and XTAL2 pin must be floated.
System power/5V/3V
Vin
SW1
Power On


C6
C5
C2<33pF
C3<33pF
X1

10K
C1
+
+
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RST
P3.0/RxD
P3.1/TxD
XTAL2
XTAL1
P3.2/INT0
P3.3/INT1
P3.4/T0/ECI
P3.5/T1/PCA1/PWM1
Gnd
VCC
ADC7/SCLK/P1.7
ADC6/MISO/P1.6
ADC5/MOSI/P1.5
ADC4/SS/P1.4
ADC3/P1.3
ADC2/P1.2
CLKOUT1/ADC1/P1.1
CLKOUT0/ADC0/P1.0
PWM0/PCA0/P3.7
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
12
www.STCMCU.com

1.6 STC12C2052AD series MCU Typical Application Circuit for ISP

—— MCU should be connected to computer through RS-232 converter to download program
1
2
3
4
5
6
7
8
16
15
14
13
12
11
10
9
Vcc
Gnd
T1OUT
R1IN
R1OUT
T1IN
T2IN
R2OUT
C1+
V+
C1-
C2+
C2-
V-
T2OUT
R2IN
Reset U1-P1.0 U1-P1.1 MCU-VCC U1-P3.0 U1-P3.1 GND
USB+5V T1OUT R1IN
GND
USB1




Vcc
+
Vcc
Gnd
PC_RxD(COM Pin2)
PC_TxD(COM Pin3)
2 3
5
PC COM
MAX232,MAX3232,SP232,SP3232
Vcc
USB +5V
Vin
SW1
Power On

+

Download user proced­ure to STC MCU by the software STC-ISP programmer
This circuit has been made as a STC12C2052AD series microcontroller ISP download programming tool
1K
<33pF
<33pF
1K
+
C1
Vcc
R1
10K
Users are suggested hold this interface on the system , which can be convenient to download the users program online.
System Power
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RST
P3.0/RxD
P3.1/TxD
XTAL2
XTAL1
P3.2/INT0
P3.3/INT1
P3.4/T0/ECI
P3.5/T1/PCA1/PWM1
Gnd
VCC
ADC7/SCLK/P1.7
ADC6/MISO/P1.6
ADC5/MOSI/P1.5
ADC4/SS/P1.4
ADC3/P1.3
ADC2/P1.2
CLKOUT1/ADC1/P1.1
CLKOUT0/ADC0/P1.0
PWM0/PCA0/P3.7
20 Pin
If using internal R/C oscillator clock (4M Hz ~ 8MH z, manufacturing err or) , XTAL1 and XTAL2 pin should be floated.
If External clock frequency is higher than 33MHz, it is recommended to directly use external active c rystals which clock are input from XTAL1 pin and XTAL2 pin must be floated.
But R/C r eset circuit is also suggest to reserve.
When the frequency of crystal oscillator is lower than 12MHz, it is suggested not to use C1 and R1 replaced by 1K resistor connect to ground.
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
13
www.STCMCU.com
Users in their target system, such as the P3.0/P3.1 through the RS-232 level shifter connected to the computer after the conversion of ordinary RS-232 serial port to connect the system programming / upgrading client software. If the user panel recommended no RS-232 level converter, should lead to a socket, with Gnd/P3.1/ P3.0/Vcc four signal lines, so that the user system can be programmed directly. Of course, if the six signal lines can lead to Gnd/P3.1/P3.0/Vcc/P1.1/P1.0 as well, because you can download the program by P1.0/P1.1 ISP ban. If you can Gnd/P3.1/P3.0/Vcc/P1.1/P1.0/Reset seven signal lines leads to better, so you can easily use "offline download board (no computer)" .
ISP programming on the Theory and Application Guide to see "STC12C2052AD Series MCU Development / Programming Tools Help"section. In addition, we have standardized programming download tool, the user can then program into the goal in the above systems, you can borrow on top of it RS-232 level shifter connected to the computer to download the program used to do. Programming a chip roughly be a few seconds, faster than the ordinary universal programmer much faster, there is no need to buy expensive third-party programmer?. PC STC-ISP software downloaded from the website www.STCMCU.com
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
14
www.STCMCU.com

1.7 Pin Descriptions

MNEMONIC
Pin Number
Description
LQFP-32 SOP-32
SOP-28/
SKDIP-28
SOP-20/DIP-20/
TSSOP-20
P1.0/ADC0/CLKOUT0 16 20 18 12
P1.0 common I/O port PORT1[0]
ADC0
Analog to Digital Converter Input channel 0
CLKOUT0
Programmable clock output of Timer/ couter 0
P1.1/ADC1/CLKOUT1 17 21 19 13
P1.1 common I/O port PORT1[1]
ADC1
Analog to Digital Converter Input channel 1
CLKOUT1
rogrammable clock output of Timer/ counter 1
P1.2/ADC2 18 22 20 14
P1.2 common I/O port PORT1[2]
ADC2
Analog to Digital Converter Input channel 2
P1.3/ADC3 20 24 21 15
P1.3 common I/O port PORT1[3]
ADC3
Analog to Digital Converter Input channel 3
P1.4/ADC4/
SS
21 25 22 16
P1.4 common I/O port PORT1[4]
ADC4
Analog to Digital Converter Input channel 4
SS
slave-select signal of serial peripheral interface, which is active low.
P1.5/ADC5/MOSI 23 27 23 17
P1.5 common I/O port PORT1[5]
ADC5
Analog to Digital Converter Input channel 5
MOSI
Master Out, Slave In signal
P1.6/ADC6/MISO 24 28 24 18
P1.6 common I/O port PORT1[6]
ADC5
Analog to Digital Converter Input channel 6
MISO
Master In, Slave Out signal
P1.7/ADC7/SCLK 25 29 25 19
P1.7 common I/O port PORT1[7]
ADC7
Analog to Digital Converter Input channel 7
SCLK
The clock signal of serial peripheral interface
P3.0/RxD 32 4 4 2
P3.0 common I/O port PORT3[0]
RxD Serial recive port
P3.1/TxD 1 5 5 3
P3.1 common I/O port PORT3[1]
TxD Serial transmit port
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
15
www.STCMCU.com
MNEMONIC
Pin Number
Description
LQFP-32 SOP-32
SOP-28/
SKDIP-28
SOP-20/DIP-20/
TSSOP-20
P3.2/
INT0
5 9 8 6
P3.2 common I/O port PORT3[2]
INT0
External interrupt 0
P3.3/
INT1
7 11 9 7
P3.3 common I/O port PORT3[3]
INT1
External interrupt 1
P3.4/T0/ECI 8 12 10 8
P3.4 common I/O port PORT3[4]
T0 Timer/counter 0 input
ECI PCA count input
P3.5/T1/PCA1/PWM1 9 13 11 9
P3.5 common I/O port PORT3[5]
T1 Timer/counter 1 input
PCA1 PCA module 1 Capture input
PWM1 PWM module 1 output
P3.7/PCA0/PWM0 15 19 17 11
P3.7 common I/O port PORT3[7]
PCA0 PCA module 0 Capture input
PWM0 PWM module 0 output
RST 31 3 3 1
Reset input
XTAL1 4 8 7 5
Input to the inverting oscillator amplifier. Receives the external oscillator sign al when an external oscillator is used.
XTAL2 3 7 6 4
Output from the inverting amplifier. This pin should be floated when an external oscillator is used.
VCC 28 32 28 20 Power
Gnd 12 16 14 10 circuit ground potential
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
16
www.STCMCU.com
20-Pin Small Outline Package (SOP-20)
Dimensions in Inches and (Millimeters)
D (12.7mm)
A1
A2
A
b
e
COMMON DIMENSIONS
(UNITS OF MEASURE = MILLMETER)
SYMBOL MIN NOM MAX
A 2.465 2.515 2.565
A1 0.100 0.150 0.200
A2 2.100 2.300 2.500
b1 0.366 0.426 0.486
b 0.356 0.406 0.456
c 0.234 - 0.274
c1 0.224 0.254 0.274
D 12.500 12.700 12.900
E 10.206 10.306 10.406
E1 7.450 7.500 7.550
e 1.270
L 0.800 0.864 0.900
L1 1.303 1.403 1.503
L2 - 0.274 -
R - 0.300 -
R1 - 0.200 -
0
0
- 10
0
z - 0.660 -
b
b1
c1c
WITH PLATING
BASE METAL
L
L1
L2
R
R1
E1
E
z
1.27mm

1.8 Package Dimension Drawings

STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
17
www.STCMCU.com
D (1026mil)
E1
A
L
e
E
eA
COMMON DIMENSIONS
(UNITS OF MEASURE = INCH)
SYMBOL MIN NOM MAX
A - - 0.175
A1 0.015 - -
A2 0.125 0.13 0.135
b 0.016 0.018 0.020
b1 0.058 0.060 0.064
C 0.008 0.010 0.11
D 1.012 1.026 1.040
E 0.290 0.300 0.310
E1 0.245 0.250 0.255
e 0.090 0.100 0.110
L 0.120 0.130 0.140
0
0 - 15
eA 0.355 0.355 0.375
S - - 0.075
UNIT: INCH 1 inch = 1000 mil
b1
b
A1
20-Pin Plastic Dual Inline Package (DIP-20)
Dimensions in Inches
0.120
0
A2
C
S
100mil
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
18
www.STCMCU.com

1.9 STC12C2052AD series MCU naming rules

STC12 xx xx
52 xx -- 35 x - xxxx xx
Pin Number e.g. 20
Package type e.g. SOP, DIP, TSSOP
Temperature range I : Industrial, -40-85 C : Commercial, 0-70
Operating frequency 35 : Up to 35MHz
AD : Have ADC function, PWM and internal EEPROM No words: no ADC function, but have PWM and internal EEPROM
Program space 10:3KB 20:2KB 30:3KB 40:4KB 50:5KB
Operating Voltage C : 5.5V~3.3V LE : 2.2V~3.6V
STC 1T Series 8051 MCU Speed is 8~12 times the traditional 8051
256 Bytes RAM, 2 channels PCA/PWM
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
19
www.STCMCU.com

1.10 Global Unique Identification Number (ID)

STC 1T MCU 12C2052AD series, each MCU has a unique identification number (ID). User can use “MOV @Ri” instruction read RAM unit F1~F7 to get the ID number after power on. If users need to the unique identification number to encrypt their procedures, detecting the procedures not be illegally modified should be done first.
//The following example program written by C language is to read internal ID number
/*----------------------------------------------------------------------------------*/ /* --- STC MCU International Limited -------------------------------------*/ /* --- Mobile: 13922809991 ------------------------------------------------ */ /* --- Fax: 0755-82905966 ------------------------------------------------- */ /* --- Tel: 0755-82948409 -------------------------------------------------- */ /* --- Web: www.STCMCU.com --------------------------------------------*/ /* If you want to use the program or the program referenced in the --*/ /* article, please specify in which data and procedures from STC --*/ /*---------------------------------------------------------------------------------*/ #include<reg51.h> #include<intrins.h> sfr ISP_CONTR = 0xE7;
sbit MCU_Start_Led = P1^7; //unsigned char self_command_array[4] = {0x22,0x33,0x44,0x55}; #define Self_Define_ISP_Download_Command 0x22 #define RELOAD_COUNT 0xfb //18.432MHz,12T,SMOD=0,9600bps
void serial_port_initial(); void send_UART(unsigned char); void UART_Interrupt_Receive(void); void soft_reset_to_ISP_Monitor(void); void delay(void); void display_MCU_Start_Led(void);
void main(void) { unsigned char i = 0; unsigned char j = 0;
unsigned char idata *idata_point;
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
20
www.STCMCU.com
serial_port_initial(); //initialize serial port // display_MCU_Start_Led(); //MCU begin to run when LED is be lighted // send_UART(0x34); // send_UART(0xa7);
idata_point = 0xF1; for(j=0;j<=6; j++) { i = *idata_point; send_UART(i); idata_point++; }
while(1); }
void serial_port_initial() { SCON = 0x50; //0101,0000 8-bit variable baud rate,No parity TMOD = 0x21; //0011,0001 Timer1 as 8-bit auto-reload Timer TH1 = RELOAD_COUNT; //Set the auto-reload parameter TL1 = RELOAD_COUNT; TR1 = 1; ES = 1; EA = 1; }
void send_UART(unsigned char i) { ES = 0; TI = 0; SBUF = i; while(TI ==0); TI = 0; ES = 1; }
void UART_Interrupt_Receive(void) interrupt 4 { unsigned char k = 0; if(RI==1) { RI = 0; k = SBUF;
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
21
www.STCMCU.com
if(k==Self_Define_ISP_Download_Command) //Self-define download command { delay(); //just delay 1 second delay(); soft_reset_to_ISP_Monitor(); //Soft rese to ISP Monitor } send_UART(k); } else { TI = 0; } }
void soft_reset_to_ISP_Monitor(void) { ISP_CONTR = 0x60; //0110,0000 Soft rese to ISP Monitor }
void delay(void) { unsigned int j = 0; unsigned int g = 0; for(j=0;j<5;j++) { for(g=0;g<60000;g++) { _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } } }
void display_MCU_Start_Led(void) { unsigned char i = 0; for(i=0;i<3;i++) { MCU_Start_Led = 0; delay(); MCU_Start_Led = 1; delay(); MCU_Start_Led = 0; } }
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
22
www.STCMCU.com

Chapter 2. Clock, Power Management and Reset

2.1 Clock

STC12C2052AD series is STC 1T MCU whose system clock is compatible with traditional 8051 MCU.
There are two clock sources available for STC12C2052AD. One is the clock from crystal oscillator and the other is from internal simple RC oscillator. The internal built-in RC oscillator can be used to replace the external crystal oscillator in the application which doesn't need an exact system clock. On-chip R/C clock is selected first in STC-ISP Writer/Programmer because the manufacturer's selection is on-chip R/C clock.
To enable the external crystal oscillator, user should enable the option "External Crystal/Clock" by STC-ISP Writer/Programmer.

2.1.1 On-Chip R/C Clock and External Crystal/Clcok are Optional in STC-ISP.exe

STC12C2052AD
07FF
After next-power up/ cold reset MCU clock can be:
1. On-Chip R/C Clock
2. External Crystal/Clock
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
23
www.STCMCU.com

2.1.2 Divider for System Clock

A clock divider(CLK_DIV) is designed to slow down the operation speed of STC12C2052AD, to save the operating power dynamically.
User can slow down the MCU by means of writing a non-zero value to the CLKS[2:0] bits in the CLK_DIV register. This feature is especially useful to save power consumption in idle mode as long as the user changes the CLKS[2:0] to a non-zero value before entering the idle mode.
CLK_DIV register (Clock Divider)
SFR Name SFR Address bit B7 B6 B5 B4 B3 B2 B1 B0
CLK_DIV C7H name - - - - - CLKS2 CLKS1 CLKS0
B2-B0 (CLKS2-CLKS0) : 000 External crystal/clock or On-Chip R/C clock is not divided (default state) 001 External crystal/clock or On-Chip R/C clock is divided by 2. 010 External crystal/clock or On-Chip R/C clock is divided by 4. 011 External crystal/clock or On-Chip R/C clock is divided by 8. 100 External crystal/clock or On-Chip R/C clock is divided by 16. 101 External crystal/clock or On-Chip R/C clock is divided by 32. 110 External crystal/clock or On-Chip R/C clock is divided by 64. 111 External crystal/clock or On-Chip R/C clock is divided by 128.
Not-divided
÷2
÷4
÷8
÷16
÷32
÷64
÷128
CLKS2,CLKS1,CLKS0
000
001
010
011
100
101
110
111
System Clock
(To CPU and peripherals)
Clock Structure
On-Chip R/C Clock External crystal/clock
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
24
www.STCMCU.com

2.1.3 How to Know Internal RC Oscillator frequency(Internal clock frequency)

STC 1T MCU 12C2052AD series in addition to traditional external clock, but also the option of using the internal RC oscillator clock source. If select internal RC oscillator, external crystal can be saved. XTAL1 and XTAL2 floating. Relatively large errors due to internal clock, so high requirements on the timing or circumstances have serial communication is not recommended to use the internal oscillator. User can use “MOV @Ri” instruction read RAM unit FC~FF to get the internal oscillator frequency of the factory and read RAM unit F8~FB to get internal oscillator frequency of last used to download programs within the internal oscillator after power on.
//The following example program written by C language is to read internal R/C clock frequency
/*----------------------------------------------------------------------------------*/ /* --- STC MCU International Limited -------------------------------------*/ /* --- Mobile: 13922809991 ------------------------------------------------ */ /* --- Fax: 0755-82905966 ------------------------------------------------- */ /* --- Tel: 0755-82948409 -------------------------------------------------- */ /* --- Web: www.STCMCU.com --------------------------------------------*/ /* If you want to use the program or the program referenced in the --*/ /* article, please specify in which data and procedures from STC --*/ /*---------------------------------------------------------------------------------*/ #include<reg51.h> #include<intrins.h> sfr ISP_CONTR = 0xE7;
sbit MCU_Start_Led = P1^7; //unsigned char self_command_array[4] = {0x22,0x33,0x44,0x55}; #define Self_Define_ISP_Download_Command 0x22 #define RELOAD_COUNT 0xfb //18.432MHz,12T,SMOD=0,9600bps
void serial_port_initial(); void send_UART(unsigned char); void UART_Interrupt_Receive(void); void soft_reset_to_ISP_Monitor(void); void delay(void); void display_MCU_Start_Led(void);
void main(void) { unsigned char i = 0; unsigned char j = 0;
unsigned char idata *idata_point;
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
25
www.STCMCU.com
serial_port_initial(); //initialize serial port // display_MCU_Start_Led(); //MCU begin to run when LED is be lighted // send_UART(0x34); // send_UART(0xa7);
idata_point = 0xFC; for(j=0;j<=3;j++) { i = *idata_point; send_UART(i); idata_point++; }
while(1); }
void serial_port_initial() { SCON = 0x50; //0101,0000 8-bit variable baud rate,No parity TMOD = 0x21; //0011,0001 Timer1 as 8-bit auto-reload Timer TH1 = RELOAD_COUNT; //Set the auto-reload parameter TL1 = RELOAD_COUNT; TR1 = 1; ES = 1; EA = 1; }
void send_UART(unsigned char i) { ES = 0; TI = 0; SBUF = i; while(TI ==0); TI = 0; ES = 1; }
void UART_Interrupt_Receive(void) interrupt 4 { unsigned char k = 0; if(RI==1) { RI = 0; k = SBUF;
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
26
www.STCMCU.com
if(k==Self_Define_ISP_Download_Command) //Self-define download command { delay(); //just delay 1 second delay(); soft_reset_to_ISP_Monitor(); //Soft rese to ISP Monitor } send_UART(k); } else { TI = 0; } }
void soft_reset_to_ISP_Monitor(void) { ISP_CONTR = 0x60; //0110,0000 Soft rese to ISP Monitor }
void delay(void) { unsigned int j = 0; unsigned int g = 0; for(j=0;j<5;j++) { for(g=0;g<60000;g++) { _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); } } }
void display_MCU_Start_Led(void) { unsigned char i = 0; for(i=0;i<3;i++) { MCU_Start_Led = 0; delay(); MCU_Start_Led = 1; delay(); MCU_Start_Led = 0; } }
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
27
www.STCMCU.com

2.1.4 Programmable Clock Output

STC12C2052AD series MCU have two channel programmable clock outputs, they are Timer 0 programmable clock output CLKOUT0(P1.0) and Timer 1 programmable clock output CLKOUT1(P1.1).
There are some SFRs about programmable clock output as shown below.
The satement (used in C language) of Special function registers AUXR/WAKE_CLKO:
sfr AUXR = 0x8E; //The address statement of
Special function register AUXR
sfr WAKE_CLKO = 0x8F; //The address statement of
SFR WAKE_CLKO
The satement (used in Assembly language) of Special function registers AUXR/WAKE_CLKO:
AUXR EQU 0x8E ;The address statement of
Special function register AUXR
WAKE_CLKO EQU 0x8F ;The address statement of
SFR WAKE_CLKO
Symbol Description Address Bit Address and Symbol
MSB LSB
Value after
Power-on or
Reset
AUXR Auxiliary register 8EH
T0x12 T1x12 UART_M0x6 EADCI ESPI ELVDI - -
0000 00xxB
WAKE_CLKO
CLK_Output
Power down
Wake-up control
register
8FH
PCAWAKEUP RXD_PIN_IE T1_PIN_IE T0_PIN_IE - - T1CLKO T0CLKO
0000 xx00B
1. AUXR: Auxiliary register (Non bit-addressable)
SFR name Address bit B7 B6 B5 B4 B3 B2 B1 B0
AUXR 8EH name T0x12 T1x12 UART_M0x6 EADCI ESPI ELVDI - -
T0x12 : Timer 0 clock source bit. 0 : The clock source of Timer 0 is SYSclk/12. It will compatible to the traditional 80C51 MCU 1 : The clock source of Timer 0 is SYSclk/1. It will drive the T0 faster than a traditional 80C51 MCU
T1x12 : Timer 1 clock source bit. 0 : The clock source of Timer 1 is SYSclk/12. It will compatible to the traditional 80C51 MCU 1 : The clock source of Timer 1 is SYSclk/1. It will drive the T0 faster than a traditional 80C51 MCU
UART_M0x6 : Baud rate select bit of UART1 while it is working under Mode-0 0 : The baud-rate of UART in mode 0 is SYSclk/12. 1 : The baud-rate of UART in mode 0 is SYSclk/2.
UART_M0x6 : Baud rate select bit of UART1 while it is working under Mode-0 0 : The baud-rate of UART in mode 0 is SYSclk/12. 1 : The baud-rate of UART in mode 0 is SYSclk/2.
EADCI : Enable/Disable interrupt from A/D converter 0 : (default) Inhibit the ADC functional block to generate interrupt to the MCU 1 : Enable the ADC functional block to generate interrupt to the MCU
ESPI : Enable/Disable interrupt from Serial Peripheral Interface (SPI) 0 : (default)Inhibit the SPI functional block to generate interrupt to the MCU 1 : Enable the SPI functional block to generate interrupt to the MCU
ELVDI : Enable/Disable interrupt from low-voltage sensor 0 : (default)Inhibit the low-voltage sensor functional block to generate interrupt to the MCU 1 : Enable the low-voltage sensor functional block to generate interrupt to the MCU
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
28
www.STCMCU.com
T1_PIN_IE : When set and the associated-Timer1 interrupt control registers is configured correctly, the T1 pin
(P3.5) is enabled to wake up MCU from power-down state.
T0_PIN_IE : When set and the associated-Timer0 interrupt control registers is configured correctly, the T1 pin
(P3.4) is enabled to wake up MCU from power-down state.
T1CKLO : When set, P1.1 is enabled to be the clock output of Timer 1. The clock rate is Timer 1overflow rate
divided by 2.
T0CKLO : When set, P1.0 is enabled to be the clock output of Timer 0. The clock rate is Timer 0overflow rate
divided by 2.
2.1.4.1 Timer 0 Programmable Clock-out on P1.0
Timer/Counter 0 Mode 2: 8-Bit Auto-Reload
SYSclk
control
C/T=0
C/T=1
T0 Pin
TR0
GATE
INT0
AUXR.7/T0x12=0
AUXR.7/T0x12=1
TL0
(8 Bits)
TH0
(8 Bits)
÷12
÷1
Interrupt
TF0
Toggle
T0CLKO
P1.0
CLKOUT0
STC12C2052AD is able to generate a programmable clock output on P1.0. When T0CLKO/ WAKE_CLKO.0 bit in
WAKE_CLKO SFR
is set, T0 timer overflow pulse will toggle P1.0 latch to generate a 50% duty clock. The frequency of clock-out = T0 overflow rate/2. If
C/T
(TMOD.2) = 0, Timer/Counter 0 is set for Timer operation (input from internal system clock),
the
Frequency of clock-out is as following :
(SYSclk) / (256 – TH0) / 2, when AUXR.7 / T0x12=1
or (SYSclk / 12) / (256 – TH0) / 2 , when AUXR.7 / T0x12=0
If
C/T
(TMOD.2) = 1, Timer/Counter 0 is set for Conter operation (input from external P3.4/T0 pin),
the Frequency of clock-out is as following : T0_Pin_CLK / (256-TH0) / 2
2. WAKE_CLKO: CLK_Output Power down Wake-up control register (Non bit-Addressable)
SFR name
Address bit B7 B6 B5 B4 B3 B2 B1 B0
WAKE_CLKO 8FH name
PCAWAKEUP RXD_PIN_IE T1_PIN_IE T0_PIN_IE - - T1CLKO T0CLKO
PCAWAKEUP: When set and the associated-PCA interrupt control registers is configured correctly, the CEXn pin
of PCA function is enabled to wake up MCU from power-down state.
RXD_PIN_IE: When set and the associated-UART interrupt control registers is configured correctly, the RXD
pin (P3.0) is enabled to wake up MCU from power-down state.
STC MCU Limited.
Mobile:(86)13922809991 Tel:86-755-82948412 Fax:86-755-82905966
STC MCU Limited.
website:www.STCMCU.com
29
www.STCMCU.com
2.1.4.2 Timer 1 Programmable Clock-out on P1.1
STC12C2052AD is able to generate a programmable clock output on P1.1. When T1CLKO/WAKE_CLKO.1 bit in WAKE_CLKO SFR is set, T1 timer overflow pulse will toggle P1.1 latch to generate a 50% duty clock. The frequency of clock-out = T1 overflow rate/2.
If
C/T
(TMOD.6) = 0, Timer/Counter 1 is set for Timer operation (input from internal system clock),
the Frequency of clock-out is as following :
(SYSclk) / (256 – TH1) / 2, when AUXR.6 / T0x12=1
or (SYSclk / 12) / (256 – TH1) / 2 , when AUXR.6 / T0x12=0
If
C/T
(TMOD.6) = 1, Timer/Counter 1 is set for Conter operation (input from external P3.5/T1 pin),
the Frequency of clock-out is as following : T1_Pin_CLK / (256-TH1) / 2
Timer/Counter 1 Mode 2: 8-Bit Auto-Reload
Interrupt
SYSclk
TF1
control
C/T=0 C/T=1
T1 Pin
TR1
GATE
INT1
AUXR.6/T1x12=0
AUXR.6/T1x12=1
TL1
(8 Bits)
TH1
(8 Bits)
÷12
÷1
Toggle
T1CLKO
P1.1
CLKOUT1
STC MCU Limited.
Mobile:(86)13922809991 Tel:086-755-82948412 Fax:86-755-82905966
STC MCU Limited. website:www.STCMCU.com
30
www.STCMCU.com

2.2 Power Management Modes

PCON register (Power Control Register)
SFR name Address bit B7 B6 B5 B4 B3 B2 B1 B0
PCON 87H name SMOD SMOD0 LVDF POF GF1 GF0 PD IDL
SMOD : Double baud rate of UART interface 0 Keep normal baud rate when the UART is used in mode 1,2 or 3. 1 Double baud rate bit when the UART is used in mode 1,2 or 3. SMOD0 : SM0/FE bit select for SCON.7; setting this bit will set SCON.7 as Frame Error function. Clearing it to set SCON.7 as one bit of UART mode selection bits. LVDF : Pin Low-Voltage Flag. Once low voltage condition is detected (VCC power is lower than LVD voltage), it is set by hardware (and should be cleared by software). POF : Power-On flag. It is set by power-off-on action and can only cleared by software. Practical application: if it is wanted to know which reset the MCU is used, see the following figure.
In initializtion program,
judge whether POF/PCON.4
have been set or not
POF=1,
Yes
cold boot
Power-On Reset
Clear POF/PCON.4
POF=0, No
external manual reset
or WDT reset
or software reset
or others
The STC12C2052AD core has three software programmable power management mode: slow-down, idle
and stop/power-down mode. The power
consumption of
STC12C2052AD series is about 2.7mA~7mA in
normal operation, while it is lower than 0.1uA in stop/power-down mode and 1.8mA in idle mode.
Slow-down mode is controlled by clock divider register(CLK_DIV). Idle and stop/power-down is managed
by the corresponding bit in Power control (PCON) register which is shown in below.
GF1,GF0: General-purposed flag 1 and 0 PD :
Stop Mode/
Power-Down
Select
bit.
.
Setting this bit will place the STC12C2052AD MCU in Stop/Power-Down mode. Stop/Power-Down mode can be waked up by external interrupt. Because the MCU’ s internal oscillator stopped in Stop/ Power-Down mode, CPU, Timers, UARTs and so on stop to run, only external interrupt go on to work.
The following pins can wake up MCU from
Stop/Power-Down mode:
INT0
/P3.2,
INT1
/P3.3, T0/P3.4,
T1/P3.5, RxD/P3.0, PCA0/PWM0/P3.7, PCA1/PWM1/P3.5, PCA2/PWM2/P2.0, PCA3/PWM3/P2.4.
IDL : Idle mode select bit. Setting this bit will place the STC12C2052AD in Idle mode. only CPU goes into Idle mode. (Shuts off clock to CPU, but clock to Timers, Interrupts, Serial Ports, and Analog Peripherals are still active.) The following pins
can wake up MCU from
Idle mode:
INT0/P3.2, INT1/P3.3, T0/P3.4, T1/P3.5, RxD/P3.0. Besides, Timer0 and
Timer1 and UARTs interrupt also can wake up MCU from idle mode
Loading...
+ 330 hidden pages