1. 程式人生 > >STM32F030和STM32F103的IO結構上的區別

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 GPIO functional descriptionSubject to the specific hardware characteristics of each I/O port listed in the datasheet, eachport bit of the general-purpose I/O (GPIO) ports can be individually configured by software inseveral 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 capabilityEach I/O port bit is freely programmable, however the I/O port registers have to beaccessed as 32-bit words, half-words or bytes. The purpose of the GPIOx_BSRR andGPIOx_BRR registers is to allow atomic read/modify accesses to any of the GPIOx_ODRFigure 13. Basic structure of a standard I/O port bit


二者區別:

以上中文部分為103系列,英文部分為030系列。兩個系列從基本結構圖上可以看到最大的差異就是上拉下拉電阻的位置有區別。103系列的上下拉只在輸入通道有效,030系列的在輸入和輸出都有效,因此030系列在浮空輸出時也可以使用上下拉電阻,在103系列微控制器中浮空輸出是不能使用上下拉的,必須使用外部電阻輔助。
這兩個IO的結構區別對實際使用有哪些影響呢?最大的區別就是IO作為雙向IO使用時,設定為浮空輸出,103系列必須外面配置上拉電阻,而030系列則可以直接配置為上拉開漏輸出,把IO口作為雙向IO使用,特別是在模擬IIC時序中使用最方便!