It should be noted that when using the template of the library function, you cannot apply the register operation randomly. I wanted to use a big move before but ended up making a fool of myself. The experimental requirements here are that the green light is on and the buzzer sounds, the red light is on and the buzzer stops, and the buzzer sounds every half a second. I will not give the LED file here, but mainly release the beep file. The PF8 port is operated here.
1.beep.h
#ifndef __BEEP_H
#define __BEEP_H
#include "sys.h"
#define BEEP PFout(8)
void beep_init(void);
#endif
2.beep.c
#include "beep.h"
void beep_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_8);
}
3.main.c
#include "stm32f4xx.h"
#include "usart.h"
#include "delay.h"
#include "led.h"
#include "beep.h"
int main(void)
{
uart_init(115200);
delay_init(84);
led_heat();
beep_init();
while(1){
GPIO_ResetBits(GPIOF, GPIO_Pin_9);
GPIO_SetBits(GPIOF, GPIO_Pin_10);
GPIO_ResetBits(GPIOF, GPIO_Pin_8);
delay_ms(500);
GPIO_SetBits(GPIOF, GPIO_Pin_9);
GPIO_ResetBits(GPIOF, GPIO_Pin_10);
GPIO_SetBits(GPIOF, GPIO_Pin_8);
delay_ms(500);
}
}
Previous article:STM32 study notes 2——GPIO lighting
Next article:Light up LED lamp using buttons based on STM32
Recommended ReadingLatest update time:2024-11-23 16:43
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Application of LabVIEW in the production of wiper motors for Volkswagen Bora A4 cars
- 【Child care machine】+ ESP32S3-BOX factory_demo source code download, compilation and flashing process record
- TMS320C55x Chip Support Library API Reference Guide
- Regarding video equalizer, please answer a few common sense questions.
- EEWORLD University----UCD3138 Digital PWM (DPWM) Module
- C8051F TCPIP source program
- 【ESP32-C3-DevKitM-1】ESP32-C3 gets network time
- A brief introduction to communication principles
- The company is recruiting LAYOUT hardware engineers. Not an agency.
- The analog signal is divided into two paths for signal processing!