STMicroelectronics STM8 Manual page 43

Table of Contents

Advertisement

{
BEEP_DeInit();
BEEP_LSICalibrationConfig(128000);
BEEP_Init(BEEP_FREQUENCY_2KHZ);
}
Explanation
As stated earlier beeper module is dependent on the AWU module and so we need to enable this
module's peripheral clock:
CLK_PeripheralClockConfig(CLK_PERIPHERAL_AWU, ENABLE);
We need to set the beeper port pin as an output pin:
GPIO_Init(GPIOD, GPIO_PIN_4, GPIO_MODE_OUT_PP_HIGH_FAST);
Configuring the beeper is straight. Just like other peripherals, we deinitialize it first and set both LSI
and beep frequency. Optionally we can calibrate the LSI.
void beeper_setup(void)
{
BEEP_DeInit();
BEEP_LSICalibrationConfig(128000);
BEEP_Init(BEEP_FREQUENCY_2KHZ);
}
To activate/deactivate the beeper we need to use the following instructions:
BEEP_Cmd(ENABLE);
BEEP_Cmd(DISABLE);
Demo
Video link:
https://www.youtube.com/watch?v=LDPtULsJao8

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM8 and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF