STM32F030和STM32F103的IO结构上的区别

STM32F103GPIO  功能描述
每个GPI/O 端口有两个 32 位配置寄存器 (GPIOx_CRL GPIOx_CRH) ,两个 32 位数据寄存器
(GPIOx_IDR GPIOx_ODR) ,一个 32 位置位 / 复位寄存器 (GPIOx_BSRR) ,一个 16 位复位寄存
(GPIOx_BRR) 和一个 32 位锁定寄存器 (GPIOx_LCKR)
根据数据手册中列出的每个I/O 端口的特定硬件特征, GPIO 端口的每个位可以由软件分别配置成
多种模式。
─  输入浮空
─  输入上拉
─  输入下拉
─  模拟输入
─  开漏输出
─  推挽式输出
─  推挽式复用功能
─  开漏复用功能
每个I/O 端口位可以自由编程,然而必须按照 32 位字访问 I/O 端口寄存器 ( 不允许半字或字节访
) GPIOx_BSRR GPIOx_BRR 寄存器允许对任何 GPIO 寄存器进行读 / 更改的独立访问;这
样,在读和更改访问之间产生IRQ 时不会发生危险。
下图给出了一个I/O 端口位的基本结构。
13  I/O 端口位的基本结构

STM32F030 GPIO functional description
Subject to the specific hardware characteristics of each I/O port listed in the datasheet, each
port bit of the general-purpose I/O (GPIO) ports can be individually configured by software in
several modes:
•  Input floating
•  Input pull-up
•  Input-pull-down
•  Analog
•  Output open-drain with pull-up or pull-down capability
•  Output push-pull with pull-up or pull-down capability
•  Alternate function push-pull with pull-up or pull-down capability
•  Alternate function open-drain with pull-up or pull-down capability
Each I/O port bit is freely programmable, however the I/O port registers have to be
accessed as 32-bit words, half-words or bytes. The purpose of the GPIOx_BSRR and
GPIOx_BRR registers is to allow atomic read/modify accesses to any of the GPIOx_ODR
Figure 13. Basic structure of a standard I/O port bit


二者区别:

以上中文部分为103 系列,英文部分为 030 系列。两个系列从基本结构图上可以看到最大的差异就是上拉下拉电阻的位置有区别。
103 系列的上下拉只在输入通道有效, 030 系列的在输入和输出都有效,因此 030 系列在浮空输出时也可以使用上下拉电阻,在 103 系列单片机中浮空输出是不能使用上下拉的,必须使用外部电阻辅助。

这两个IO 的结构区别对实际使用有哪些影响呢?最大的区别就是 IO 作为双向 IO 使用时,设置为浮空输出, 103 系列必须外面配置上拉电阻,而 030 系列则可以直接配置为上拉开漏输出,把 IO 口作为双向 IO 使用,特别是在模拟 IIC 时序中使用最方便!


猜你喜欢

转载自blog.csdn.net/l18780079219/article/details/80551336