STM8L051 buzzer beep--library function version (not using TIM2 to calibrate LSI)

Publisher:星际穿越Latest update time:2020-01-15 Source: eefocusKeywords:STM8L051 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The buzzer pin of STM8L051 shares the same pin with the swin debugging port. Although the debugging function cannot be used when beep is used (after the program is downloaded, disconnect the debugging swin and restart it to output), the program can still be burned into the MCU. (**Note** You can use the beep function without setting the option bit)


Here is the code for the library function:

void BeepInit()

{

  // BEEP_LSClockToTIMConnectCmd(ENABLE);

   CLK_PeripheralClockConfig(CLK_Peripheral_BEEP,ENABLE);

  // BEEP_LSICalibrationConfig(38000);

   CLK_BEEPClockConfig(CLK_BEEPCLKSource_LSI);

   BEEP_Init(BEEP_Frequency_1KHz);

   BEEP_Cmd(ENABLE);

}

Keywords:STM8L051 Reference address:STM8L051 buzzer beep--library function version (not using TIM2 to calibrate LSI)

Previous article:STM8L051 ADC+DMA two-channel data sampling misalignment problem
Next article:stm8L051 uses the library to build a project

Recommended ReadingLatest update time:2024-11-23 15:17

STM32 timer realizes PWM output control of passive buzzer (HAL)
1. PWM concept and principle Pulse Width Modulation (PWM), short for "Pulse Width Modulation", is a very effective technology that uses the digital output of a microprocessor to control analog circuits. PWM principle diagram The figure above is a simple PWM principle diagram. In the figure, we assume that the t
[Microcontroller]
STM32 timer realizes PWM output control of passive buzzer (HAL)
ARM4412 bare board drives LED lights, buttons, and buzzers
First find the circuit diagram of the board, taking LED as an example Next is the circuit's network label: Find the register description in the corresponding chip manual The LED light is operated by operating the corresponding register: First, register the corresponding register address into a file: reg.h   1
[Microcontroller]
ARM4412 bare board drives LED lights, buttons, and buzzers
51 MCU button control buzzer start and stop program
51 MCU button control buzzer start and stop program #include reg52.h #define uint unsigned int //macro definition sbit SPK=P3^5; //define speaker port sbit key=P3^1; //The corresponding key on the development board is s18 void delay(uint z) { uint x,y; for(x=z;x 0;x--) for(y=110;y 0;y--); } void main() { while(1)
[Microcontroller]
STM8L051 RTC write time failed
I recently used STM8L051 to do a low-power project. I needed to synchronize the time between two nodes. As a result, the RTC did not wake up the microcontroller at the set time. At first, I thought it was because the crystal oscillator had too much error. I accidentally found that the time interval between the two wak
[Microcontroller]
Learning MCU from Scratch (VIII) Buzzer Singing
The structure of the buzzer on the microcontroller is very simple As long as you give it a 0, it will "call". The principle of making it sing is very simple. The volume of the sound is fixed. By changing its frequency, it can make it produce different notes. In the code, during the software loop delay process, a
[Microcontroller]
Learning MCU from Scratch (VIII) Buzzer Singing
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号