ARM
• ARM既指ARM公司,也指ARM处理器内核
ARM公司是全球领先的半导体知识产权(IP)提供商,全世界超过95%的智能手机和平板电脑都采用ARM架构
ARM公司设计ARM内核,半导体厂商完善内核周边电路并生产芯片
STM32F103C8T6
系列:主流系列STM32F1内核:ARM Cortex-M3主频:72MHzRAM:20K (SRAM)ROM:64K(Flash)供电:2.0~3.6V(标准3.3V)封装:LQFP48

STM32 学习笔记:STM32 简介与学习路线
对应课程:
[1-2] STM32简介整理日期:2026-08-29
学习状态:已听课,已结合师兄笔记校正和补全
主控型号:STM32F103C8T6
开发体系:Keil + STM32F10x 标准外设库
1. 本节要解决什么问题
学完本节,应能回答下面几个问题:
- STM32 是什么,适合用来做什么?
- STM32、ARM 和 Cortex-M3 之间是什么关系?
STM32F103C8T6每一段字符代表什么?- STM32F103C8T6 有哪些主要片上资源?
- CPU、总线、存储器和外设如何连接?
- BOOT0、BOOT1 如何决定启动位置?
- 一块 STM32 最小系统至少需要哪些电路?
2. STM32 是什么
STM32 是 STMicroelectronics(意法半导体)推出的 32 位微控制器系列。它把 CPU、程序存储器、运行内存以及 GPIO、定时器、ADC、串口等外设集成在一颗芯片中。
典型应用包括:
- 智能车:读取红外或光电传感器,输出 PWM 驱动电机;
- 无人机:读取陀螺仪和加速度计,进行姿态解算与控制;
- 机器人:控制关节、电机和各种传感器;
- 工业控制:采集信号,与其他设备通信并执行控制;
- 物联网:连接蓝牙、Wi-Fi 等通信模块;
- 普通电子制作:流水灯、显示、报警器等。
本课程使用 STM32F1 主流系列中的 STM32F103C8T6 。它基于 Arm Cortex-M3 内核,最高主频通常为 72 MHz。
2.1 STM32、ST、Arm 和 Cortex-M3 的关系
Arm 主要设计并授权处理器内核;ST 获得授权后,在 Cortex-M3 内核外围增加存储器、总线和各种片上外设,形成完整的 STM32 芯片。
#mermaid-svg-iqBMaBhpjnitnOBU{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-iqBMaBhpjnitnOBU .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-iqBMaBhpjnitnOBU .error-icon{fill:#552222;}#mermaid-svg-iqBMaBhpjnitnOBU .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-iqBMaBhpjnitnOBU .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-iqBMaBhpjnitnOBU .marker{fill:#333333;stroke:#333333;}#mermaid-svg-iqBMaBhpjnitnOBU .marker.cross{stroke:#333333;}#mermaid-svg-iqBMaBhpjnitnOBU svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-iqBMaBhpjnitnOBU p{margin:0;}#mermaid-svg-iqBMaBhpjnitnOBU .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-iqBMaBhpjnitnOBU .cluster-label text{fill:#333;}#mermaid-svg-iqBMaBhpjnitnOBU .cluster-label span{color:#333;}#mermaid-svg-iqBMaBhpjnitnOBU .cluster-label span p{background-color:transparent;}#mermaid-svg-iqBMaBhpjnitnOBU .label text,#mermaid-svg-iqBMaBhpjnitnOBU span{fill:#333;color:#333;}#mermaid-svg-iqBMaBhpjnitnOBU .node rect,#mermaid-svg-iqBMaBhpjnitnOBU .node circle,#mermaid-svg-iqBMaBhpjnitnOBU .node ellipse,#mermaid-svg-iqBMaBhpjnitnOBU .node polygon,#mermaid-svg-iqBMaBhpjnitnOBU .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-iqBMaBhpjnitnOBU .rough-node .label text,#mermaid-svg-iqBMaBhpjnitnOBU .node .label text,#mermaid-svg-iqBMaBhpjnitnOBU .image-shape .label,#mermaid-svg-iqBMaBhpjnitnOBU .icon-shape .label{text-anchor:middle;}#mermaid-svg-iqBMaBhpjnitnOBU .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-iqBMaBhpjnitnOBU .rough-node .label,#mermaid-svg-iqBMaBhpjnitnOBU .node .label,#mermaid-svg-iqBMaBhpjnitnOBU .image-shape .label,#mermaid-svg-iqBMaBhpjnitnOBU .icon-shape .label{text-align:center;}#mermaid-svg-iqBMaBhpjnitnOBU .node.clickable{cursor:pointer;}#mermaid-svg-iqBMaBhpjnitnOBU .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-iqBMaBhpjnitnOBU .arrowheadPath{fill:#333333;}#mermaid-svg-iqBMaBhpjnitnOBU .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-iqBMaBhpjnitnOBU .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-iqBMaBhpjnitnOBU .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-iqBMaBhpjnitnOBU .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-iqBMaBhpjnitnOBU .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-iqBMaBhpjnitnOBU .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-iqBMaBhpjnitnOBU .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-iqBMaBhpjnitnOBU .cluster text{fill:#333;}#mermaid-svg-iqBMaBhpjnitnOBU .cluster span{color:#333;}#mermaid-svg-iqBMaBhpjnitnOBU div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-iqBMaBhpjnitnOBU .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-iqBMaBhpjnitnOBU rect.text{fill:none;stroke-width:0;}#mermaid-svg-iqBMaBhpjnitnOBU .icon-shape,#mermaid-svg-iqBMaBhpjnitnOBU .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-iqBMaBhpjnitnOBU .icon-shape p,#mermaid-svg-iqBMaBhpjnitnOBU .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-iqBMaBhpjnitnOBU .icon-shape .label rect,#mermaid-svg-iqBMaBhpjnitnOBU .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-iqBMaBhpjnitnOBU .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-iqBMaBhpjnitnOBU .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-iqBMaBhpjnitnOBU :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 设计并授权
集成
Arm 公司
Cortex-M3 内核
意法半导体 ST
STM32F103 芯片
Flash / SRAM
GPIO / TIM / ADC / USART
I2C / SPI / DMA 等
可以简单记为:
Cortex-M3 是 CPU 内核,STM32F103 是包含该内核、存储器和外设的完整微控制器。
3. STM32 产品系列的基本认识
STM32 家族覆盖通用、高性能、低功耗和无线等方向。课程当前只要求建立整体印象,不需要背诵全部系列。
- F0、F1、F3 等:常见主流/通用系列;
- F2、F4、F7、H7 等:偏高性能;
- L0、L1、L4、L5 等:偏低功耗;
- WB、WL 等:带无线能力或面向无线应用。
选择芯片时,不能只看"STM32"或"F1",必须落实到完整型号并查看该型号的数据手册。同一系列的不同型号,Flash、SRAM、引脚数量和外设数量都可能不同。
4. STM32F103C8T6 型号解析
STM32F103C8T6 可以按下面的方式理解:
| 字段 | 含义 | 本型号信息 |
|---|---|---|
| STM32 | ST 的 32 位微控制器 | STM32 家族 |
| F | 产品类型/系列标识 | 通用型产品线 |
| 103 | 子系列 | STM32F103 增强型系列 |
| C | 引脚数量代码 | 48 引脚 |
| 8 | Flash 容量代码 | 64 KB |
| T | 封装代码 | LQFP |
| 6 | 温度等级代码 | -40 ℃~85 ℃ |
课程中经常对比的 STM32F103RCT6,其中 R 表示 64 引脚,C 表示 256 KB Flash;其余字段的解释方式相同。
4.1 关键参数
- 内核:Arm Cortex-M3;
- 最高主频:72 MHz;
- Flash:64 KB;
- SRAM:20 KB;
- 典型供电:3.3 V;
- 允许供电范围:以数据手册为准,课程给出约 2.0~3.6 V;
- 封装:LQFP48;
- ADC:12 位;
- 调试接口:SWD / JTAG;
- 常用通信外设:USART、I2C、SPI、USB、CAN(具体数量必须查该型号数据手册)。
!WARNING
USB 口提供的通常是 5 V,不能直接作为 STM32 的 3.3 V 电源。应先经过 3.3 V 稳压电路。部分 GPIO 标有
FT,表示输入端可容忍 5 V;没有FT标记的引脚不能默认接收 5 V 电平。
5. 常见片上外设
课程这一部分的目标是先认识缩写。具体配置方法会在后续章节逐项学习。
| 缩写 | 名称 | 主要用途 |
|---|---|---|
| NVIC | 嵌套向量中断控制器 | 管理中断和中断优先级 |
| SysTick | 系统滴答定时器 | 提供周期时基,可用于延时或操作系统节拍 |
| RCC | 复位和时钟控制 | 配置系统时钟,并给各外设开启时钟 |
| GPIO | 通用输入输出 | 输入按键/传感器状态,输出 LED 等控制信号 |
| AFIO | 复用功能 I/O | 外设引脚复用、重映射及 EXTI 端口选择 |
| EXTI | 外部中断/事件控制器 | 根据外部引脚边沿触发中断或事件 |
| TIM | 定时器 | 定时、计数、PWM、输入捕获、编码器接口 |
| ADC | 模数转换器 | 把模拟电压转换为数字量 |
| DMA | 直接存储器访问 | 在外设和存储器之间搬运数据,减少 CPU 参与 |
| USART | 同步/异步串口 | 调试输出、模块通信、数据包收发 |
| I2C | 两线串行总线 | 连接 MPU6050、EEPROM 等器件 |
| SPI | 同步串行总线 | 连接 Flash、显示屏、传感器等高速外设 |
| RTC | 实时时钟 | 维护年月日和时分秒,可由备用电池供电 |
| BKP | 备份寄存器 | 在备用电源域保存少量数据 |
| PWR | 电源控制 | 睡眠、停止和待机等低功耗控制 |
| IWDG / WWDG | 独立/窗口看门狗 | 程序异常时自动复位,提高系统可靠性 |
| DAC | 数模转换器 | 将数字量转换为模拟电压;C8T6 是否具备需查表 |
| CRC | 循环冗余校验 | 硬件辅助数据校验 |
| FSMC | 灵活静态存储器控制器 | 扩展外部存储器;C8T6 不具备 |
5.1 为什么使用外设前通常要开时钟
STM32 为降低功耗,许多外设上电后默认没有工作时钟。标准外设库初始化代码中经常首先调用 RCC 函数给目标外设开启时钟。
#mermaid-svg-PE30kTSDcBkWXP69{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-PE30kTSDcBkWXP69 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-PE30kTSDcBkWXP69 .error-icon{fill:#552222;}#mermaid-svg-PE30kTSDcBkWXP69 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-PE30kTSDcBkWXP69 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-PE30kTSDcBkWXP69 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-PE30kTSDcBkWXP69 .marker.cross{stroke:#333333;}#mermaid-svg-PE30kTSDcBkWXP69 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-PE30kTSDcBkWXP69 p{margin:0;}#mermaid-svg-PE30kTSDcBkWXP69 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-PE30kTSDcBkWXP69 .cluster-label text{fill:#333;}#mermaid-svg-PE30kTSDcBkWXP69 .cluster-label span{color:#333;}#mermaid-svg-PE30kTSDcBkWXP69 .cluster-label span p{background-color:transparent;}#mermaid-svg-PE30kTSDcBkWXP69 .label text,#mermaid-svg-PE30kTSDcBkWXP69 span{fill:#333;color:#333;}#mermaid-svg-PE30kTSDcBkWXP69 .node rect,#mermaid-svg-PE30kTSDcBkWXP69 .node circle,#mermaid-svg-PE30kTSDcBkWXP69 .node ellipse,#mermaid-svg-PE30kTSDcBkWXP69 .node polygon,#mermaid-svg-PE30kTSDcBkWXP69 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-PE30kTSDcBkWXP69 .rough-node .label text,#mermaid-svg-PE30kTSDcBkWXP69 .node .label text,#mermaid-svg-PE30kTSDcBkWXP69 .image-shape .label,#mermaid-svg-PE30kTSDcBkWXP69 .icon-shape .label{text-anchor:middle;}#mermaid-svg-PE30kTSDcBkWXP69 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-PE30kTSDcBkWXP69 .rough-node .label,#mermaid-svg-PE30kTSDcBkWXP69 .node .label,#mermaid-svg-PE30kTSDcBkWXP69 .image-shape .label,#mermaid-svg-PE30kTSDcBkWXP69 .icon-shape .label{text-align:center;}#mermaid-svg-PE30kTSDcBkWXP69 .node.clickable{cursor:pointer;}#mermaid-svg-PE30kTSDcBkWXP69 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-PE30kTSDcBkWXP69 .arrowheadPath{fill:#333333;}#mermaid-svg-PE30kTSDcBkWXP69 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-PE30kTSDcBkWXP69 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-PE30kTSDcBkWXP69 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-PE30kTSDcBkWXP69 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-PE30kTSDcBkWXP69 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-PE30kTSDcBkWXP69 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-PE30kTSDcBkWXP69 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-PE30kTSDcBkWXP69 .cluster text{fill:#333;}#mermaid-svg-PE30kTSDcBkWXP69 .cluster span{color:#333;}#mermaid-svg-PE30kTSDcBkWXP69 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-PE30kTSDcBkWXP69 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-PE30kTSDcBkWXP69 rect.text{fill:none;stroke-width:0;}#mermaid-svg-PE30kTSDcBkWXP69 .icon-shape,#mermaid-svg-PE30kTSDcBkWXP69 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-PE30kTSDcBkWXP69 .icon-shape p,#mermaid-svg-PE30kTSDcBkWXP69 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-PE30kTSDcBkWXP69 .icon-shape .label rect,#mermaid-svg-PE30kTSDcBkWXP69 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-PE30kTSDcBkWXP69 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-PE30kTSDcBkWXP69 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-PE30kTSDcBkWXP69 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 准备使用外设
确定外设挂在哪条总线
通过 RCC 开启外设时钟
配置 GPIO 或复用功能
配置外设参数
使能外设
读写数据或响应中断
这一流程会在 GPIO、TIM、USART、ADC、I2C、SPI 等几乎所有章节重复出现。
6. STM32F103 系统结构和总线
理解总线结构的意义不是背图,而是知道:
- CPU 如何访问 Flash、SRAM 和外设;
- 外设挂在哪条总线上;
- 为什么开启 GPIO、TIM 或 USART 时,要选择不同的 RCC 时钟函数;
- 为什么 APB1 和 APB2 的默认时钟可能不同。
6.1 简化结构
#mermaid-svg-btMw4J7qAzucoRES{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-btMw4J7qAzucoRES .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-btMw4J7qAzucoRES .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-btMw4J7qAzucoRES .error-icon{fill:#552222;}#mermaid-svg-btMw4J7qAzucoRES .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-btMw4J7qAzucoRES .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-btMw4J7qAzucoRES .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-btMw4J7qAzucoRES .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-btMw4J7qAzucoRES .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-btMw4J7qAzucoRES .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-btMw4J7qAzucoRES .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-btMw4J7qAzucoRES .marker{fill:#333333;stroke:#333333;}#mermaid-svg-btMw4J7qAzucoRES .marker.cross{stroke:#333333;}#mermaid-svg-btMw4J7qAzucoRES svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-btMw4J7qAzucoRES p{margin:0;}#mermaid-svg-btMw4J7qAzucoRES .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-btMw4J7qAzucoRES .cluster-label text{fill:#333;}#mermaid-svg-btMw4J7qAzucoRES .cluster-label span{color:#333;}#mermaid-svg-btMw4J7qAzucoRES .cluster-label span p{background-color:transparent;}#mermaid-svg-btMw4J7qAzucoRES .label text,#mermaid-svg-btMw4J7qAzucoRES span{fill:#333;color:#333;}#mermaid-svg-btMw4J7qAzucoRES .node rect,#mermaid-svg-btMw4J7qAzucoRES .node circle,#mermaid-svg-btMw4J7qAzucoRES .node ellipse,#mermaid-svg-btMw4J7qAzucoRES .node polygon,#mermaid-svg-btMw4J7qAzucoRES .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-btMw4J7qAzucoRES .rough-node .label text,#mermaid-svg-btMw4J7qAzucoRES .node .label text,#mermaid-svg-btMw4J7qAzucoRES .image-shape .label,#mermaid-svg-btMw4J7qAzucoRES .icon-shape .label{text-anchor:middle;}#mermaid-svg-btMw4J7qAzucoRES .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-btMw4J7qAzucoRES .rough-node .label,#mermaid-svg-btMw4J7qAzucoRES .node .label,#mermaid-svg-btMw4J7qAzucoRES .image-shape .label,#mermaid-svg-btMw4J7qAzucoRES .icon-shape .label{text-align:center;}#mermaid-svg-btMw4J7qAzucoRES .node.clickable{cursor:pointer;}#mermaid-svg-btMw4J7qAzucoRES .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-btMw4J7qAzucoRES .arrowheadPath{fill:#333333;}#mermaid-svg-btMw4J7qAzucoRES .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-btMw4J7qAzucoRES .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-btMw4J7qAzucoRES .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-btMw4J7qAzucoRES .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-btMw4J7qAzucoRES .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-btMw4J7qAzucoRES .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-btMw4J7qAzucoRES .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-btMw4J7qAzucoRES .cluster text{fill:#333;}#mermaid-svg-btMw4J7qAzucoRES .cluster span{color:#333;}#mermaid-svg-btMw4J7qAzucoRES div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-btMw4J7qAzucoRES .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-btMw4J7qAzucoRES rect.text{fill:none;stroke-width:0;}#mermaid-svg-btMw4J7qAzucoRES .icon-shape,#mermaid-svg-btMw4J7qAzucoRES .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-btMw4J7qAzucoRES .icon-shape p,#mermaid-svg-btMw4J7qAzucoRES .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-btMw4J7qAzucoRES .icon-shape .label rect,#mermaid-svg-btMw4J7qAzucoRES .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-btMw4J7qAzucoRES .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-btMw4J7qAzucoRES .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-btMw4J7qAzucoRES :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Cortex-M3 CPU
总线矩阵
Flash
程序与常量
SRAM
运行数据
DMA
数据搬运
AHB 高性能总线
APB1 外设总线
典型最高 36 MHz
APB2 外设总线
典型最高 72 MHz
GPIO / AFIO / EXTI / ADC
USART1 / SPI1 / TIM1 等
TIM2~TIM4 / USART2~3
I2C / SPI2 / PWR / BKP 等
以上挂载关系是帮助理解的简化图,最终应以 STM32F103 参考手册中的系统结构图和时钟树 为准。
6.2 三条内核总线的直观理解
- I-Code:从 Flash 取程序指令;
- D-Code:访问代码区中的数据,例如常量;
- System:访问 SRAM、外设和其他系统资源。
6.3 DMA 为什么能减轻 CPU 负担
例如 ADC 连续采样时,如果每次转换都由 CPU 读取结果,CPU 会频繁执行重复搬运。DMA 可以按照配置自动将 ADC 数据搬到数组中,完成后再通知 CPU。
CPU SRAM数组 DMA ADC CPU SRAM数组 DMA ADC #mermaid-svg-vK4fAPrqxirSJVNJ{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-vK4fAPrqxirSJVNJ .error-icon{fill:#552222;}#mermaid-svg-vK4fAPrqxirSJVNJ .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-vK4fAPrqxirSJVNJ .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-vK4fAPrqxirSJVNJ .marker{fill:#333333;stroke:#333333;}#mermaid-svg-vK4fAPrqxirSJVNJ .marker.cross{stroke:#333333;}#mermaid-svg-vK4fAPrqxirSJVNJ svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-vK4fAPrqxirSJVNJ p{margin:0;}#mermaid-svg-vK4fAPrqxirSJVNJ .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-vK4fAPrqxirSJVNJ text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-vK4fAPrqxirSJVNJ .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-vK4fAPrqxirSJVNJ .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-vK4fAPrqxirSJVNJ #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-vK4fAPrqxirSJVNJ .sequenceNumber{fill:white;}#mermaid-svg-vK4fAPrqxirSJVNJ #sequencenumber{fill:#333;}#mermaid-svg-vK4fAPrqxirSJVNJ #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-vK4fAPrqxirSJVNJ .messageText{fill:#333;stroke:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-vK4fAPrqxirSJVNJ .labelText,#mermaid-svg-vK4fAPrqxirSJVNJ .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .loopText,#mermaid-svg-vK4fAPrqxirSJVNJ .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-vK4fAPrqxirSJVNJ .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-vK4fAPrqxirSJVNJ .noteText,#mermaid-svg-vK4fAPrqxirSJVNJ .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-vK4fAPrqxirSJVNJ .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-vK4fAPrqxirSJVNJ .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-vK4fAPrqxirSJVNJ .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-vK4fAPrqxirSJVNJ .actorPopupMenu{position:absolute;}#mermaid-svg-vK4fAPrqxirSJVNJ .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-vK4fAPrqxirSJVNJ .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-vK4fAPrqxirSJVNJ .actor-man circle,#mermaid-svg-vK4fAPrqxirSJVNJ line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-vK4fAPrqxirSJVNJ :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} CPU同时执行其他任务 转换完成,发出DMA请求读取数据寄存器写入下一个数组位置一批数据完成后产生中断(可选)
7. 引脚与调试接口
7.1 看引脚表时重点关注什么
- 引脚序号与方向;
- GPIO 名称,如
PA0、PB6; - 默认功能与复用功能;
- 是否为
FT(5 V tolerant)输入; - 是否与晶振、复位、电源、调试或启动功能共用;
- 所需外设是否支持引脚重映射。
7.2 SWD 与 JTAG
STM32F103 支持 SWD 和 JTAG。课程采用 ST-LINK 的 SWD 方式,核心信号是:
SWDIO:调试数据;SWCLK:调试时钟;GND:共地;3.3V:目标板电平参考/供电连接,具体取决于下载器接法。
调试引脚与普通 GPIO 复用。程序中如果错误关闭或重映射全部调试端口,可能导致 ST-LINK 暂时无法连接,需要通过复位连接或系统 Bootloader 恢复。
8. 启动模式:BOOT0 与 BOOT1
STM32 复位时采样启动引脚,决定从哪个存储区域开始执行。
| BOOT0 | BOOT1 | 启动区域 | 典型用途 |
|---|---|---|---|
| 0 | 任意 | 主 Flash | 正常运行用户程序,最常用 |
| 1 | 0 | 系统存储器 | 运行芯片内置 Bootloader,可用于串口下载等 |
| 1 | 1 | SRAM | 从 SRAM 启动,普通学习项目很少使用 |
#mermaid-svg-UeDEUUWN5j4Ael4Y{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-UeDEUUWN5j4Ael4Y .error-icon{fill:#552222;}#mermaid-svg-UeDEUUWN5j4Ael4Y .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-UeDEUUWN5j4Ael4Y .marker{fill:#333333;stroke:#333333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .marker.cross{stroke:#333333;}#mermaid-svg-UeDEUUWN5j4Ael4Y svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-UeDEUUWN5j4Ael4Y p{margin:0;}#mermaid-svg-UeDEUUWN5j4Ael4Y .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster-label text{fill:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster-label span{color:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster-label span p{background-color:transparent;}#mermaid-svg-UeDEUUWN5j4Ael4Y .label text,#mermaid-svg-UeDEUUWN5j4Ael4Y span{fill:#333;color:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .node rect,#mermaid-svg-UeDEUUWN5j4Ael4Y .node circle,#mermaid-svg-UeDEUUWN5j4Ael4Y .node ellipse,#mermaid-svg-UeDEUUWN5j4Ael4Y .node polygon,#mermaid-svg-UeDEUUWN5j4Ael4Y .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .rough-node .label text,#mermaid-svg-UeDEUUWN5j4Ael4Y .node .label text,#mermaid-svg-UeDEUUWN5j4Ael4Y .image-shape .label,#mermaid-svg-UeDEUUWN5j4Ael4Y .icon-shape .label{text-anchor:middle;}#mermaid-svg-UeDEUUWN5j4Ael4Y .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .rough-node .label,#mermaid-svg-UeDEUUWN5j4Ael4Y .node .label,#mermaid-svg-UeDEUUWN5j4Ael4Y .image-shape .label,#mermaid-svg-UeDEUUWN5j4Ael4Y .icon-shape .label{text-align:center;}#mermaid-svg-UeDEUUWN5j4Ael4Y .node.clickable{cursor:pointer;}#mermaid-svg-UeDEUUWN5j4Ael4Y .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .arrowheadPath{fill:#333333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UeDEUUWN5j4Ael4Y .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-UeDEUUWN5j4Ael4Y .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UeDEUUWN5j4Ael4Y .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster text{fill:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y .cluster span{color:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-UeDEUUWN5j4Ael4Y .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-UeDEUUWN5j4Ael4Y rect.text{fill:none;stroke-width:0;}#mermaid-svg-UeDEUUWN5j4Ael4Y .icon-shape,#mermaid-svg-UeDEUUWN5j4Ael4Y .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UeDEUUWN5j4Ael4Y .icon-shape p,#mermaid-svg-UeDEUUWN5j4Ael4Y .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-UeDEUUWN5j4Ael4Y .icon-shape .label rect,#mermaid-svg-UeDEUUWN5j4Ael4Y .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UeDEUUWN5j4Ael4Y .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-UeDEUUWN5j4Ael4Y .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-UeDEUUWN5j4Ael4Y :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 是
否
是
否
芯片复位
BOOT0 是 0 吗?
从主 Flash 启动
执行用户程序
BOOT1 是 0 吗?
从系统存储器启动
进入内置 Bootloader
从 SRAM 启动
启动引脚在复位瞬间被采样。完成启动后,引脚可能恢复为其普通/复用功能,但硬件上仍应给 BOOT0 一个确定电平,不能悬空。
9. STM32 最小系统
"最小系统"是让单片机能够稳定供电、复位、运行和下载程序所需的最基本电路集合。
#mermaid-svg-tL5a9nbKUF5DX4cu{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-tL5a9nbKUF5DX4cu .error-icon{fill:#552222;}#mermaid-svg-tL5a9nbKUF5DX4cu .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-tL5a9nbKUF5DX4cu .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-tL5a9nbKUF5DX4cu .marker{fill:#333333;stroke:#333333;}#mermaid-svg-tL5a9nbKUF5DX4cu .marker.cross{stroke:#333333;}#mermaid-svg-tL5a9nbKUF5DX4cu svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-tL5a9nbKUF5DX4cu p{margin:0;}#mermaid-svg-tL5a9nbKUF5DX4cu .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster-label text{fill:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster-label span{color:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster-label span p{background-color:transparent;}#mermaid-svg-tL5a9nbKUF5DX4cu .label text,#mermaid-svg-tL5a9nbKUF5DX4cu span{fill:#333;color:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu .node rect,#mermaid-svg-tL5a9nbKUF5DX4cu .node circle,#mermaid-svg-tL5a9nbKUF5DX4cu .node ellipse,#mermaid-svg-tL5a9nbKUF5DX4cu .node polygon,#mermaid-svg-tL5a9nbKUF5DX4cu .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-tL5a9nbKUF5DX4cu .rough-node .label text,#mermaid-svg-tL5a9nbKUF5DX4cu .node .label text,#mermaid-svg-tL5a9nbKUF5DX4cu .image-shape .label,#mermaid-svg-tL5a9nbKUF5DX4cu .icon-shape .label{text-anchor:middle;}#mermaid-svg-tL5a9nbKUF5DX4cu .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-tL5a9nbKUF5DX4cu .rough-node .label,#mermaid-svg-tL5a9nbKUF5DX4cu .node .label,#mermaid-svg-tL5a9nbKUF5DX4cu .image-shape .label,#mermaid-svg-tL5a9nbKUF5DX4cu .icon-shape .label{text-align:center;}#mermaid-svg-tL5a9nbKUF5DX4cu .node.clickable{cursor:pointer;}#mermaid-svg-tL5a9nbKUF5DX4cu .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-tL5a9nbKUF5DX4cu .arrowheadPath{fill:#333333;}#mermaid-svg-tL5a9nbKUF5DX4cu .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-tL5a9nbKUF5DX4cu .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-tL5a9nbKUF5DX4cu .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tL5a9nbKUF5DX4cu .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-tL5a9nbKUF5DX4cu .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tL5a9nbKUF5DX4cu .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster text{fill:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu .cluster span{color:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-tL5a9nbKUF5DX4cu .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-tL5a9nbKUF5DX4cu rect.text{fill:none;stroke-width:0;}#mermaid-svg-tL5a9nbKUF5DX4cu .icon-shape,#mermaid-svg-tL5a9nbKUF5DX4cu .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-tL5a9nbKUF5DX4cu .icon-shape p,#mermaid-svg-tL5a9nbKUF5DX4cu .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-tL5a9nbKUF5DX4cu .icon-shape .label rect,#mermaid-svg-tL5a9nbKUF5DX4cu .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-tL5a9nbKUF5DX4cu .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-tL5a9nbKUF5DX4cu .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-tL5a9nbKUF5DX4cu :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 3.3 V 电源
去耦/滤波电容
STM32F103C8T6
8 MHz 主晶振
及负载电容
32.768 kHz 晶振
RTC 可选
NRST 复位电路
上拉 + 电容 + 按键
BOOT0/BOOT1
启动配置
SWDIO / SWCLK
下载调试接口
VBAT 备用电源
可选
9.1 电源与去耦
- 所有 VDD 应正确接 3.3 V,所有 VSS 应接 GND;
- VDDA/VSSA 是模拟电源相关引脚,也必须按手册连接;
- 每组电源附近放置去耦电容,以抑制电源波动;
- 不使用独立备用电池时,VBAT 通常接到 3.3 V,不能悬空。
9.2 时钟电路
- 常见主晶振为 8 MHz,经内部 PLL 倍频得到 72 MHz 系统时钟;
- 需要高精度 RTC 时,可连接 32.768 kHz 低速外部晶振;
32768 = 2^15,便于 RTC 分频得到 1 Hz 时基;- 晶振和负载电容的取值、布局应参考芯片及晶振数据手册。
9.3 复位电路
NRST 为低电平有效。课程展示了上拉电阻、电容及按键组成的复位电路:
- 上电瞬间形成短暂低电平,使芯片复位;
- 电容充电后,NRST 回到高电平,芯片开始运行;
- 按下复位键时,NRST 被拉低;松开后重新运行程序。
9.4 下载接口
建议至少引出:
- SWDIO;
- SWCLK;
- GND;
- 3.3 V;
- 条件允许时也引出 NRST,便于处理连接困难。
课程配套核心板已经集成稳压、晶振、复位、BOOT 跳线、LED、USB 供电和 SWD 接口,因此入门实验不需要自己重新搭建最小系统。
10. 自动转写中的关键术语纠正
录音转写存在同音词和英文缩写误识别。下面列出本节最容易混淆的内容:
| 转写中可能出现的词 | 正确术语 |
|---|---|
| COTAX、CORT xd | Cortex |
| NVRC | NVIC |
| cst 系统定时器 | SysTick 系统滴答定时器 |
| RTCCC 复位和时钟控制 | RCC |
| ESTIS | EXTI |
| APP1 / APP2 | APB1 / APB2 |
| AIOR、alcohol、L口 | GPIO / I/O 口 |
| 魔术转换器 | 模数转换器(ADC) |
| 开门狗 | 看门狗(Watchdog) |
| 金正、进阵 | 晶振 |
| 布特 | BOOT |
| NSP、NIST | NRST |
| SP link、STNIK | ST-LINK |
| SWCOK | SWCLK |
| room | ROM;本芯片程序实际存于 Flash |
11. 本节知识闭环
#mermaid-svg-x0Rw8Zt809lcJtj3{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-x0Rw8Zt809lcJtj3 .error-icon{fill:#552222;}#mermaid-svg-x0Rw8Zt809lcJtj3 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-x0Rw8Zt809lcJtj3 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-x0Rw8Zt809lcJtj3 .marker.cross{stroke:#333333;}#mermaid-svg-x0Rw8Zt809lcJtj3 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-x0Rw8Zt809lcJtj3 p{margin:0;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge{stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 text{fill:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon--1{font-size:40px;color:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge--1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth--1{stroke-width:17;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section--1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-0{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-0{stroke-width:14;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-1{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-1{stroke-width:11;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 text{fill:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-2{stroke-width:8;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-3{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-3{stroke-width:5;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-4{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-4{stroke-width:2;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-5{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-5{stroke-width:-1;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-6{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-6{stroke-width:-4;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-7{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-7{stroke-width:-7;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-8{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-8{stroke-width:-10;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-9{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-9{stroke-width:-13;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 polygon,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 text{fill:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .node-icon-10{font-size:40px;color:black;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge-depth-10{stroke-width:-16;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:lightgray;}#mermaid-svg-x0Rw8Zt809lcJtj3 .disabled text{fill:#efefef;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root rect,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root path,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root circle,#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root text{fill:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-root span{color:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .section-2 span{color:#ffffff;}#mermaid-svg-x0Rw8Zt809lcJtj3 .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-x0Rw8Zt809lcJtj3 .edge{fill:none;}#mermaid-svg-x0Rw8Zt809lcJtj3 .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-x0Rw8Zt809lcJtj3 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} STM32F103C8T6
定位
32位微控制器
Cortex-M3
72MHz
存储
64KB Flash
20KB SRAM
外设
GPIO与EXTI
TIM与PWM
ADC与DMA
USART
I2C与SPI
RTC与看门狗
硬件基础
3.3V供电
8MHz晶振
复位电路
BOOT配置
SWD下载
开发依据
数据手册
参考手册
标准外设库手册
11.1 一句话总结
STM32F103C8T6 是一颗以 Cortex-M3 为 CPU 内核、集成 Flash、SRAM、总线和多种外设的 32 位微控制器;学习 STM32 的主线就是理解并通过程序配置这些外设。
12. 复习问题
建议先遮住答案口述,再回到正文核对。
- Cortex-M3 和 STM32F103 的关系是什么?
- 为什么使用 GPIO、TIM、USART 等外设前一般要开启 RCC 时钟?
STM32F103C8T6中C、8、T、6分别表示什么?- Flash 与 SRAM 分别保存什么内容?掉电后有什么区别?
- APB1 和 APB2 各自挂载哪些常用外设?
- DMA 为什么能够减轻 CPU 负担?
- BOOT0=0 时从哪里启动?BOOT0=1、BOOT1=0 时呢?
- 最小系统包括哪些电路?
- 为什么 USB 的 5 V 不能直接给芯片供电?
- SWD 下载通常需要哪些信号?
12.1 动手任务
- 找到核心板上的 STM32F103C8T6、8 MHz 晶振和 32.768 kHz 晶振;
- 找到 BOOT0 跳线和复位按键;
- 在原理图中找到 3.3 V 稳压芯片和电源去耦电容;
- 在引脚定义表中找到 PA13/SWDIO、PA14/SWCLK、NRST;
- 打开数据手册,核对 Flash、SRAM、ADC、TIM、USART、I2C、SPI 数量;
- 用自己的话画出"CPU---总线---外设"的关系图。
13. 后续课程归档与学习路线
以下内容根据课程列表截图整理。当前只把 [1-2] STM32简介 标记为已学习,其余均作为待学习内容归档。
阶段 0:课程准备
[1-1]课程简介(11:28)[1-2]STM32 简介(49:02)✅ 已形成本文档[2-1]软件安装(16:45)[2-2]新建工程(42:15)
阶段 1:GPIO 与基础外设
[3-1]GPIO 输出(34:30)[3-2]LED 闪烁、LED 流水灯与蜂鸣器(39:10)[3-3]GPIO 输入(43:59)[3-4]按键控制 LED、光敏传感器控制蜂鸣器(33:05)[4-1]OLED 调试工具(14:01)[4-2]OLED 显示屏(19:55)
阶段 2:中断
[5-1]EXTI 外部中断(41:58)[5-2]对射式红外传感器计次与旋转编码器计次(49:31)
阶段 3:定时器、PWM 与测量
[6-1]TIM 定时中断(49:37)[6-2]定时器定时中断与定时器外部时钟(38:31)[6-3]TIM 输出比较(44:22)[6-4]PWM 驱动 LED 呼吸灯、舵机及直流电机(1:04:25)[6-5]TIM 输入捕获(38:55)[6-6]输入捕获测频率与 PWMI 测频率/占空比(35:27)[6-7]TIM 编码器接口(25:59)[6-8]编码器接口测速(21:04)
阶段 4:ADC 与 DMA
[7-1]ADC 模数转换器(48:46)[7-2]AD 单通道与 AD 多通道(49:01)[8-1]DMA 直接存储器存取(49:42)[8-2]DMA 数据转运与 DMA+AD 多通道(53:09)
阶段 5:USART 串口
[9-1]USART 串口协议(32:21)[9-2]USART 串口外设(39:51)[9-3]串口发送与串口发送+接收(1:00:01)[9-4]USART 串口数据包(20:29)[9-5]串口收发 HEX 数据包与文本数据包(26:27)[9-6]FlyMcu 串口下载与 ST-LINK Utility(22:00)
阶段 6:I2C 与 MPU6050
[10-1]I2C 通信协议(51:08)[10-2]MPU6050 简介(50:27)[10-3]软件 I2C 读写 MPU6050(1:03:32)[10-4]I2C 通信外设(45:07)[10-5]硬件 I2C 读写 MPU6050(49:41)
阶段 7:SPI 与 W25Q64
[11-1]SPI 通信协议(47:41)[11-2]W25Q64 简介(48:11)[11-3]软件 SPI 读写 W25Q64(55:06)[11-4]SPI 通信外设(45:30)[11-5]硬件 SPI 读写 W25Q64(26:39)
阶段 8:RTC、电源与低功耗
[12-1]Unix 时间戳(44:28)[12-2]BKP 备份寄存器与 RTC 实时时钟(44:43)[12-3]读写备份寄存器与实时时钟(52:06)[13-1]PWR 电源控制(45:53)[13-2]修改主频、睡眠模式、停止模式与待机模式(50:24)
阶段 9:可靠性与内部存储
[14-1]WDG 看门狗(40:08)[14-2]独立看门狗与窗口看门狗(32:00)[15-1]FLASH 闪存(46:18)[15-2]读写内部 FLASH 与读取芯片 ID(53:41)- 结束语(1:31)
13.1 推荐推进顺序
#mermaid-svg-yuKXZYoJl3W6XsZl{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-yuKXZYoJl3W6XsZl .error-icon{fill:#552222;}#mermaid-svg-yuKXZYoJl3W6XsZl .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-yuKXZYoJl3W6XsZl .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-yuKXZYoJl3W6XsZl .marker{fill:#333333;stroke:#333333;}#mermaid-svg-yuKXZYoJl3W6XsZl .marker.cross{stroke:#333333;}#mermaid-svg-yuKXZYoJl3W6XsZl svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-yuKXZYoJl3W6XsZl p{margin:0;}#mermaid-svg-yuKXZYoJl3W6XsZl .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster-label text{fill:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster-label span{color:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster-label span p{background-color:transparent;}#mermaid-svg-yuKXZYoJl3W6XsZl .label text,#mermaid-svg-yuKXZYoJl3W6XsZl span{fill:#333;color:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl .node rect,#mermaid-svg-yuKXZYoJl3W6XsZl .node circle,#mermaid-svg-yuKXZYoJl3W6XsZl .node ellipse,#mermaid-svg-yuKXZYoJl3W6XsZl .node polygon,#mermaid-svg-yuKXZYoJl3W6XsZl .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-yuKXZYoJl3W6XsZl .rough-node .label text,#mermaid-svg-yuKXZYoJl3W6XsZl .node .label text,#mermaid-svg-yuKXZYoJl3W6XsZl .image-shape .label,#mermaid-svg-yuKXZYoJl3W6XsZl .icon-shape .label{text-anchor:middle;}#mermaid-svg-yuKXZYoJl3W6XsZl .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-yuKXZYoJl3W6XsZl .rough-node .label,#mermaid-svg-yuKXZYoJl3W6XsZl .node .label,#mermaid-svg-yuKXZYoJl3W6XsZl .image-shape .label,#mermaid-svg-yuKXZYoJl3W6XsZl .icon-shape .label{text-align:center;}#mermaid-svg-yuKXZYoJl3W6XsZl .node.clickable{cursor:pointer;}#mermaid-svg-yuKXZYoJl3W6XsZl .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-yuKXZYoJl3W6XsZl .arrowheadPath{fill:#333333;}#mermaid-svg-yuKXZYoJl3W6XsZl .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-yuKXZYoJl3W6XsZl .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-yuKXZYoJl3W6XsZl .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-yuKXZYoJl3W6XsZl .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-yuKXZYoJl3W6XsZl .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-yuKXZYoJl3W6XsZl .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster text{fill:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl .cluster span{color:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-yuKXZYoJl3W6XsZl .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-yuKXZYoJl3W6XsZl rect.text{fill:none;stroke-width:0;}#mermaid-svg-yuKXZYoJl3W6XsZl .icon-shape,#mermaid-svg-yuKXZYoJl3W6XsZl .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-yuKXZYoJl3W6XsZl .icon-shape p,#mermaid-svg-yuKXZYoJl3W6XsZl .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-yuKXZYoJl3W6XsZl .icon-shape .label rect,#mermaid-svg-yuKXZYoJl3W6XsZl .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-yuKXZYoJl3W6XsZl .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-yuKXZYoJl3W6XsZl .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-yuKXZYoJl3W6XsZl :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 简介与工程
GPIO
OLED
EXTI
TIM / PWM / 捕获
ADC / DMA
USART
I2C / MPU6050
SPI / W25Q64
RTC / 低功耗
看门狗 / Flash
每一节建议形成以下闭环:
- 听课并保留原始转写;
- 提炼概念与配置步骤;
- 用师兄笔记纠正术语、补框图;
- 对照有注释版工程;
- 上板验证;
- 完成复习题和故障记录。
14. 资料索引
- 师兄手写笔记:
../STM32笔记.pdf - 有注释版课程工程:
../程序源码/STM32Project-有注释版/ - STM32F103C8T6 引脚定义:
../参考文档/STM32F103C8T6引脚定义.xlsx - 中文数据手册:
../参考文档/STM32F103x8B数据手册(中文).pdf - 中文参考手册:
../参考文档/STM32F10xxx参考手册(中文).pdf - Cortex-M3 编程手册:
../参考文档/STM32F10xxx Cortex-M3编程手册.pdf - 核心板原理图:
../模块资料/1-STM32F103C8T6核心板/STM32F103C8T6核心板原理图.pdf - 本节录音转写原文:
D:/2026-08-29 18_37 记录STM32介绍_原文.docx
本文以课程原始转写为讲解顺序,以师兄笔记、配套工程和项目内参考资料校正明显的语音识别错误。涉及精确电气参数、外设数量和引脚复用时,最终以对应芯片的数据手册和参考手册为准。