STM32 IO port initialization process

Publisher:静逸闲云Latest update time:2018-08-12 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

First initialize the clock APB2

1. Configure input/output mode and pin speed (GPIOx_CRL or GPIOx_CRH)



2. Read or write IO port data

    2.1 Read IO port data (GPIOx_IDR)



    2.2 Write IO port data (GPIOx_ODR, GPIOx_BSRR, GPIOx_BRR) 

   



3. Lock the IO port data until the next reset (GPIOx_LCKR)





Keywords:STM32 Reference address:STM32 IO port initialization process

Previous article:STM32 Learning Notes - Initial Settings of Serial Port
Next article:The difference between STM32F103 and STM32F105 in serial port initialization

Recommended ReadingLatest update time:2024-11-16 16:31

STM32 remapping and address mapping
Remap In stm32, some ports' peripherals have been used by other pins. In this case, port remapping is needed to solve the problem, which is very convenient. Take USART1 as an example  The steps for remapping are: Turn on the remapped clock and the USART remapped I/O port pin clock,  RCC_APB2PeriphClockCmd(RCC_APB2
[Microcontroller]
STM32 remapping and address mapping
STM32SPI read and write functions
//SPIx read and write a byte //TxData: Bytes to be written //Return value: the bytes read u8 SPIx_ReadWriteByte(u8 TxData) {                                                                        while((SPI1- SR&(1 1))==0);                     SPI1- DR=TxData; //Send a byte                    while((SPI1
[Microcontroller]
KeilMDK4.22 compiles STM32 project warning: warning: #223-D
Build the project and compile a lot of errors and warnings: ..\FWlib\src\stm32f10x_usart.c(135): warning:  #223-D: function "assert_param" declared implicitly ..\FWlib\src\stm32f10x_usart.c:     assert_param(IS_USART_ALL_PERIPH(USARTx)); ..\FWlib\src\stm32f10x_usart.c:     ^ ..\FWlib\src\stm32f10x_usart.c(184): warni
[Microcontroller]
KeilMDK4.22 compiles STM32 project warning: warning: #223-D
STM32 GPIO register introduction and settings
Each GPIO port has two 32-bit configuration registers (GPIOx_CRL, GPIOx_CRH) to control the high and low eight bits of each port respectively. If the IO port is 0-7, write the CRL register, if the IO port is 8-15, write the CRH register, two 32-bit data registers (GPIOx_IDR, GPIOx_ODR), one is read-only as input data
[Microcontroller]
Significance of assert_param function
In the STM32 firmware library and the provided routines, assert_param() can be seen everywhere. If you open the stm32f10x_conf.h file in any routine, you can see that assert_param is actually a macro definition; in the firmware library, its function is to detect whether the parameters passed to the function are valid
[Microcontroller]
57. STM32 CAN controller principle and configuration
1. Introduction to STM32 CAN controller - bxCAN What is bxCAN: STM32 comes with a basic extended CAN peripheral, also known as bxCAN. The F103 has up to 14 filter banks, the F407 has 28. (II) Introduction to the modes of the STM32 CAN controller Working mode: It must be in initialization mode at the beginning to
[Microcontroller]
57. STM32 CAN controller principle and configuration
STMicroelectronics releases security software to protect STM32 edge AI devices connected to AWS IoT Core
New developer software for STM32H5 simplifies secure connections between IoT devices and AWS using ST’s Secure Manager software October 10, 2023, China - STMicroelectronics (STMicroelectronics), a world-leading semiconductor company serving multiple electronic applications, recently ad
[Embedded]
STMicroelectronics releases security software to protect STM32 edge AI devices connected to AWS IoT Core
STM32 printf semihost mode
After reading the problem of printf function redirection in the usart section of Atom Brother, I tried it myself. The microcontroller can print information through the serial port, and the printf function is very convenient to use after redirection. Redirection refers to modifying the underlying function of printf s
[Microcontroller]
STM32 printf semihost mode
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号