Jump to content
Sign in to follow this  
CsCrazy

MSP430 Launchpad RTTTL-player

Recommended Posts

Hi all!

 

Yesterday I finished with my little project, which was to play ring-tones in rtttl-format (Ring-Tone Text Transfer Language) with MSP430G2231. I thought that some of you might be interested about the project and about the code.

 

Code is "built" from arduino sketch which involves Tone Library and the sketch acts as a interpreter for the rtttl "code", but also the code is partly made of 'msp430 LaunchPad Music' made by Bob Somers. So this is a kind of a ported code.

 

Here's how it works. Main part of the rtttl-player (as the CCS project is named) is the play_rtttl(*song) function, which reads the song in RTTTL-format. After the function has decoded each note, the note's frequency is selected from the lookup table and it's length is calculated. These two values (note-freqyency in timer ticks, note-length in ms) are then forwarded to PlaySingleTone(...)-function, which sets up the timer and a delay which they together produce a notable sound from the speaker.

 

Speaker might be any low-power speaker (since MSP430G2231 doesn't have much kick to drive larger speakers) or a piezo-speaker, as in my case i used a piezo-speaker. Speaker can be connected to any of the pins in mcu, since timer A causes only interrupt when capture/compare register value is detected. Inside the interrupt the port pin is toggled.

 

You can see or preferrably hear how this little bug plays a MacGyver theme, here's a link to my youtube video: 

 

So with the msp430g2231 chip you can play about 45 sec long song (of course it depends on the song and it's tone lengths). 

 

Couple of things which were problems during the project:

1. Sounds were at the beginning very wrong, they had different frequency of what it should have been (it hearded like the sounds were inverted each note). This was due to defines in the code. Because this was originally an arduino skecth, the defined note-values (like #define NOTE_C4 <number>) were direct frequencies in Hz and I didn't think of this at first and I just inserted these values into timer. So it was obviously a wrong method.

2. In Tone.c -file I forgot to remove TAIE interrupt (which in this code is not needed) and I didn't have interrupt handler so the player produced only one note and then it was resetting itself. This was very obvious when it was detected.

 

So here it is. Thank you for your interest. Hopefully this is useful for somebody, for me it was really fun thing to do and the interesting part was the parser code (play_rtttl) function.

 

 

In the attachment you can find the project-files for CCSv5 and below is a picture of my speaker setup:

post-29846-0-12018100-1357286888_thumb.jpg

 

RtttlPlayer.zip

Edit: Added schematics for the current code.

msp430g2231-RTTTL-Player.pdf

Share this post


Link to post
Share on other sites

Good work! and thanks for sharing your code.

Be sure to add this to the next month's POTM contest.

 

Thank you bluehash!

 

I think I just might do that, when will the contest open?

Share this post


Link to post
Share on other sites

Hi,

Congratulations, great sound.

Do you connect the speaker ou piezo-speaker directly to a output pin of the microcontroller? This have enough current? Can you tell me the references of your piezo-speaker. I have one but the song is too bad.

Best Regards

Adriano Campos

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...