Tuesday, May 29, 2012

simple tone/music player

Here's a reasonably simple way to get ugly square waves playing music, much like an old Nokia ringtone. It has been configured to use the G2211 that comes with the MSP430 Launchpad. It doesn't really need any special functions and can run on other value line MSP430s. This project uses Code Composer Studio 5.2 with Grace.

All you need to add is a speaker between P2.6 and GND (they're adjacent pins) and press the button connected to P1.3. The code isn't all that elegant and I've ignored all the new ULP rules.

The DCO is set to 12MHz for the purposes of interrupts. I have included a spreadsheet that calculates the constants from music note frequencies into the adjusted DCO periods. The main function changes the note and duration while the interrupt routine toggles the output and keeps track of time for the note period and total duration.

http://db.tt/HKXGJrFq

This particular file plays 'Thaxted'. I found the sheet music from the Mutopia Project's website.

No comments:

Post a Comment