This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DK-TM4C129X: Unable to play sound through speaker

Part Number: DK-TM4C129X

Hello

I am using the DK-TM4C129X board. I wanted to generate a 'buzzer' sound from the on-board speaker, i.e. a single frequency sound for 5 seconds. I checked the 'synth' example for the same. I used the following functions:

SoundInit(g_ui32SysClock);
SoundVolumeSet(255);
SoundStart(g_pi16AudioBuffer, AUDIO_SIZE, 64000, SoundCallback);

AUDIO_SIZE is 2048

But on executing the program, there is no output from the speaker. 

I just want to generate a plain 'beep' sound. 

Any help would be greatly appreciated.

Thanks & regards

Yash Bhan

  • Yash,
    Did you properly configure the output pin where the speaker is connected to?
    Can you see on the scope a wave coming out of such pin?
    If not, maybe you should try first to simply generate a square wave output on that pin - even a closed loop with wait() - simply to make sure your hardware is working, and your GPIO is all set.
    Only then I recommend you make use of "misterious" libraries such as these SoundXXXX - unless you do have all the documentation and/or understanding of such API requirements.
    Bruno
  • Hello Bruno

    I did as you told, generated a square wave output on the pin, using an infinite loop, i could hear slight noise from the speaker, which means that the speaker is configured with the output pin, however, i want to generate a simple 'beep' sound, wanted to know if there is a way for doing that, if a sample code is available or a library, it would be very helpful.

    Thanks & Regards
    Yash Bhan
  • Yash,

    There are two completely separate issues that you need to verify: one is on your hardware, the other is on any more elaborate software approach.

    For hardware, you say "you can hear a slight noise from the speaker". That means there is a lot to fix still...

    - Is there a driver/amplifier between your mcu and the speaker? What sort of spearker are you talking about? Did you check the driving requirements so that it makes sound?

    - You need an oscilloscope! How do you plan to see the electric signal? You can even invest on a low cost PC based one, or use the schools scope, but you won't be able to properly learn/solve anything without one.

    - Hardware/electric levels solved, inject a 4KHz square wave into your speaker - even if it is a low quality buzzer, it will still sound!

    - Only then, you can venture into more complex audio software solutions. You can control your audio output with PWM, or even use complex variations (learn PCM audio). There are several examples on the web, and they don't need to be related to TM4C - they are just audio software solutions that can be applied to mostly any processor.

    Regards

    Bruno

  • In general you are providing great service during this notable,  "Reduced Vendor Appearance."   (or to be (especially) poetic & linking, "A Vendor Drought!")   (decent forum would immediately award 5 "Likes" - just for that interleave!   You may "start" that process...)

    That said, your statement,  

    Bruno Saraiva said:
    You need an oscilloscope! ... you won't be able to properly learn/solve anything without one

    That's quite an overreach - is it not?   (one from which (even) your piloting skills - may not enable a full escape)

    Clearly an O-Scope provides great value - yet lowly LEDs prove excellent indicators of signal presence/absence.    And that "qualifies" as learning - negating an excessive claim.

    Today's powerful IDEs prove spectacular learning aids as well - the ability to, "Break Code Runs - then view & read multiple Registers, Memory Locations, & GPIO" as just one example - surely provides learning and very often solutions...

    *** Now to the poster's issue - in general your suggestions are fine - yet poster noted that the "Speaker" was, "On Board" (i.e. poster: "generate a 'buzzer' sound from the on-board speaker") - thus we must assume that it is proper - and likely too - properly driven.   

    When such focused, additional hardware appears upon an Eval Board - most always - software support (i.e. code examples) ARE INCLUDED!    Has our poster properly searched - checked for these - (that) seems a very wise beginning...

  • cb1_mobile said:
    yet lowly LEDs prove excellent indicators of signal presence/absence

    OP says he "hears a click on the speaker" - probably means a steady "ON" signal is driving it. A LED or a voltmeter (better than a led if the aim is to indicate signal presence/absence) would be lit - and still, the speaker won't sound. A LED with a 4KHz square wave into it will also lit - surely a bit less bright, but not all environments will allow to tell the difference.

    Can you really develop anything related to audio without a scope? Maybe if you limit the voltage signal somehow, and apply the audio analog signal into a PC audio IN port and visualize the (again, signal) on a freeware Audacity audio editor?

    I will overreach even further: the general posting guidelines should add an entry: "Get yourself an oscilloscope before posting!"

    As for the speaker driving, maybe it is a proven expansion board compatible to his launchpad... maybe it isn't - I couldn't tell from the quick reading. Apparently, poster has searched for the supporter's solution - he has even mentioned functions like SoundInit(g_ui32SysClock); - which does seem to be part of someone's eval package.

  • Hello Yash,

    I would suggest that you look at the synth example for the usage of the sound libraries first. Yes, it is not really a "beep", but that's a start