cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RE-How to generate any sound using PWM

biswajitjobapp
Associate II
Posted on February 07, 2014 at 15:12

Hello Everyone,

I am totally new to the world of embedded systems. Please pardon me if my question is too simple.

I have been asked to generate any kind of sound on a small speaker(needs to be attached to the STM32F103RE board)..The main point would to use the PWM of the STM32.

I am willing to investigate myself,but I haven't got any head or toe where to start.Please explain as if you are explaining a layman. Thanks a lot...

A beer on me!!!
5 REPLIES 5
Posted on February 07, 2014 at 15:30

Homework?

''Any sound using PWM'' may mean two things:

- using PWM as a form of output toggle to create square-wave sound

- or using PWM as a DAC replacement to create any waveform

The former is simpler, you simply set the timer to audible frequency and set PWM to say 50%.

STM32F10x_StdPeriph_Lib_V3.4.0\Project\STM32F10x_StdPeriph_Examples\TIM\ contains PWM examples.

Google is your friend.

JW

Posted on February 07, 2014 at 21:32

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/How%20can%20create%20a%20tone%20with%20timer&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=51]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fHow%20can%20create%20a%20tone%20with%20timer&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FAllItems%2Easpx¤tviews=51

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
biswajitjobapp
Associate II
Posted on February 11, 2014 at 13:13

Hi..

Yes its homework sort of....

thanks for your support.I am still on it..Using elua...have set duty cycle to 50% , and setting the audible frequency to about 10,000 HZ,selected the channel and the frequency..no results yet..let me check if we can have any alternative solution...will post it once found..cheerss!!

chen
Associate II
Posted on February 11, 2014 at 13:22

Hi

''I have been asked to generate any kind of sound on a small speaker(needs to be attached to the STM32F103RE board).''

The STM32 output will not be able to drive a speaker directly. You will need an amplifier of some kind.

You may actually be getting an output, just you cannot hear it because the output port does not have enough drive to work the speaker.

Do you have access to an oscilloscope?

biswajitjobapp
Associate II
Posted on February 11, 2014 at 13:37

Thanks clive1.....indeed a lot of info available in the forum..let me have a thorough look..cheerss