STM32F030和STM32F103的IO结构上的区别

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

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

STM32F030和STM32F103的IO结构上的区别

二者区别:

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

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