Skip to main content
Visitor II
December 2, 2020
Question

Need sample code / logic for melody generation on STM8S005 from beep function

  • December 2, 2020
  • 1 reply
  • 961 views

Hello , I am able to generate the different frequency tones using the beep function. Can anyone guide how to play musical tones let's say happy birthday song on piezo buzzer?

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    December 2, 2020

    The Standard Peripheral is currently using three fixed beep frequencies 1kHz, 2kHz and 4kHz, because that is often used for signalling using piezo transducers (buzzers).

    For more frequencies, e.g. for C major or other scales, the library must be changed accordingly but STMicroelectronics do not provide a ready-made library for this.

    Note: For a starting point please take a look at the SPL, especially stm8s_beep.c, stm8s_beep.h and the example BEEP_3SignalsGeneration that you may have already seen.

    Good luck!

    /Peter