grahamn 0 Posted September 20, 2012 Share Posted September 20, 2012 Hi Please forgive me if I'm doing something stupid, but I have recently purchased a MSP430 launchpad and am starting to set it up to learn more about it. My first step was to install the Energia IDE, and I successfully ran the blinking LED sketch as suggested in the instructions. I then decided to start working through some of the other code examples, and loaded the 'Melody' sketch as what I thought would be a simple exercise. However - nothing works. I'm really unclear on the pin assignments and tried what I thought were the correct pins (p1.7 and GND), but nothing happened. I then tried moving the speaker lead from 1.7 to each of the other 1.x pins in turn, but again nothing. Am I missing something, or does this particular sketch not work? Or do I need to learn more before trying to program this device? I should probably point out that I've been using an Arduino for some time, and am fairly happy about how to program that, but my programming skills are mainly years old and stopped at Visual Basic and very simple C programs. Thanks for any assistance. Quote Link to post Share on other sites
jsolarski-backup 22 Posted September 20, 2012 Share Posted September 20, 2012 what kind of speaker are you using? (you could be trying to drive a speaker that needs more power) instead try an LED instead of a speaker, this should allow you to see if it is playing or not. What msp430 are you using, and did the IDE upload the sketch correctly? as for the skill, if you can program an arduino you can program an msp430 with energia IDE with the same ease. grahamn 1 Quote Link to post Share on other sites
grahamn 0 Posted September 20, 2012 Author Share Posted September 20, 2012 The speaker is a small (2" diameter) 8 ohm speaker which will crackle even with an almost completely dead 1.5V battery, so I don't think it's a power problem (though I will try a LED later on). The launchpad is a MSP430G2553 (I haven't made any jumper changes etc. from when I unpacked it). The sketch compiled and was uploaded without any errors, and the blink sketch works perfectly, so I assume I've got at least the basics right. Quote Link to post Share on other sites
grahamn 0 Posted September 20, 2012 Author Share Posted September 20, 2012 I should probably add that the sketch stated pin 8 should be used - presumably an Arduino pin number - and I simply guessed the equivalent on the MSP430. Quote Link to post Share on other sites
cde 334 Posted September 20, 2012 Share Posted September 20, 2012 The Energia home page wiki notes that tone() is not currently working or implemented. As such, the melody sketch won't work. Alternatively, the pin referenced in the melody sketch is pin 8, which translates to port 2, so port 2 pin 0? This requires a 20 pin msp430. You can try changing the 8 in "tone(8, melody[thisNote],noteDuration);" to 2 through 7 (p1.1 to p1.5), see if it works (if the wiki page is simply out of date) And you want to read the "energia_pins.h" file inside "hardware/msp430/variants/launchpad/" for an idea how arduino pins convert to launchpad port/pins. grahamn and jsolarski-backup 2 Quote Link to post Share on other sites
grahamn 0 Posted September 20, 2012 Author Share Posted September 20, 2012 That's great - thank you. I hadn't looked at the Wiki properly and hadn't noticed that page. Pin 8 does indeed go to 2.0 once I had checked the .h file, so at least I'm starting to get somewhere. I'll carry on trying some of the other example sketches to get some more familiarity with the board. Quote Link to post Share on other sites
cde 334 Posted September 20, 2012 Share Posted September 20, 2012 That's great - thank you. I hadn't looked at the Wiki properly and hadn't noticed that page. Pin 8 does indeed go to 2.0 once I had checked the .h file, so at least I'm starting to get somewhere. I'll carry on trying some of the other example sketches to get some more familiarity with the board. Try changing that line though, see if it works with 7 instead of 8 (pin 1.5) Quote Link to post Share on other sites
maxik 1 Posted September 20, 2012 Share Posted September 20, 2012 The Energia home page wiki notes that tone() is not currently working or implemented. As such, the melody sketch won't work. Wiki is probably out of date, tone() works as expected, I've just tested it with buzzer to be sure. void setup() { pinMode(P1_5, OUTPUT); } void loop(){ tone(P1_5, 2193, 150); delay(250); } Quote Link to post Share on other sites
grahamn 0 Posted September 20, 2012 Author Share Posted September 20, 2012 I decided to look through some of the other files and found tone.cpp which seemed to imply that it should work. I tried using pin 2.0 as suggested and it worked straight away! Many thanks - I'll start looking more closely at the docs in future! Quote Link to post Share on other sites
energia 485 Posted September 20, 2012 Share Posted September 20, 2012 rei_vilo has put together an excellent hardware guide and it is posted here: https://github.com/energia/Energia/wiki/Hardware I am still interested to find out why it didn't work originally. If there is a bug then I'd like to find out and fix it in the next release. If I am correct then the Melody example Sketch did not work without modifications? (I assume that you selected the right board from the Tools->Board menu). Robert Quote Link to post Share on other sites
grahamn 0 Posted September 20, 2012 Author Share Posted September 20, 2012 The sketch worked fine after I worked out what I had done wrong. I originally used pin 1.7 (as I assumed that was pin 8), and when there was no output I tried each other pin. The problem was that I didn't press reset between each change of pin - I just assumed the tone sequence would repeat. Once I actually read the sketch properly, and realised I had used the wrong pin, everything worked just as it should. Thanks for the guide link - I did find that, but misunderstood the pin layouts until it was pointed out earlier in this thread. Quote Link to post Share on other sites
cde 334 Posted September 20, 2012 Share Posted September 20, 2012 rei_vilo has put together an excellent hardware guide and it is posted here: https://github.com/energia/Energia/wiki/Hardware I am still interested to find out why it didn't work originally. If there is a bug then I'd like to find out and fix it in the next release. If I am correct then the Melody example Sketch did not work without modifications? (I assume that you selected the right board from the Tools->Board menu). Robert Simply an error of which pin the sketch was using, versus which pin on the chip. Grahamn tried p1.1-p1.7, but the sketch was using digital pin 8, which is pin 2.0. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.