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.

Using MSP430G2553 to generate a square wave tone through a 2-1/2"-8 OHM Speaker. NEED HELP !!!

Other Parts Discussed in Thread: CC3200

I am currently attempting to generate a square wave to through the specified speaker above using the msp430. We're currently able to generate a flat wave using the following code below. We're unsure whether we need another micro controller, or if there's a flaw in the code. Any modification to the posted code, or advice, will be much appreciated. 

#include "msp430.h"                     ; #define controlled include file

        NAME    main                    ; module name

        PUBLIC  main                    ; make the main label vissible
                                        ; outside this module
        ORG     0FFFEh
        DC16    init                    ; set reset vector to 'init' label

        RSEG    CSTACK                  ; pre-declaration of segment
        RSEG    CODE                    ; place program in 'CODE' segment

init:   MOV     #SFE(CSTACK), SP        ; set up stack

main:   NOP                             ; main program
        MOV.W   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
        
        BIS.B   #BIT1, &P2DIR            ;
        BIS.B   #BIT1, &P2SEL            ;       
                
        MOV.W   #3822, &TA1CCR0          ;
        MOV.W   #1911, &TA1CCR1          ;  
                
        BIS.W   #OUTMOD_7, &TA1CCTL1     ;  
        BIS.W   #TASSEL_2 + MC_1, &TA1CTL;
        BIS.W   #LPM0 + GIE, SR          ;
        MOV.W   #1000, R7                ;





       
        JMP $                           ; jump to current location '$'
                                        ; (endless loop)
        END

NOTE: THIS NEEDS TO BE IN ASSEMBLY LANGUAGE CODE. NOT C++.

  •  Hi Gabriel, at first your title is the worst and forum if you read rule on how to use forum ignore this...

     Your request sound as irrespective of helpers so we ignore this type of post. If you wish to be helped please use courtesy and ask if someone can help than screaming on title too...

     

  • Should work, did you ever put a voltmeter on the pin?, should register 1.6v as the signal is of too high Hz to be seen without a oscilloscope.
    But most likely you already killed the pin, as direct connect that speakers is the same as putting 8ohm resistor between that pin and ground.

    You do under stand that you can not drive a speaker directly from the msp pin,
    can not even drive a piezo speaker directly from the pin as 2mA drive is a weak drive.

    And speakers should be driven +- and not +0, so you need a hbridge/d-amp to do that.
    maybe could get way using a boost circuit using mosfet and a inductor.

  • Tony Philipsson said:
    But you do under stand that you can not drive a speaker directly from the msp pin,
    can not even drive a piezo speaker directly from the pin as 2mA drive is a weak drive.

     Hi Tony, I remember 40mA or my memory is weak? Loudspeaker can be driven from MSP pins a current  limiting restistor is better than directly connect an inductive load.

     Another better idea is to use a capacitor in series to loudspeaker to avoid damsge it when you debug code and vcc is applied for a too long time.

     An HC04 with all port connected in parallel can be the cheap  LS driver, still don't forgot capacitor...

    Tony Philipsson said:
    And speakers should be driven +- and not +0, so you need a hbridge/d-amp to do that.
    could get way using a boost circuit using mosfet and a inductor.

     Uh.. but this is an overkill, then you need filter dc bias and some high frequency to have less sharp sound and filter out uC noise too.

  • Gabriel - We've got your question and it appears Tony has jumped in and helped. Just keep in mind that all caps can unintentionally come across as screaming when used in a Forum headline (when writing your main question). The more key summarized details you include in your title will help us to quickly discern what you might need and how we can help - device, part  or part numbers, type of issue, etc. Any questions along the way specific to using E2E or if there is anything I can ever do to help please feel free to reach out to me directly.

    Roberto Romano said:
    at first your title is the worst and forum if you read rule on how to use forum ignore this...

    Roberto - Please don't post comments like this which are not only off topic but harassing.

    Roberto Romano said:
    Your request sound as irrespective of helpers so we ignore this type of post.

    This is not an acceptable or correct statement. Please leave out this type of commentary which can only come across as attacking and harassing.

    In your follow up post to this one everything was on topic and on point (when quoting back with additional details to what Tony wrote) but in this post it wasn't.

  • Blake Ethridge said:
    This is not an acceptable or correct statement. Please leave out this type of commentary which can only come across as attacking and harassing.

     Hi Blake, please accept my apologizes about, it was not my goal than inform why post got no attention. So we can start back from what I think can be forum rules:

    e2e.ti.com/.../55315

     to cure this way, can we refine a good way to ask poster read? Can be  acceptable this

     *****************************

    Hi name, welcome here please read about  forum usage :

     *******************************

     Or simply leave unanswered post alone without explain? So sorry this is harassing, but from description of harassing I find more harassing leave someone alone than explain, this is a form of isolation.

     I never do that again and I left ignored messages where they are or if you kindly suggest me a courtesy form I can apply as a  guideline (of course if you and others like this).

     Again beginner question or newbie, if these word are felt as offensive, we can use general or unclassified request, but an area where to post freely possible "silly" question is a better way to grow up forum. We know this is first time or not expert so we can guide by hand in hand starting directly from bottom than refining with tons of questions.

     Another area if forum has to grow up can be  a C programming area TI processor biased, I see a lack of information for (complete with your word as beginner) so some guides can be prepared on question about FAQ. How to set reset bit port or similar... Some items like pointer manipulation are of not simple understanding and also experienced programmer can get some more hint.

     Why not grow as thematics and also add an introduction on how to use forum global as guide to who first wish post here? First time I was not sure of correct area nor how to ask.

     I fear I am becoming too old and sometimes new generation are too far far away from our habit, I wait your instruction too, my feeling are from ancient text only forum at time of old BBS 'am  learning are outdated.

     Sincerely

  • You can use two complementary CCR timers (in total 3 CCR timers) to two Port pins to double output power. Connect each Port pin to one side of the speaker but add a series resistor ~470Ohm to limit the port current.
    But I think a 2.5” speaker will be too much and will not give much sound or maybe even no sound.
  • It's a 8ohm speaker, they are made to be driven near shorting-out-the-system.
    Putting a 470ohm in series and it will be not be audible to hear.
    There are Speakers that have 100-500ohm resistance and a membrane to accommodate for the lower current.
    www.mouser.com/...
    Piezo speakers (though bad at creating a nice tone range) uses even less power.

  • Tony Philipsson said:
    Putting a 470ohm in series and it will be not be audible to hear.

     You have reason, SPL sensitivity of these loudspeaker I fear are no more than 70 max 90dB/W or even much less, so 470Ohm on square wave driven to 3.3V generate an about 7 mAmp current resulting in a 394uW so about -4dBmW or -34dBW resulting in case 70dB  an SPL near 36dB, it is too fable to be useful.

     At least 50 60  dB SPL are required to be hear freely so a resulting drive power of at least -10 -20dBW is requires, this result in 10 100mW ranges so current on loudspeaker must be near I=Sqrt(P/R) 35 -  112mA, resulting in series resistor of  86Ohm down to 21.5Ohm.

     A buffering transistor or power amplifier stage is needed for these values of current.

  • I don’t think Gabriel wants’ to build a Ghetto Blaster!

    He is just exercising, and when he is lucky some speaker vibration will appear and he has LOL.
    Lowering the resister value will not much help with this MCU, it will also lowering the port output voltage.

    To increase the vibrations he can always have a look at TI’s ‘Sound Plus’ range.
  • Leo Bosch said:
    I don’t think Gabriel wants’ to build a Ghetto Blaster!

     Uh.. what is this? Searching... Compare.. Urban language.. best fit match..

    Ghetto Blaster

     UHm.. Leo why not ;) But 2 1/2 LS is not so powerful to build a powerful boombox, Leo you are guilty of this, new boosterpack idea gotten, it doesn't fit to small G2553 (or not).. but can be best served from MSP5x Series, MSP432 too TIVA CC3200 and c2000 launch pad series.

      Leo, this was just to evaluate Tony perception and I feel is good, a fraction mW is near inaudible on a so small loudspeaker, this just to evaluate how to better attach a simple device. I am near sure 47- 100Ohm resistor in series to loudspeaker can do protection of MSP and also give enough sound pressure to have audible sound, not so loud but firmly audible. In the case of 470Ohm level is very weak.

     Then if our Gabriel wish made an high power boom box like a Ghetto Blaster it is our customer so we can move to audio amplifier and fit best match of battery powered ear destroyer too ;) Or I can propose a better ultra high power interleaved  digital hifi multiphase inverter to generate audio from.. We have not dreamed too much from original small just simple beeping device?

  • GABRIEL JEFFERSON said:
    I am currently attempting to generate a square wave to through the specified speaker above using the msp430. We're currently able to generate a flat wave using the following code below. We're unsure whether we need another micro controller, or if there's a flaw in the code. Any modification to the posted code, or advice, will be much appreciated. 

     Hi Gabriel, after all mindstorming about how to ..

     You wrote are generating a "flat" wave, this means a square wave? So you see it on a scope?

     Just a doubt, weak but speaker must generate some sound, is loudspeaker good?

     From reset state register all carry zero default, but try change the two BIS on tacxxx register with a move to be sure register are forever set to a correct pattern.

     fast checked values of assumed 1MHz clock are ok so it must work or some different problem may be affecting setup.

  • Not below 100 Ohm otherwise he will reach the maximum allowed device current.
    But anyhow it looks like he is using a very low frequency which need a lot of power, if he would use 5-10KHz maybe he will hear something.
  • Leo Bosch said:
    But anyhow it looks like he is using a very low frequency which need a lot of power, if he would use 5-10KHz maybe he will hear something.

     Yes Leo, 216Hz efficiency is low and SPL is probably less than audible threshold but SCLK is not specified too.. So it is time to have some feedback from Gabriel is silent from too much time.

     What I seen new GRACE version update all mode, so wroting register all other view got updated in consequence. Similar instrument are missing on other MCU series of TI. Another good tools is RF STUDIO for radio based CC series and CC chipset.

  • An 8 Ohm speaker is way too much for the port pins. Assuming a maximum (short) current of 40mA, it means on 8 Ohm just 320mV. It results in 12.8mW power. I doubt it will be enough to bring the speaker even into the slightest motion.
    Also, as a speaker is an inductive load, it may fry the port pins by the inverse voltage (causing a peak current through the clamp diodes that may well be >2mA)
    A better try would be an earphone speaker. These usually have 32 Ohm, which gives 50mW, and due to the smaller mass and the placement in the ear, it is clearly audible. And the higher impedance and lower mass will cause less problems with inductive voltage generation.
  • Author asked for SQUARE wave so single transistor as an amplifier could do the job:

    Picture from this webpage

    Here's more

  • Using an amplifier is of course a possible solution.
    However, it never will be square wave. The inductance of the speaker acts as low-pass filter, so you'll get a sine wave with some overtones, but not really a square wave output. :)
  • >However, it never will be square wave.
    Indeed. It is not possible to generate perfect square wave signal, not to mention sound. Tolerance was not defined, so basically ANY solution that seems to output square wave fits the bill here.
  • hello, if it's any help I have the code where generate musical notes right through PWM timmer A,

**Attention** This is a public forum