EasyManua.ls Logo

STMicroelectronics STM8 - Page 43

STMicroelectronics STM8
126 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
{
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

Related product manuals