STM8S参考手册
RM0016
参考手册
STM8S
微控制器家族
导言
本参考手册为应用开发人员提供了关于如½½用STM8S微控制器的存储器和外设的完整信息。
STM8S是一个拥有不同存储器大小,封装和外设的微控制器家族。
■
STM8S针对通用应用而设计,关于订货信息,引脚描述,器件的机械及电气参数,请参考
STM8S增强型及基本型数据手册。
■
关于内部FLASH存储器的编程,擦除和保护,请参考STM8S
Flash编程手册(PM0051)
和
STM8 SWIM
通讯协议及调试模块用户手册(UM0470)
■
关于STM8内核,请参考STM8
CPU
编程手册(PM0044)。
本译文的英文原文下½½地址为:http://www.st.com/stonline/products/literature/rm/14587.pdf
参照2009年1月
RM0016 Reference Manual STM8S microcontroller family
英文第4版
本译文仅供参考,如有翻译错误,请以英文原稿为准。请读者随时注意在ST½站下½½更新版本
STM8S参考手册
目½
1
中央处理器(CPU) ........................................................................ 11
1.1
1.2
简介 ............................................................................... 11
CPU寄存器 .......................................................................... 11
1.2.1
1.2.2
1.3
CPU寄存器描述 ................................................................... 11
STM8 CPU寄存器映射 .............................................................. 13
激活级别 ........................................................................
禁用SWIM ........................................................................
全局配½寄存器(CFG_GCR)描述......................................................
全局配½寄存器映射及复½值.......................................................
14
14
14
14
全局配½寄存器(CFG_GCR) ............................................................ 14
1.3.1
1.3.2
1.3.3
1.3.4
2
3
用于系统启动的只读存储器 ............................................................... 15
存储器和寄存器映射 ..................................................................... 16
3.1
寄存器描述缩写 ..................................................................... 16
4
FLASH程序存储器和数据EEPROM ............................................................ 17
4.1
4.2
4.3
4.4
介绍 ...............................................................................
词汇表 .............................................................................
FLASH主要特性 ......................................................................
存储器组织结构 .....................................................................
17
17
17
17
4.4.1
4.4.2
4.4.3
4.4.4
4.5
用户启动区域(UBC) ...............................................................
数据EEPROM(DATA) ................................................................
主程序区 ........................................................................
选项字节(Option byte)............................................................
20
23
23
23
存储器保护 ......................................................................... 24
4.5.1
4.5.2
4.5.3
4.6
4.7
读保护 .......................................................................... 24
存储器存取安全系统(MASS)......................................................... 24
对选项字节的写操½ .............................................................. 25
存储器编程 ......................................................................... 25
读同时写 (RWW) ..................................................................... 25
4.7.1
4.7.2
4.7.3
4.7.4
4.8
4.9
字节编程 ........................................................................
字编程 ..........................................................................
块编程 ..........................................................................
选项字节(Option byte)编程........................................................
25
26
26
27
ICP和IAP ........................................................................... 27
FLASH寄存器 ........................................................................ 29
4.9.1
4.9.2
4.9.3
4.9.4
4.9.5
4.9.6
4.9.7
4.9.8
4.9.9
5
FLASH控制寄存器 1(FLASH_CR1) .....................................................
FLASH控制寄存器 2(FLASH_CR2) .....................................................
FLASH互补控制寄存器 2(FLASH_NCR2) ................................................
FLASH保护寄存器(FLASH_FPR).......................................................
FLASH保护寄存器(FLASH_NFPR)......................................................
FLASH程序存储器解保护寄存器(FLASH_PUKR)..........................................
DATA EEPROM解保护寄存器(FLASH_DUKR)..............................................
FLASH状态寄存器(FLASH_IAPSR).....................................................
FLASH寄存器映射和复½值..........................................................
29
30
31
32
33
34
35
36
37
单线接口模块(SWIM)和调试模块(DM) ....................................................... 38
5.1
5.2
5.3
介绍 ............................................................................... 38
主要特性 ........................................................................... 38
SWIM模式 ........................................................................... 38
6
7
供电电源 ............................................................................... 39
复½(RST) .............................................................................. 40
参照2009年1月
RM0016 Reference Manual STM8S microcontroller family
英文第4版
本译文仅供参考,如有翻译错误,请以英文原稿为准。请读者随时注意在ST½站下½½更新版本
STM8S参考手册
7.1
7.2
复½电路 ........................................................................... 40
内部复½源 ......................................................................... 40
7.2.1
7.2.2
7.2.3
7.2.4
7.2.5
7.2.6
7.3
7.4
8
上电复½(POR)和掉电复½(BOR).....................................................
看门狗复½ ......................................................................
½件复½ ........................................................................
SWIM复½ ........................................................................
非法操½码复½ ..................................................................
EMS复½ .........................................................................
40
41
41
41
41
41
复½(RST)寄存器 .................................................................... 42
7.3.1
复½状态寄存器(RST_SR)........................................................... 42
复½寄存器地址映射 ................................................................. 42
时钟控制 ............................................................................... 43
8.1
主时钟源 ........................................................................... 44
8.1.1
8.1.2
8.1.3
8.2
HSE ............................................................................. 45
HSI ............................................................................. 46
LSI ............................................................................. 46
系统启动 ........................................................................ 46
主时钟切换的过程 ................................................................ 46
49
49
49
50
50
51
52
主时钟切换 ......................................................................... 46
8.2.1
8.2.2
8.3
8.4
8.5
8.6
8.7
8.8
8.9
½速时钟源的选择 ...................................................................
CPU时钟分频器 ......................................................................
外设时钟门控 .......................................................................
时钟安全系统(CSS) ..................................................................
时钟输出功½(CCO) ..................................................................
时钟中断 ...........................................................................
时钟寄存器 .........................................................................
8.9.1
8.9.2
8.9.3
8.9.4
8.9.5
8.9.6
8.9.7
8.9.8
8.9.9
8.9.10
8.9.11
8.9.12
8.9.13
8.10
9
内部时钟寄存器(CLK_ICKR).........................................................
外部时钟寄存器(CLK_ECKR).........................................................
主时钟状态寄存器(CLK_CMSR).......................................................
主时钟切换寄存器(CLK_SWR)........................................................
切换控制寄存器(CLK_SWCR).........................................................
时钟分频寄存器(CLK_CKDIVR).......................................................
外设时钟门控寄存器(CLK_PCKENR1)..................................................
外设时钟门控寄存器 2(CLK_PCKENR2) ................................................
时钟安全系统寄存器(CLK_CSSR).....................................................
可配½时钟输出寄存器 ............................................................
CAN外部时钟控制寄存器(CLK_CANCCR)................................................
HSI时钟修正寄存器(CLK_HSITRIMR)..................................................
SWIM时钟控制寄存器(CLK_SWIMCCR)..................................................
52
53
54
55
56
57
58
59
60
61
62
63
64
时钟寄存器地址映射 ................................................................. 65
电源管理 ............................................................................... 66
9.1
9.2
常规考虑 ........................................................................... 66
½功耗的时钟管理 ................................................................... 66
9.2.1
9.2.2
9.3
降½系统时钟 .................................................................... 66
外设时钟门控 .................................................................... 66
等待(Wait)模式 .................................................................. 67
停机(Halt)模式 .................................................................. 67
活跃停机(Active Halt)模式........................................................ 68
停机模式下的快速内存唤醒......................................................... 68
活跃停机模式下的超½内存功耗..................................................... 68
½功耗模式 ......................................................................... 67
9.3.1
9.3.2
9.3.3
9.4
附加的模拟功耗控制 ................................................................. 68
9.4.1
9.4.2
10
中断控制器(ITC) ........................................................................ 69
参照2009年1月
RM0016 Reference Manual STM8S microcontroller family
英文第4版
本译文仅供参考,如有翻译错误,请以英文原稿为准。请读者随时注意在ST½站下½½更新版本
STM8S参考手册
10.1
10.2
简介 ............................................................................... 69
中断屏½和处理流程 ................................................................. 69
10.2.1
10.2.2
10.3
10.4
10.5
处理等待(排队)的中断 ........................................................ 70
中断源 ........................................................................ 71
中断和½功耗模式 ................................................................... 72
活动等级/½功耗模式的控制 .......................................................... 72
同时的和嵌套的中断管理 ............................................................. 72
10.5.1
10.5.2
10.6
10.7
10.8
10.9
同时发生中断管理模式 .......................................................... 72
嵌套中断管理模式 .............................................................. 73
74
74
75
76
外部中断 ...........................................................................
中断指令 ...........................................................................
中断映射 ...........................................................................
ITC寄存器 ..........................................................................
10.9.1
10.9.2
10.9.3
10.9.4
10.9.5
11
CPU CC 寄存器中断½ ...........................................................
½件优先级寄存器 x (ITC_SPRx) .................................................
外部中断控制寄存器 1 (EXTI_CR1) ...............................................
外部中断控制寄存器 1 (EXTI_CR2) ...............................................
寄存器表和复½值 ..............................................................
76
77
78
79
80
通用输入输出口(GPIO) ................................................................... 81
11.1
11.2
11.3
简介 ............................................................................... 81
GPIO主要功½ ....................................................................... 81
I/O的配½和½用 .................................................................... 82
11.3.1
11.3.2
11.4
11.5
11.6
11.7
输入模式 ...................................................................... 83
输出模式 ...................................................................... 83
83
83
83
83
复½后的默认配½ ...................................................................
没有½用的引脚 .....................................................................
½功耗模式 .........................................................................
输入模式的详述 .....................................................................
11.7.1
11.7.2
11.7.3
11.7.4
11.8
复用功½输入 ..................................................................
中断功½ ......................................................................
模拟通道 ......................................................................
½密特触发器 ..................................................................
83
84
84
84
输出模式详述 ....................................................................... 84
11.8.1
11.8.2
11.9
复用功½的输出 ................................................................ 84
摆率控制 ...................................................................... 84
端口
端口
端口
端口
端口
GPIO
x 输出数据寄存器 (Px_ODR) ................................................
x 输入寄存器 (Px_IDR) ....................................................
x 数据方向 (Px_DDR) ......................................................
x 控制寄存器 1 (Px_CR1) ..................................................
x 控制寄存器 2 (Px_CR2) ..................................................
寄存器表和复½值 .........................................................
85
86
87
88
89
89
GPIO 寄存器 ........................................................................ 84
11.9.1
11.9.2
11.9.3
11.9.4
11.9.5
11.9.6
12
自动唤醒(AWU) .......................................................................... 90
12.1
12.2
简介 ............................................................................... 90
AWU功½描述 ........................................................................ 90
12.2.1 AWU 操½ ........................................................................ 90
12.2.2
时基选择 ...................................................................... 91
12.2.3 LSI ½速内部时钟频率检测......................................................... 91
12.3
AWU 寄存器 ......................................................................... 92
12.3.1
12.3.2
12.3.3
12.3.4
控制/状态寄存器 (AWU_CSR) .....................................................
异步预分频寄存器 (AWU_APR) ....................................................
时基选择寄存器 (AWU_TBR) ......................................................
AWU 寄存器表和复½值 ..........................................................
92
93
94
95
参照2009年1月
RM0016 Reference Manual STM8S microcontroller family
英文第4版
本译文仅供参考,如有翻译错误,请以英文原稿为准。请读者随时注意在ST½站下½½更新版本
STM8S参考手册
13
蜂鸣器(BEEP) ........................................................................... 96
13.1
13.2
简介 ............................................................................... 96
功½描述 ........................................................................... 96
13.2.1
13.2.2
13.3
蜂鸣器操½ .................................................................... 96
蜂鸣器校准 .................................................................... 96
蜂鸣器 控制/状态 寄存器 (BEEP_CSR) ............................................ 97
BEEP寄存器表和复½值 .......................................................... 97
蜂鸣器 寄存器 ...................................................................... 97
13.3.1
13.3.2
14
独立看门狗(IWDG) ....................................................................... 98
14.1
14.2
14.3
介绍 ............................................................................... 98
独立看门狗功½说明 ................................................................. 98
IWDG寄存器 ......................................................................... 99
14.3.1
14.3.2
14.3.3
14.3.4
15
键寄存器(IWDG_KR) ............................................................. 99
预分频寄存器(IWDG_PR) ........................................................ 100
重装½½寄存器(IWDG_RLR) ....................................................... 101
IWDG寄存器映像和复½数值 ..................................................... 101
窗口看门狗(WWDG) ...................................................................... 102
15.1
15.2
15.3
15.4
15.5
15.6
15.7
15.8
15.9
15.10
介绍 ..............................................................................
WWDG主要功½ ......................................................................
WWDG功½说明 ......................................................................
在停止模式下½用WWDG ..............................................................
如½设½看门狗的超时 ..............................................................
WWDG½功耗模式 ....................................................................
硬件看门狗选项 ....................................................................
在停止模式下½用WWDG ..............................................................
WWDG中断 ..........................................................................
WWDG寄存器 ........................................................................
102
102
102
103
103
104
104
104
105
105
15.10.1
15.10.2
15.11
16
控制寄存器(WWDG_CR) .......................................................... 105
窗口寄存器(WWDG_WR) .......................................................... 106
窗口看门狗寄存器映像和复½数值 .................................................... 106
定时器概述 ............................................................................ 107
16.1
16.2
定时器功½比较 .................................................................... 108
定时器信号术语表 .................................................................. 108
17
16 ½高级控制定时器(TIM1).............................................................. 110
17.1
17.2
17.3
简介 .............................................................................. 110
主要特性 .......................................................................... 110
时基单元 .......................................................................... 112
17.3.1
17.3.2
17.3.3
17.3.4
17.3.5
17.3.6
17.3.7
17.4
读写 16 ½计数器 ..............................................................
16 ½TIM1_ARR寄存器的写操½...................................................
预分频器 .....................................................................
向上计数模式 .................................................................
向下计数模式 .................................................................
中央对½模式(向上/向下计数) ..................................................
重复计数器 ...................................................................
预分频时钟(CK_PSC) ...........................................................
内部时钟源(f
MASTER
) .............................................................
外部时钟源模式 1..............................................................
外部时钟源模式 2..............................................................
触发同步 .....................................................................
与TIM5/TIM6 定时器的同步......................................................
112
113
113
113
115
116
117
119
119
119
120
121
124
时钟/触发控制器 ................................................................... 118
17.4.1
17.4.2
17.4.3
17.4.4
17.4.5
17.4.6
17.5
捕获/比较通道 ..................................................................... 129
参照2009年1月
RM0016 Reference Manual STM8S microcontroller family
英文第4版
本译文仅供参考,如有翻译错误,请以英文原稿为准。请读者随时注意在ST½站下½½更新版本
评论