STM32_Firmware library operates LED lights

Publisher:会弹琴的鲸鱼3312Latest update time:2017-11-01 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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:

STM32_Firmware library operates LED lights

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


Keywords:STM32 Reference address:STM32_Firmware library operates LED lights

Previous article:STM32 lighting + delay function (without UCOS2)
Next article:STM32_Firmware library creation project

Recommended ReadingLatest update time:2024-11-17 10:32

STM32 interrupt priority and library function to turn on and off total interrupt
1. Interrupt priority: The concept of priority in STM32 (Cortex-M3) There are two concepts of priority in STM32 (Cortex-M3) - preemptive priority and response priority. Some people call response priority "sub-priority" or "sub-priority". Each interrupt source needs to be assigned these two priorities. An interrupt
[Microcontroller]
stm32 timer response time calculation
Take TIM3_Int_Init(u16 arr,u16 psc) as an example: (st standard library) arr: automatic reload value psc: clock pre-scaling factor arr has four counting methods: plus 1, minus 1, plus-minus, minus-plus. (single or multiple) To calculate the time, you must know the clock source frequency F of the microcontroll
[Microcontroller]
stm32 timer response time calculation
STM32 uses FSMC to control NAND flash routine
Recently, the development project needs to use STM32 to drive NAND FLASH, but because the development board routines and firmware library are for small pages (512B), the FLASH I need to use is 1G bit large page (2K), which took two more days of detours. The following notes will explain how to modify the default firmwa
[Microcontroller]
STM32 USB Mass Storage example debugging notes
1. Cause of the problem       Recently, several customers reported that the USB Mass Storage routine of the STM3210E development board had some problems. The team leader assigned me to debug. The Mass Storage routine implements two USB disks on the PC, one is an SD disk and the other is a NAND Flash disk. After downlo
[Microcontroller]
STM32 USB Mass Storage example debugging notes
A thorough study of the CAN bus based on stm32
1. Initialization of CAN bus void can_init(void) {       CAN_InitTypeDef        CAN_InitStructure;       CAN_FilterInitTypeDef  CAN_FilterInitStructure;       /* CAN register init */       CAN_DeInit();       CAN_StructInit(&CAN_InitStructure);            /* CAN cell init */       CAN_InitStructure.CAN_TTCM=
[Microcontroller]
A thorough study of the CAN bus based on stm32
STM32 clock system review
1. References         "STM32F1 Development Guide - Library Function Version" - Section 4.3 Clock System         "STM32 Chinese Reference Manual V10" - Chapter 6 Reset and Clock Control RCC 2. Clock system summary      1. STM32 has 5 clock sources: HSI, HSE, LSI, LSE, and PLL.          ①. HSI is a high-speed internal
[Microcontroller]
【STM32】STM32 firmware library (standard peripheral library)
Standard Peripheral Library Overview The STM32 standard peripheral library is a firmware function package that consists of programs, data structures and macros, including the performance characteristics of all peripherals of the microcontroller. The library also includes driver descriptions and application examples fo
[Microcontroller]
【STM32】STM32 firmware library (standard peripheral library)
STM32 library function USART_SendData problem and solution
1. Problems and Phenomena There is no problem in using USART_SendData() function to send single characters non-continuously; when sending characters continuously (no delay between two characters), the sending buffer will overflow. If the amount of data sent is very small, the serial port will only send the last char
[Microcontroller]
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号