3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Intro to Microcontroller Debugging (and a Pomodoro Timer)

Intro to Microcontroller Debugging (and a Pomodoro Timer)

Hello Hack-A-Day and Dangerous Prototypes readers!  Please vote for me in the Sparkfun uC Contest!  (If you vote for me you can still vote for other projects as well)  The vote button is just up and left of here... there you go... closer... closer...  I know you can do it...




1.) I do, in fact, own an Arduino and despite this being a microcontroller project on Instructables, an Arduino is NOT a part of this guide. An Arduino has it's specific uses and fills a niche in my toolkit very well but Arduino is usually not my first choice when deciding which platform I'll prototype my latest idea with. One of the best parts of the Arduino platform is that it is streamlined to the point that anyone can use it without being an engineer. However, someone serious about the code they are writing for their project, will before long, need an essential feature: in-circuit debugging. We'll go over why ICD is so great and discuss how to use it as we build this simple project.

2.) What the heck is a Pomodoro timer, you ask? The Pomodoro technique is a means of time management created by Francesco Cirillo. You can find lots more information here: http://www.pomodorotechnique.com/ Personally, I love the Pomodoro technique but didn't want to run yet another application on my computer. Thus, I needed a simple timer. If you don't need or want a Pomodoro timer, the end result of this Instructable isn't as important as the means of getting to it and learning how to debug. What I really want to teach is some simple debugging concepts your average Arduino user may not know they are missing out on.

3.) This project is based around the Texas Instruments LaunchPad development board, an MSP430G2211 and five LEDs. If you don't have a Launchpad and have any interest in embedded programming at all, please just order one now. You can thank me later.

Take a look at the final step for the components needed for the pomodoro timer, if you're interested in making one.

4.) IAR Embedded Workbench Kickstart for MSP430 is the development environment we'll be using. Download it from here: http://www.ti.com/iarkickstart This is unfortunately a Windows-only IDE, but it runs in various virtual machines on both Linux and OS X. For this Instructable, I'm using Parallels on OS X. If there is sufficient interest, I'll write a guide for MSP430 development using FOSS tools on OS X.

 

 
Remove these adsRemove these ads by Signing Up
 

Step 1Putting the prototype board together

Putting the prototype board together
«
  • DSC00427.jpg
  • DSC00428.jpg
  • DSC00430.jpg
Got all of the parts? Good. Let's throw this thing together real fast. First, DISCONNECT the Launchpad from your computer if it is connected. The Launchpad should NOT have power.

Remove the TXD, RXD, and P1.6 jumpers from the board. Put the microcontroller in the Launchpad if you haven't already. The groove in the microcontroller goes towards the USB connector.

LEDs don't work if put in backwards so pay attention to their polarity. Here is a quick primer if needed: http://www.sparkfun.com/tutorials/222. Thanks Sparkfun!

For all five LEDs, bend the cathode straight out. (That's the short leg). Put the LEDs, 100ohm resistor, and paperclip together like they are in the picture. I'd prefer a bit solder to the paperclip, but we're keeping things as simple as possible.

The LEDs, one each, are in ports P1.1 – P1.5.  The paperclip prototyping method seen below works in lieu of solder.  The 100 ohm resister completes the LED's path to GND.

My piezo speaker was a lucky find as it already had a .1” pitch header on it. It that is the case, you can remove the P1.6 jumper and attach the speaker directly to the board. Otherwise, you need to make a connection from P1.6 through the speaker to GND.

For those that want to make this a stand-alone device, the final schematic is included in this guide on the last page. 
« Previous StepDownload PDFView All StepsNext Step »
16 comments
Feb 19, 2011. 5:08 PMNewB007 says:
After I learned my C bitwise operators and figured out that you were using the Hex numbers to filter bits, I found the error before I read about it in step 5! Thanks for the great intro to debugging, and for making it just complex enough that I had to learn something new!

It's probably absurd that I understand all that without knowing any programing languages. Time to learn C! :)
Feb 15, 2011. 7:38 PMNewB007 says:
In Step 2, the line "WDTCTL = WDTPW + WDTHOLD;" is in your comment.
Looking at the screenshot in Step 3, you did not intend this.
I though it was an intentional bug at first, until I kept reading.

In the meantime, I am still trying your example. I am not familiar with C, MSP430s, IAR, or really any of it. I understand the basics of programing and circuits, but despite having compiled and downloaded the code, all I have managed to do is get the P1.3 LED to glow dimly and continuously. The other LEDs and buzzer show no signs of anything. I have tested the LEDs through the paperclip junction (alligator clip on mine) for continuity, and the joint is good. I have rearranged the LEDs and moved the buzzer between the two acceptable location to no avail. I haven't noticed any magic smoke. Do you have any ideas for what I could be doing wrong and/or how to correct it?
Feb 16, 2011. 12:29 AMmouritsen says:
I get the exact same result as NewB0007. P1.3 LED glows dimly and no other LEDs ever light up. I noticed if I press S2 then P1.3 LED turns off until I release S2. Also LED1 and LED2 continuously flip on and off back and forth as in red-green-red-green, etc. If I unplug the USB cable and disconnect the LEDs and 100 Ohm resistor the default temperature program still works. I don't think my code is being written to the chip. Any suggestions? This is my first project since my 430 came in the mail today, so maybe there is some kind of initial setup I need to do either in IAR or something else? Any help would be great. Thanks for the tutorial. I'm looking forward to learning how to use this thing.
Feb 15, 2011. 8:07 PMNewB007 says:
You're welcome. It is correct above, now.

I tried your suggestion, and I am getting 1.6V on P1.3, independently of wherever I stop it. No other pin is supplying voltage. I think I must have a download error, or a dead chip. I'll have to find a way to test that, I guess.
Feb 15, 2011. 8:28 PMNewB007 says:
I meant to say "I noticed that you have not soldered the included crystal to the pads, whereas I have."
Feb 16, 2011. 3:43 PMNewB007 says:
Problem solved!

I noticed my error while setting up a Workspace for your test code. It turns out that my problem was scrolling my mouse wheel after selecting "FET Debugger" under "Driver," so that I had inadvertently been working under "Simulator." I ran your "helloworld" to confirm that my hardware worked, and then re-ran your Step 2 code.
Feb 15, 2011. 8:26 PMNewB007 says:
Thanks, that explains the voltage difference! I guess the issue now is why P1.1, P1.2, P1.4, and P1.5 don't want to cooperate... I noticed that you have not soldered the included crystal to the pads. Could that explain my discrepancy?

I guess I will just have to try a hello world to each of the pins tomorrow to see if I can isolate the problem.
Feb 15, 2011. 11:52 AMcsammis says:
"If there is sufficient interest, I'll write a guide for MSP430 development using FOSS tools on OS X."

+1 for interest on this topic! I just got a couple Launchpads for my first ever foray into uC programming and I'll soon be getting an OS X machine. Being able to use those together would be awesome.
Feb 13, 2011. 9:54 PMfrank26080115 says:
I just want to point out that you shouldn't connect a lot of LEDs with only one resistor. Although you might think that the current flow is evenly distributed through all the LEDs, they are not, one might have more current flowing through it than the others due to very slight differences in conductance. For the purposes here, it's not a big deal, just a bad habit.

Also just a reminder for everybody, two diodes rated at 1A each placed in parallel does NOT mean you can let 2A through, unless the diodes are absolutely identical, which is almost impossible in the real world. One will let more current flow through than the other, and that one gets warmer, and actually increases its conductance.
Feb 15, 2011. 10:31 AMBadWolf Corp says:
Don't forget that he probably set the resistor like waaaaay above the limit to make sure that erven with 5 leds on,the current won't kill it. I'm pretty sure you didn't think about that ;)

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
1
Followers
1
Author:kphlight