STC — the global first brand of 8051 MCU, the biggest design company of 8051 MCU in the world
www.STCMCU.com
www.GXWMCU.com
STC15W4K32S4 series MCU
.
TC
S
ed
it
Data Sheet
im
L
CU
M
Website : www.STCMCU.com www.GXWMCU.com
Update Date: 2015/2/6
STC15W4K32S4 series MCU Manual
Temporary Technical Adviser : (86)13922829991
Tel of R&D: (86)13922805190
QQ of R&D: 800003751
CONTENTS
Chapter 1 General Overview of STC15W4K32S4 series ..............12
1.1 Introduction of STC15W4K32S4 series MCU ................................. 12
1.2 Block diagram of STC15W4K32S4 series MCU ............................. 15
1.3 Pin Configurations of STC15W4K32S4 series MCU ...................... 16
1.4 STC15W4K32S4 series Selection and Price Table .......................... 21
.
1.5 Naming rules of STC15W4K32S4 series MCU ............................... 22
1.6 Application Circuit Diagram for ISP of STC15W4K series .............. 23
1.6.1 Application Circuit Diagram for ISP using RS-232 Converter ................... 23
1.6.2 Application Circuit Diagram for ISP using USB to convert Serial Port ..... 24
1.6.3 Application Circuit Diagram for ISP directly using USB port .................... 25
——P3.0/P3.1 of STC15W4K series and IAP15W4K58S4 connect directly with D-/D+ of USB ......25
1.7 Pin Descriptions of STC15W4K32S4 series MCU .......................... 26
1.8 Package Dimension Drawings of STC15 series MCU ..................... 33
1.8.1 Dimension Drawings of DFN8 .................................................................... 33
.
1.8.2 Dimension Drawings of SOP8 ..................................................................... 34
1.8.3 Dimension Drawings of DIP8 ...................................................................... 35
1.8.4 Dimension Drawings of SOP16 ................................................................... 36
1.8.5 Dimension Drawings of DIP16 .................................................................... 37
1.8.6 Dimension Drawings of SOP20 ................................................................... 38
1.8.7 Dimension Drawings of TSSOP20 .............................................................. 39
.
1.8.8 Dimension Drawings of LSSOP20 .............................................................. 40
.
1.8.9 Dimension Drawings of DIP20 .................................................................... 41
1.8.10 Dimension Drawings of SOP28 ................................................................. 42
1.8.11 Dimension Drawings of TSSOP28 ............................................................. 43
1.8.12 Dimension Drawings of SKDIP28 ............................................................. 44
1.8.13 Dimension Drawings of QFN28 ................................................................ 45
.
1.8.14 Dimension Drawings of LQFP32 ............................................................... 46
1.8.15 Dimension Drawings of SOP32 ................................................................. 47
1.8.16 Dimension Drawings of QFN32 ................................................................ 48
.
1.8.17 Dimension Drawings of PDIP40 ................................................................ 49
1.8.18 Dimension Drawings of LQFP44 ............................................................... 50
1.8.19 Dimension Drawings of PLCC44 .............................................................. 51
.
TC
S
CU
M
Li
ed
it
m
1.9 Special Peripheral Function(CCP/SPI,UART1/2/3/4) Switch ........... 58
1.9.1 Test Porgram that Switch CCP/PWM/PCA (C and ASM) .......................... 60
1.9.2 Test Porgram that Switch PWM2/3/4/5/PWMFLT (C and ASM) ............... 62
1.9.3 Test Porgram that Switch PWM6/PWM7 (C and ASM) .............................. 64
1.9.4 Test Porgram that Switch SPI (C and ASM) ............................................... 66
1.9.5 Test Porgram that Switch UART1 (C and ASM) ........................................ 68
1.9.6 Test Porgram that Switch UART2 (C and ASM) ........................................ 70
1.9.7 Test Porgram that Switch UART3 (C and ASM) ........................................ 72
1.9.8 Test Porgram that Switch UART4 (C and ASM) ........................................ 74
1.8.20 Dimension Drawings of PQFP44 ............................................................... 52
1.8.21 Dimension Drawings of LQFP48 ............................................................... 53
1.8.22 Dimension Drawings of QFN48 ................................................................ 54
.
1.8.23 Dimension Drawings of LQFP64S ............................................................ 55
.
1.8.24 Dimension Drawings of LQFP64L............................................................. 56
1.8.25 Dimension Drawings of QFN64 ................................................................ 57
.
Chapter 2 Clock, Reset and Power Management ..........................81
.
1.10 Global Unique Identification Number (ID) .................................... 76
2.1 Clock ................................................................................................. 81
2.1.1 On-Chip Configurable Clock ...................................................................... 81
2.1.2 Divider for System Clock ............................................................................ 82
2.1.3 Programmable Clock Output (or as Frequency Divider) ............................ 83
2.1.3.1 Special Function Registers Related to Programmable Clock Output ..................83
2.1.3.2 Master Clock Output and Demo Program(C and ASM) ......................................88
2.1.3.3 Timer 0 Programmable Clock Output and Demo Program(C and ASM) ............91
2.1.3.4 Timer 1 Programmable Clock Output and Demo Program(C and ASM) ............95
2.1.3.5 Timer 2 Programmable Clock Output and Demo Program (C and ASM) ...........99
2.1.3.6 Timer 3 Programmable Clock Output and Demo Program (C and ASM) .........103
2.1.3.7 Timer 4 Programmable Clock Output and Demo Program (C and ASM) .........104
TC
S
CU
M
L
ted
mi
i
2.2 RESET Sources ............................................................................... 105
2.2.1 External RST pin Reset ............................................................................. 105
2.2.2 Software Reset and Demo Program (C and ASM) .................................... 106
2.2.3 Power-Off / Power-On Reset (POR) ......................................................... 109
2.2.4 MAX810 Speical Circuit Reset (Power-Off/ Power-On Reset Delay) ..... 109
2.2.5 Internal Low Voltage Detection Reset ....................................................... 110
2.2.6 Watch-Dog-Timer Reset ............................................................................ 113
2.2.7 Reset Caused by Program Accessing an Invalid Address ......................... 117
2.2.8 Warm Boot and Cold Boot Reset .............................................................. 118
2.3 Power Management Modes .............................................................119
.
2.3.1 Slow Down Mode and Demo Program (C and ASM) ............................... 120
2.3.2 Idle Mode and Demo Program (C and ASM) ........................................... 123
.
2.2.3 Stop / Power Down (PD) Mode and Demo Program (C and ASM) ......... 125
.
Chapter 3 Memory Organization and SFRs .................................151
2.3.3.1 Demo Program Using Power-Down Wake-Up Timer to Wake Up Stop/PD Mode ....127
2.3.3.2 Demo Program Using External Interrupt INT0 to Wake Up Stop/PD Mode .....129
2.3.3.3 Demo Program Using External Interrupt INT1 to Wake Up Stop/PD Mode .....131
2.3.3.4 Demo Program Using External Interrupt INT2 to Wake Up Stop/PD Mode.....133
2.3.3.5 Demo Program Using External Interrupt INT3 to Wake Up Stop/PD Mode.....135
2.3.3.6 Demo Program Using External Interrupt INT4 to Wake Up Stop/PD Mode.....137
2.3.3.7 Program Using External Interrupt Extended by CCP/PCA to Wake Up PD Mode .139
.
2.3.3.8 Program Using the Level Change of RxD pin to Wake Up Stop/PD Mode.......143
2.3.3.9 Program Using the Level Change of RxD2 pin to Wake Up Stop/PD Mode.....147
3.1 Program Memory ............................................................................ 151
3.2 Data Memory (SRAM) ................................................................... 152
3.2.1 On-chip Scratch-Pad RAM ....................................................................... 152
3.2.2 On-Chip Expanded RAM / XRAM /AUX-RAM ..................................... 154
.
3.2.3 External Expandable 64KB RAM (Off-Chip RAM) ................................ 160
.
3.3.1 Special Function Registers Address Map .................................................. 163
3.3.2 Special Function Registers Bits Description ............................................. 164
3.3.3 Dual Data Pointer Register (DPTR) .......................................................... 170
3.3 Special Function Registers ............................................................. 163
.
Chapter 4 Configurable I/O Ports of STC15 series MCU ...........171
4.1 I/O Ports Configurations ................................................................. 171
4.2 Special Explanation of P1.7/XTAL1 and P1.6/XTAL2 pin ............ 174
4.3 Special Explanation of RST pin ...................................................... 174
4.4 Special Explanation of RSTOUT_LOW pin .................................. 174
4.5 SFRs related to I/O ports and Its Address Statement ...................... 175
4.6 Demo Program of STC15 series P0/P1/P2/P3/P4/P5 ..................... 179
4.7 I/O ports Modes .............................................................................. 185
4.7.1 Quasi-Bidirectional I/O ............................................................................. 185
4.7.2 Push-Pull Output ....................................................................................... 185
4.7.3 Input-Only (High-Impedance)Mode ......................................................... 186
4.7.4 Open-Drain Output .................................................................................... 186
4.8 I/O Port Application Notes ............................................................. 186
.
4.9 Typical Transistor Control Circuit .................................................. 187
4.10 Typical Diode Control Circuit ...................................................... 187
.
4.11 How to Make I/O Port Low after MCU Reset .............................. 187
4.12 Keyboard Scanning Circuit using I/O ports .................................. 188
4.13 Pin Function and Logic Turth Table of 74HC595 ........................ 189
.
4.14 Circuit Expanding I/O ports using 74HC595 ............................... 190
.
4.15 Circuit Driving 8-segment Digitron using 74HC595 ................... 191
.
4.16 Demo Program of Driving 8-Segment Digitron ........................... 192
—— Using common I/O ports to Control 74HC595 .................... 192
4.17 Application Circuit using A/D Conversion to Scan Key ............. 199
4.18 Demo Program using I/O ports to Simulate I
2
C Interface ............ 200
Chapter 5. Instruction System ......................................................206
4.18.1 Master Mode using I/O ports to Simulate I
2
C Interface by Software ..... 200
4.18.2 Slave Mode using I/O ports to Simulate I
2
C Interface by Software ....... 203
.
5.1 Addressing Modes .......................................................................... 206
.
5.1.1 Immediate Addressing ............................................................................... 206
5.1.2 Direct Addressing ...................................................................................... 206
5.1.3 Indirect Addressing ................................................................................... 206
.
5.1.4 Register Addressing .................................................................................. 207
.
5.1.5 Inherent Addressing .................................................................................. 207
.
5.1.6 Index Addressing ....................................................................................... 207
5.1.7 Bit Addressing ........................................................................................... 207
Chapter 6 Interrupt System ..........................................................251
5.2 Instruction Set Summary ................................................................ 208
.
5.3 Instruction Definitions of Traditional 8051 MCU .......................... 214
6.1 Interrupt Structure ........................................................................... 252
6.2 Interrupt Vector Address/Priority/Request Flag Table .................... 255
6.3 How to Declare Interrupt Function in Keil C ................................. 256
6.4 Interrupt Registers .......................................................................... 257
.
6.5 Interrupt Priorities ........................................................................... 266
6.6 Interrupt Handling .......................................................................... 268
.
6.7 Interrupt Nesting ............................................................................. 270