STM32F429IGT6 register map lights up the LED

Publisher:sedsedqLatest update time:2019-02-18 Source: eefocusKeywords:STM32F429IGT6 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The schematic diagram is as follows (taking the LED light connected to the PH10 pin as an example)



We only need to give the PH10 pin a low level, then the LED will light up.


The internal GPIO schematic is shown in the figure. The red arrow indicates the GPIO output direction. As long as data is written to the set/reset register, the data will be transferred to the output data register (or the output data register can be directly assigned a value), and then the high and low levels will be output through the push-pull output circuit.



First configure the registers related to the PH10 pin (register map)


By referring to the reference manual of stm43f4, the relevant register mapping is as follows (the function of each register will be discussed below)



Next, configure the relevant registers in the following order


1. GPIO mode


First, we configure the PH10 pin connected to the LED light to output mode, that is, configure the GPIO MODER register, which contains pins 0-15, and each pin occupies 2 register bits. When these two register bits are set to "01", it is the GPIO output mode.



2. Output Type


GPIO output has two types: push-pull and open-drain. We know that the open-drain type cannot directly output high level. To output high level, a pull-up resistor must be connected to the chip externally, which does not conform to our hardware design, so we directly use the push-pull mode. Configure the OTYPER10 register bit in the OTYPER register. When this bit is set to 0, the PH10 pin is in push-pull mode.



3. Output speed


The output speed of the GPIO pin is the highest frequency that the pin supports high and low level switching, which can be set at will in this experiment. Here we configure the register bit OSPEEDR10 in the OSPEEDR register to control the output speed of PH10.



4. Pull-up/pull-down mode


When the GPIO pin is used for input, the pull-up/pull-down mode of the pin can control the default state of the pin. But now our GPIO pin is used for output, and the pin is affected by the ODR register. The default value of the ODR register corresponding to the pin bit is 0 after initialization, and the pin outputs a low level, so at this time, we configure the pull-up/pull-down mode will not affect the pin level state. However, since the pull-up here can slightly increase the current output capability, we configure it to the pull-up mode, that is, configure the PUPDR10 bit of the PUPDR register and set it to the binary value "01".



5. Control pin output level


In output mode, the level state of the pin can be controlled by writing parameters to the BSRR register or ODR register.



6. Enable peripheral clock


After setting the GPIO pins and controlling the level output, you may think that you can finally light up the LED, but there is actually one last step left.


In the peripheral chapter of "STM32 Chip Architecture", it is mentioned that STM32 has many peripherals. In order to reduce power consumption, each peripheral corresponds to a clock. These clocks are turned off when the chip is just powered on. If you want the peripheral to work, you must turn on the corresponding clock.


The clocks of all peripherals of STM32 are managed by a special peripheral called RCC (reset and clockcontrol), which is described in Chapter 6 of the STM32 Chinese Reference Manual. All GPIOs are mounted on the AHB1 bus, so their clocks are controlled by the AHB1 peripheral clock enable register (RCC_AHB1ENR), where the clock of the GPIOH port is enabled by writing 1 to bit 7 of the register, turning on the GPIOH port clock.


The specific code implementation is as follows


Keywords:STM32F429IGT6 Reference address:STM32F429IGT6 register map lights up the LED

Previous article:How to create a new stm32 firmware library project
Next article:Keil5 compiles successfully but there is a red cross

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号