STM32 Getting Started: Lighting

Publisher:haoyingLatest update time:2019-03-29 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Operation on pins:


E.g. light up the LED light:


1. First, you need to know the pins corresponding to the LED lights, find its module block diagram and clock tree in the datasheet of the corresponding chip, find the parent clock and turn it on. Then initialize it with the structure, and configure the corresponding parameters according to your needs during initialization. 


The clock tree of the ZET6 datasheet is as follows:


Module diagram:


2. Initialize it using the initialization function.


3. Find the schematic diagram and find out whether the component to be operated requires a high level or a low level. For example, the LED light here requires a high level, and the level can be raised through the void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) function.


If the component requires a low level, you can pull the level low through the void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin) function.


The level can also be set directly through bit operations.


Use the void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal) function to directly write all the level conditions of a module.


The operation is as follows:

For example, you want to set GPIO_Pin_10 to a high level.

You can use GPIO_SetBits(GPIOA,GPIO_Pin_10);

You can also use GPIO_WriteBit(0x01<<10);


Above code:

void Led_Init()

{

GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);

GPIO_Init(GPIOE, &GPIO_InitStructure);


}

Keywords:stm32 Reference address:STM32 Getting Started: Lighting

Previous article:STM32 IO configuration lighting
Next article:STM32 Review Notes (15) Infrared Remote Control

Recommended ReadingLatest update time:2024-11-22 21:12

stm32 uses the atomic delay function at the right time, and the main function delay fails
I recently discovered a phenomenon when I was working on something. I had never discovered it before, or I had never studied it carefully. I would like to share it with you. When using the delay function of Atom Brother, I found that the delay function in the main function was invalid. It did not work. The following
[Microcontroller]
STM32 external crystal oscillator 8M changed to 25M
Note: Modify F4 to stm32f4xx.h/system_stm32f4xx.c, modify F3 to stm32f10x.h/system_stm32f10x.c One of the modifications: HSE_VALUE in stm32f4xx.h, the system uses an external 8M crystal oscillator by default, so #define HSE_VALUE ((uint32_t)8000000), now change it to #define HSE_VALUE ((uint32_t)25000000)   Modifi
[Microcontroller]
STM32_SPI master-slave communication
Today I will explain "STM32F103 SPI master-slave communication". I originally planned to explain this part later (the second stage) to meet a netizen's question "About SPI communication between two MCUs", so I specially explained it in advance today. Since yesterday we talked about "SPI reading and writing Flash", MCU
[Microcontroller]
STM32_SPI master-slave communication
STM32 Learning Path (VI) - AD Conversion
        ADC input channel management mode can be divided into rule group and injection group. Rule group refers to normal conversion; injection group is triggered by external trigger or software, interrupting normal rule group conversion. Rule group can be a single channel or a combination of several channels. The conv
[Microcontroller]
stm32 nRF24L01 wireless module (1): SPI2 to SPI1 migration
    I was going to write the tick timer next, but I struck while the iron was hot and wrote the port from SPI2 to SPI1.     Why should the migration from SPI2 to SPI1 be written in the nRF24L01 module? Because the most important data transmission of the wireless module is realized through SPI. Why is the migration nec
[Microcontroller]
stm32 nRF24L01 wireless module (1): SPI2 to SPI1 migration
Introduction to STM32 low power mode
The STM32F10xxx has three low-power modes: ●Sleep mode (Cortex?-M3 core stops, peripherals are still running) ●Stop mode (all clocks are stopped) ●Standby mode (1.8V power supply is turned off)   When the clock frequency is 72MHz and the code is executed from the flash memory, the STM32 consumes 36mA, which is t
[Microcontroller]
Introduction to STM32 low power mode
Design of intelligent motor protector based on STM32
0 Introduction Motors are the main driving source in the field of industrial production. How to effectively monitor the operating status of motors, protect motor circuits, increase motor operating time, and reduce motor failures is critical to the operation of the factory's overall power grid. There ar
[Microcontroller]
STM32 CAN communication
CAN communication using stm32: 1. Initialization,     1) Including pin initialization    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;    GPIO_Init(GPIOA, &GPIO_InitStructure);         GPIO_InitStructure.GPIO_Pin = GP
[Microcontroller]
Latest Microcontroller Articles
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号