Skip to main content
K_P_D
Associate III
April 19, 2019
Question

STM32F030 Buz

  • April 19, 2019
  • 2 replies
  • 2376 views

Hi,

I am working on the STM32F030C6 MCU to develop the alarm Buzzer tone generation.

I need to buzz the buzzer with different melody tones and also need to control it Volume.

Can anyone please share and suggest me how do we achieve the above functionality.

Thanks

This topic has been closed for replies.

2 replies

Ozone
Principal
April 19, 2019

PWM.

Or, if you wonna be wasteful, a timer interrupt where you count periods and set the buzzer GPIO.

Your tag selection seems rather random.

K_P_D
K_P_DAuthor
Associate III
April 19, 2019

Hi @Ozone​ ,

After some online search reading I come to about TIM14, in which I am using Channel 1 as PWM. And I have connected the Buzzer with transistor.

I am looking for a tone() function through which I can pass the value and buzz the buzzer with different melody tones.

So, Is their any functionality available in STM HAL API's. It will great of your if can share something about the same get buzzer tone().

Many Thanks

Ozone
Principal
April 19, 2019

Not a HAL user, sorry. I think Cube comes with examples, look there.

But in general, setting a fixed PWM facor of, say, 50% and change the frequency (timer value) according the desired buzzer frequency.

K_P_D
K_P_DAuthor
Associate III
April 23, 2019

Hi @Ozone​ ,

Can help me, in the above tim14 code to generate the PWM for buzzer.

I am looking buzz the buzzer at every one second (On & Off at every second alternatively).

So, Can you please let me know about the same that how do I set the timer parameters to achieve it.

(My clock source is 8Mhz to TIMER ABP block )

Looking for your response ...

Thanks

Ozone
Principal
April 23, 2019

Not much experience with the F03x, nor with PWM timers.

But PWM needs GPIO resources, i.e. pins(s) to output the PWM signal. Can't see any related code. PWM is, AFAIK, an alternative function (AF) of a GPIO, like AIN or UART Tx/Rx.

Perhaps check the Cube PWM examples. You should be able to measure the signal on the specified pins.

K_P_D
K_P_DAuthor
Associate III
April 23, 2019

Hi @Ozone​ 

Yes, I have already checked but I didn't get required that's main issue from various available examples.

It will be great if you STM guys can help for the buzzer with PWM generation at 50% duty cycle (to beep at every 1 sec).

Looking forward for response ...

Many Thanks & Regards