Saturday, 22 September 2012

Programming the MSP430 using Assembly

Hey everyone,

From those of you who are in Prof. Khan's ECE2560 microcontroller's class, I have been getting a lot of questions on how to load the assembly project examples onto the MSP430 Launchpad. For this tutorial, I will use the Blinky.asm.

To start, go ahead and start up CCS v5. Do note that in order to be able to program the MSP430 Launchpad, you will need to be on the Free Code Size Limited license.

1) To create a new project, go to File>New>CCS Project. Make sure you choose CCS Project and not just Project!

2) Look at the screenshot below and make sure that you make the same selections. Make sure that you have MSP430 selected as your device, and MSP430G2553 as your variant. Also Choose Empty Assembly-only Project as a template. You can name your project as you wish, it does not have to be Blinking_LEDs.


3) I called my project Blinky. The next step is to create a source file into which your code will go. This file can have various formats, it can be a ".c" file, but we want a ".asm" file because we will be using not C, but assembly to program. To do this, find your project under the Project Explorer and make sure its title is in bold. Right click on its name and choose New>Source File. If you are lost, check out the screenshot below. When the New File window comes up, find a name for your source file and make sure to add .asm at the end of it. For example, I chose main.asm as my source file name.



4) Once the new source file is created, the new file will open up in the editor. But you will notice that it is not empty. It puts a couple of lines in the file which include the date and your name. You can see a picture of it below. Delete all of these lines because if you leave them there, your compiler will give you errors. This title would work fine if we were programming in C, but assembly compiler will not be happy.


5) Once you deleted the lines, go to this PDF file  here. You might notice that this is the PDF file on Prof. Khan's website which contains the example code. You will see that the code is copied directly from CCS into the PDF file. You will also see that line numbers are also present. What you can do at this point is copy all of the text and paste it into your new .asm source file on CCS. However, you are not quite done yet because you will need to reformat the whole code in order to be able to compile it. You will see that every line is messed up and the indentations are all wrong. You can try fixing it, but don;t even try because I am nice enough to provide you with this text file which includes the same code, in the correct format. I have done all of the manual labor for you. So all you have to do is open up the .txt file, copy the contents and paste it into your source file on CCS.

6) Once you have that done, all you have to do is debug your code and program your Launchpad. To do this, click on the button that has a bug on it and this button will build, compile and program your code. So it is a pretty useful button, isn't it? If you don't know which button I am talking about, check out the screenshot below.


7) Once CCS finishes programming your MSP430, you will have to command your MSP430 to execute your code in order to see your LEDs blink. To do this, click on the button that looks like a play button. To end your debug session and go back to editing your code, click on the stop button. Here is a screenshot that shows where these buttons are located on the CCS Debug window.



Common Problems
Some of you will inevitably run into problems during debugging. The most common problem will be that you have the wrong license on CCS so you will get a message saying that you cannot program MSP430s with your current license. To fix this, go to Help>Code Composer Studio Licensing Information. Then go to the Upgrade tab and choose Launch License Setup. Once the License Setup Wizard comes up, click on CODE SIZE LIMITED (MSP430) and then click on Finish. Now you should be able to debug your code.

Have questions? Comment below and ask them. I will get back to you.

-Anil

Monday, 10 September 2012

About Me

Hey everyone,

This is my very first post on this blog. I have been meaning to create this blog for a while now, and finally it is live. Before I start talking about the blog though, I would like to say a few words about myself. My name is Anil Ozyalcin, I am a third-year Electrical Engineering student at the Ohio State University. I moved to Columbus, Ohio in September 2010 for college. Before college, I lived with my parents in Ankara, Turkey which is where I am actually from. My dad, too, is an electrical engineer, so you could say that being an electrical engineer is a tradition for the Ozyalcin family.

My encounter of microcontrollers has been a strange one. In November 2011, I bought my first microcontroller not because it had awesome specs, but simply because it was dirt cheap. In fact, at the time I ordered my first microcontroller, I had no idea about what it even was or what it did. You might have guessed already, but the first microcontroller I bought was indeed the $4.30 Texas Instruments MSP430 Launchpad. I bought it because it was very cheap, and it looked awesome with its red circuit board and the "rocket logo." Its looks were more of a criterion to me than its technical specs.

Long story short, this blog is aimed to help newbies out there start building their very own microcontroller projects! I have been there, and I know that it can be intimidating playing with microcontrollers in the beginning. I hope to help you guys understand the basics of programming micrcocontrollers and how to use CCS (Code Composer Studio 5). I deal with the MSP430 Launchpad and the C2000 mainly. So I will have projects and tutorials regarding both in the near future! Stay tuned and comment so I know at least someone is reading this!

-Anil

My desk with my microcontrollers.