2019-04-18 10:44 PM
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
2019-04-18 11:39 PM
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.
2019-04-19 01:14 AM
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
2019-04-19 02:42 AM
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.
2019-04-19 03:29 AM
Hi @Ozone ,
Thanks for your quick responses.
I have gone through the all the available example other code too, to get the functionality.
How ever luckly I have developed one of the code for the same but Here I facing issue that how do I control the volume of the buzzer.
I developed function in which I am passing value and basis on value it make buzzer buzz.
Now I am looking for the Volume and tone generation functionality.
Thanks in advance
Best Regards
2019-04-23 03:06 AM
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
2019-04-23 04:32 AM
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.
2019-04-23 05:15 AM
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
2019-04-23 05:28 AM
Some suggestions for the GPIO:
I have my reason for not divulging into CubeMX, so my experience with it is close to zero.
But the F030 is a quite mature design, and the SPL + SPL-based discovery firmware still around. I suppose you can find some code examples there as well.
2019-04-23 05:30 AM
I didn't get you ??
I have have used PA4 (TIM_CHANNEL_1)