Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of STM32 GPIO?

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what is the use of STM32 GPIO for you. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

01, Icano interface circuit

The circuit block diagram with FT shows that it can tolerate 5V voltage.

1.1. General input

In normal input mode, the pull-up and pull-down resistors (weak) exist, which are divided into three modes.

Floating input, do not enable pull up resistor, do not enable pull down resistor

Pull up the input to enable the pull up resistor

Pull down the input to enable the pull down resistor

From the block diagram above, output caching is prohibited

1.2, normal output

In normal input mode, pull-up and pull-down resistors (weak) exist. Mainly due to the existence of P-MOS and N-MOS, there are two modes

Open-drain mode: when the output register is 0, N-MOS is activated, and when the output register is 1, the port remains in high resistance state (P-MOS will not be enabled)

Push-pull output: activate N-MOS when the output register is 0 and activate P-MOS when the output register is 1

From the block diagram above,

1. In the normal output mode, the TTL Schmidt trigger is turned on, so you can read the input data register to get the status of Ibank O.

2. To drive GPIO output, we can use either the output register or the bit segment

1.3, analog input

Analog input pull-up resistors and pull-down resistors are useless

Analog input in high resistance state

It is known from the block diagram above

Weak pull-up and pull-down resistors are prohibited

Schmidt trigger is disabled, and the output value of Schmidt trigger is forced to 0

Output caching is prohibited

Read the input data period register, the value read is 0

Note: 5V voltage cannot be tolerated when IO is configured for analog input

1.4, reuse output

Multiplexing output block diagram

Five pieces of information can be obtained from the frame above.

The output cache is driven by signals from the peripheral (sending data enabled and data), that is, bit setting / clearing registers and output data registers are useless here.

Due to P-MOS and N-MOS enabled, it can still be configured for push-pull output and open-leak output.

Pull-up and pull-down resistors enable and can be configured

TTL Schmidt trigger enable

By reading the input data register, you can get the status of Igamo.

02. Pin reuse and remapping

Pin reuse and remapping (actually the same thing), STMF10X series is called remapping, STMF20X series is called pin reuse, that is, reuse function

2.1and STMF10X series

There are a lot of Imax O ports on STM32, and there are also a lot of built-in external ideas such as I2C, ADC, and IPC, etc. In order to save the lead-out pins, these built-in peripherals basically share pins with Imax O ports, that is, the multiplexing function of IAccord O pins. But there is another special thing about STM32: many Imax O pins that reuse built-in peripherals can be led out from different Imax O pins through the remapping function, that is, the pins of the reuse function can be changed by program.

STM32F103VCT6 CPU USART1 is connected to PB6/PB7, but the default function is not USART1 after power-on initialization. So want to use serial port function. You must remap with a port.

Each function module of STM32 single chip microcomputer has its own clock system, so if you want to call the function module of STM32 single chip microcomputer, you must configure the corresponding clock first, and then you can operate the corresponding function module. The same is true of port remapping. As shown in the figure:

The remapping steps are:

1. Turn on the remap clock and the USART O-port pin clock after remapping

RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO,ENABLE)

2.I/O mouth remapping is on.

GPIO_PinRemapConfig (GPIO_Remap_USART1,ENABLE)

3. To configure the remapping pin, you only need to configure the remapped Iripple O, not the original one.

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init (GPIOB,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;GPIO_Init (GPIOB,&GPIO_InitStructure); 2.1, STMF20X series

The STMF20X series (including the following 40 series) has no remapping, only a unified so-called reuse function.

From the above picture, we can see that the F10X series will have special ordinary IO registers and multiplexing registers. The library functions are as follows:

Void GPIO_PinRemapConfig (uint32_t GPIO_Remap, FunctionalStateNewState)

From the figure above, F20X series uses multiplexing function registers, but unlike F10 series with special multiplexing registers, F20X series GPIO multiplexing has a wider range of functions.

Note: first configure GPIO to reuse function, then call the reused library function

F20 series: there are four functions of GPIO

Typedef enum {GPIO_Mode_IN = 0x00, / *! < GPIO Input Mode * / GPIO_Mode_OUT = 0x01, / *! < GPIO Output Mode * / GPIO_Mode_AF = 0x02, / *! < GPIO Alternate function Mode * / GPIO_Mode_AN = 0x03 / *! < GPIO Analog Mode * /} GPIOMode_TypeDef

GPIO statu

Push-pull output

Can output high and low level, connect digital devices.

Open-leak output

Can only output strong low level, high level needs external resistance to pull up, the output end is equivalent to the collector of Triode, to get high level, need pull-up resistance, suitable for current mode drive, its absorption current negligence is relatively strong (generally within 20ma)

High resistance state

High-resistance state is a common term in a digital circuit, which refers to an output state of the circuit, which is neither high-level nor low-level. If the high-resistance state is input into the next-stage circuit, it will have no effect on the lower-level circuit, just as it is not connected. If measured with a multimeter, it may be high-level or low-level, depending on what follows it. If it is set to floating input, that is, there is no pull-up resistance and no pull-down resistance. It can be considered as a high resistance state.

This is the end of this article on "what's the use of STM32 GPIO". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report