I want to create music notes from MSP430 to play on a speaker (either a piezo speaker or through an amplifier). I’m thinking something like a PWM signal from the MSP430. Anyone knows the values in the coding for the different music notes by any chance and how to set it up?
The data sheet will tell you how to set up the pwm output for a given frequency. To find the frequency of a note, start with a known frequency (the A above middle C is 440 Hz) and multiply/divide by the twelfth root of 2 for each semitone up or down. (To go a full octave, multiply or divide by exactly 2.) This will get you an “equal temperament”. If you want to get fancy, you can choose a non-equal temperatment that fits the particular music you’re playing better than an equal temperament does.
I looked at the data sheet and sample codings but i didn’t see anything on how to setup for multiple frequencies on one output port, so that i can create some kind of music.
oh, I see. I think you’d have to do that in software (compute a waveform by summing each individual “voice”, then use the PWM at high frequency as a sort of DAC, or just drive an output pin directly as a 1-bit DAC). But maybe I’m missing some way to do that in hardware.