The running light is the first experiment that almost every development board comes into contact with. It is simple but indispensable.
Today, I will briefly explain how to use the firmware library to operate LED lights.
Hardware Connection:
software design:
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
// 1, enable the GPIO corresponding pin clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG ,ENABLE);
// 2, define GPIO pins
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // Push-pull output
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; // Maximum speed 50Mhz
GPIO_Init(GPIOD,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_Init(GPIOG,&GPIO_InitStructure);
GPIO_ResetBits(GPIOD,GPIO_Pin_13); // Set GPIO_D13 to low level
GPIO_SetBits(GPIOG,GPIO_Pin_14); // Set GPIO_D13 to high level
}
The above design can define the GPIO pins corresponding to the LED lights.
Set the pin to high or low level, call
GPIO_ResetBits(GPIOx,GPIO_Pin_x),
GPIO_SetBits(GPIOx,GPIO_Pin_x);
Function
Previous article:STM32 lighting + delay function (without UCOS2)
Next article:STM32_Firmware library creation project
Recommended ReadingLatest update time:2024-11-17 10:32
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Some knowledge points about low-frequency amplifiers
- MC33063A boost circuit, burning IC and electrolytic capacitor? With pictures, help!
- There are two questions about the frequency division circuit, as shown in the figure
- C51 demonstration program of nrf905 with number hopping, frequency hopping and address hopping
- Does TMS320C6748 support TFTP instance in stareware?
- Air conditioning temperature precise control circuit diagram
- Voltage acquisition circuit
- Copy board expert
- Problems with IO pin configuration when STM32 is low power
- Low-level error "while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == RESET)" infinite loop