Sunday, July 18, 2010

Some News about the LaunchPad

So I have a quick update about the LaunchPad. TI has finally posted the LaunchPad User Guide on their website; oddly enough it is not on the Wiki yet. They also posted a white paper on the LaunchPad but is not really worth the read if you already have your LaunchPad. I do recommend reading the User Guide though, some interesting things in there.

A few quick comments about the LaunchPad. I have verified that you can just plug the MSP430F2013 into the socket on the board and it works perfectly. They also mentioned this in the User Guide. One thing I am not too happy about is that you can not disconnect ground between the programmer and the target side. Not too big of a deal, but I don't like it.

Also, has anyone else been having trouble with the pdf files from TI? I keep getting some weird errors pretty consistently. Its possible its just me though.

Expect a follow up article to my Getting Started Guide soon. I will be discussing the use of the pushbuttons and will explain the code a bit. From this point on the blog will alternate between news, beginner guides, and advanced topics. Feel free to let me know if there is a topic you would like me to write about.

Thursday, July 15, 2010

My Version of Getting Started

So, with a bit of playing around I have my LaunchPad blinking happily and I am going to show you how I did it. People who really know there stuff might not like how I’m doing this, but we will progress to creating our own project from scratch soon.

Before we start I’m going to say right now the demo temperature sensing program TI provides is hard to work with when starting an example project. It’s cool since it shows off what the chip can do, but it's hard to work modify. Also, I will be using Code Composer Studio because it has a larger program size limit that IAR. This doesn't matter with the current chip, but it will for others I will use in future posts.

Step 1 – Installation and Example Code

Download and install Code Composer Studio. If you are using Windows 7 like I am make sure you don’t install it under Program Files, and install it somewhere like “C:\Texas Instruments”. Also, you probably don’t need to do this, but I kept my LaunchPad unplugged while I was installing everything.

Download the test project “MSP-EXP430G2-Launchpad” and unzip it to a temporary folder such as one on your desktop.

Download the “MSP430F20xx, G2x01, G2x11, G2x21, G2x31 Code Examples” and also unzip it to your documents somewhere. This is the sample code we will be using, and not the example project with the stupid temperature sensing UART thing.

If my links don't work, all of this is linked under the LaunchPad Wiki.

Step 2 – Load the Project and Set it Up

Run CCS and you will be prompted where you want to put your workspace. Within one workspace you can have multiple projects so I recommend making a directory where you will keep all your different projects code. I chose to use this directory as default but you don’t have to.

Close the Welcome window.



Now we are going to import the project. Go to Project --> Import Existing CCS/CCE Eclipse Project.


The MSP-EXP430G2-Launchpad project will show up, check the “Copy projects into workspace” and then click Finish.

On the left under the project box expand your project, and you’re going to want to delete “test_RX.c.old”. We won't be using it.

Double click on the file “MSP430F2012.ccxml”. This is the file which lets the compiler know which devices your project is being loaded on to. Click “Do not show this again” on the stupid Cheat Sheet thing on the right that popped up.


Type “*2231” in under the Board or Device, and then check the MSP430G2231. There is a chance that you might not need to do this, but I am a fan of selecting your device just in case, just one less thing to worry about being wrong. Again, I have no idea why they had this chip selected. I assume that you are using the chip that came plugged into your LaunchPad for now. In later tutorials we will be changing this to program different chips using the SBW. Click “Save Configuration”.

To keep ourselves sane, rename the .ccxml file according to “MSP430G2231”.

Now go to Project, and hit “Clean…”. I like to do this when I make any huge property changes, again this might not be necessary but follow me for now. A warning will pop up, continue to clean the project.

Step 3 – Use the Real Test Program

Open up main.c, you will now see a huge program that’s poorly commented. I’m still young, and hate commenting my code, but everyone should suck it up and do it. That is one of the most important things I feel everyone must do when writing code, comment well.

Under the code examples we downloaded before, under the folder named “C” there should be a file named “msp430x20x3_1.c”. Open this file in notepad or whatever editor you use. Copy all the code. Then past it into our main.c file after removing all the stupid temperature project code.
The comments at the start of the code should look like this. (My formatting is all messed up, I know. I just wanted to post this quickly, I can edit the fonts later.)

//******************************************************************************
// MSP430F20xx Demo - Software Toggle P1.0
//
// Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.
// ACLK = n/a, MCLK = SMCLK = default DCO
//
// MSP430F20xx
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
// M.Buccini / L. Westlund
// Texas Instruments, Inc
// October 2005
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.40A
//******************************************************************************

This code is very nice and simple and is pretty well commented. What it does is toggle P1.0 which in this scenario, will blink an LED on the LaunchPad.

One thing we will need to change (which again, we might not have to, but I like to keep these things as correct as possible) is the #include header file.

Change it to this:
#include "msp430g2231.h"

Step 4 – Programming the LaunchPad

Now we are going to program the LaunchPad, but before we do I have a few comments. It seems like the pictures and schematics they provide on the LaunchPad Wiki site are a bit wrong. P1.0 is connected LED 1, which is Red. This is the LED we will be toggling. If it is green on your board, or anything else is funky or different, please post and let me know.

We now should plug in the LaunchPad, hopefully all your drivers install automatically because mine did. If you are using Windows XP I think you have to direct the installer to the files under the CCS install directory. Good luck.

The LaunchPad should have at the very least the power LED lit showing the device is powered and ready to go, you might have some blinking LEDs or something from what is already stored on there.


Click the little bug near the project menu called “Debug Launch”. A window should pop up which is compiling your code, and then a debug session should open up. If you have any errors either something is wrong with your driver, you didn’t follow my instructions correctly, or something else entirely. If you are having trouble, feel free to comment.

Nothing should be happening on the board yet though. What we want to do is now click Run, which will start the program on the LaunchPad. Now look down at the LED.

Congratulations, you have a blinking “Hello World” program working!

Step 5 – Modify and Have fun

Change the “i” value in the code to change how quickly the LED blinks, the bigger the number the longer the LED will stay on and off. You can also change the port to P1.6 to blink the other LED. Next blog post I will explain the code, and fun ways to modify it.

As always, comment away. If I have typos, formatting errors, or some wrong information please let me know. Hopefully this worked for you and I hope you’re now having fun with your LaunchPad.

-NJC

My LaunchPad is Here!!!!

Quick update post, my LaunchPad is here! Can't wait to get home to play around with it! Expect a Getting Started guide soon which will walk you through programming the device, no theory will be covered in that post. A bit of theory will come later.

For anyone who is interested (and speaks German or can use Google Translator), I found a really good website about the MSP430 with some VERY interesting application notes using a VERY cool custom dev board. If anyone can find a place to buy this board, let me know. From what I've read, they are not selling their board. They also have some information on getting an MSP430 up and running on Linux using GCC which might be the best tutorial for doing this. I know there's a few of you from Germany from my Google Analytics report, if anyone knows of any other good resources in other languages, post away! Just so everyone knows though, Google Translator messes up quite a lot with grammar when translating German, so just keep this in mind.

YAY LAUNCHPAD! :-D

Next post coming soon...

Tuesday, July 13, 2010

New Board!?!?

Wooops. So I decided to try out that half off MSP430 tool coupon on the TI site, since I bought my LaunchPads from Digikey (hoping they had some in stock). I was looking around thinking I might buy the ez430 Chronos or just the ez430 wireless chip board, but stumbled on something greater. Now, to be honest, this is not something I would have ever paid full price for since I do not think it’s worth the $75; $37.50 on the other hand, well, was too tempting to pass up.

So, the project I am working on needs to send data at fairly quick rates to the PC over a USB interface, and is going to need a USB solution somewhat soon. I need something cheap, easy, and with a fast data throughput (along the order of 5Mbps or so). FTDI devices are nice, I've worked with them before but I never have gotten the devices working that fast (at least easily and reliably). Since I need such a fast throughput, UART and I2C were out of the question, I decided to look for other solutions than FTDI.

I want to keep this post short, so I will get to my point. I bought the zif socket for the 5xx chip I was planning on playing with soon. I was really was not looking forward to doing the dead bug technique thing, or making a board specifically to prototype this small SMT device. For $75 this devices has a ZIF socket, which for those who don’t know is like a DIP socket, but way easier to use and you have less of a problem with LEADs. The big benefit here is that you DON'T need to solder the SMT device (which is quite difficult to do without the correct tools or some ingenuity), this is great news! I can even try out different devices that come in the same package. The board comes with two MSP430F5528 chips.

Here's the real kicker and why I'm writing about it in my LaunchPad blog. THE LAUNCHPAD CAN PROGRAM IT!!! (I hope) Theoretically the device is supported by the LaunchPad, but before looking at the socket board’s schematic I thought I would have to wire something up myself from some output pins. Turns out the device not only has a USB connector soldered on with ALL the supporting hardware, including an anti ESD device (WOW!), but it also has the 6 pin header for SBW! So you guessed it, I ordered another LaunchPad while I was at it (the underlying reasons why I got another one are a bit complicated and not technical).

So before I end I want to leave you all with an important concept my Dad thought me when I was young (which I ignore sometimes we all do with certain things). Do your research, before you buy anything no matter how inexpensive it is. Can you use what you want to buy? Will it do what you expect? There's nothing worse than buying a $50 board or even a $4.30 board that you expect to do something and it doesn't. Sometimes it's not even about the money but more about the time you wasted. Time is money after all, right? So to make sure I was getting something I could work with and use I read all the white papers TI had on the chips that came with the board, and the board itself before I decided to buy it, and I recommend that you all do that before buying anything. Here's an example of one interesting article I read about the 5xx device and USB. A future blog will talk about how to read data sheets and make sense of all this nonsense companies put in their files.

A bit about what I plan on doing with this board and what you all can plan on seeing from me in the future. First I plan on getting the new chip and board I ordered up and running with the LaunchPad and doing all the first basic "hello world" programs to test the buttons, LEDs, and whatnot. I will also be setting up a simple program which uses the USB device such as a simple mouse or keyboard eventually, which will build up over time to a fully fledged (hopefully at 12Mbps) data streamer. I will then talk about how I will interface this into my current project. It goes without saying that I will be providing code, schematics (where applicable), and discussing any problems I faced while doing this. I might even describe a bit of theory if I can do it without being too boring.

The Future

So, the next post will most likely be about ADCs and Aliasing. If not, that post will come eventually. Also, I have set up FeedBurner to monitor the feeds for this blog; please let me know if you guys have any problems with this from an end user perspective since I've never used it before. As always, more comments! :-P

If I get up to 100 subscribers I will make a Twitter, or something else cool for everyone, maybe a forum or some kind of competition with prizes even, if this gets big enough. It’s well on its way! Thanks everyone for hanging in there so far (speaking of which, so much for my "short" post) while we wait for our LaunchPads. After all, that’s what we are all here for. Applications and projects using the LaunchPad will be coming soon. Promise.

Important Update from TI

I am in the processes of editing my next post and it will be posted soon. I'm writing this because today I stumbled on an important bit of information I thought everyone should know right away. The code that comes with the LaunchPad has an error which causes the UART to not work 100% correctly. It seems as if some boards still work with the faulty code, but some do not. Again, this is not a hardware issue (it seems?) but a software issue.

The reason why I am writing to you is to provide the updated code since TI has NOT updated this yet on the Wiki. This is understandable, and I'm sure it will be updated soon but here is a sneak peak I guess at the second version of the test program.

Click this here to see the new main.c program or click this link to see the original forum post on TI's website. After my next post I might write a blog post where I work through this example code and explain how it works.

Edit: I just want to let everyone know that I might have gotten some of (or all of?) this information wrong. I'm looking into it now, but I just wanted to keep everyone updated. See this forum link.

Monday, July 12, 2010

Equipment for Everyone

This post will be about setting up your workstation at home cost effectively. This comes as a request from one of our readers. Thanks Nathan for the feedback!

Before I start, in the future this blog will be focusing more on the LaunchPad and MSP430 devices (once I get my board). Hang in there if you are waiting for MSP430 code and projects, it will come.

So… It was very hard for me when I setup my lab at home due to how little money I had. The most cost effective way to build up a lab is slowly over time as you progress in your knowledge, which is what I’ve done over the last 10 years or so. But what about if you want to go all out right away and not built up your lab over time? I'm actually in the process of updating my tools since I won't have my universities labs available to me anymore quite soon.

The following is a list of all the main tools that someone who's working with electronics would want. Some of them are quite expensive and out of the price range of most hobbyists or students. All of these will find their uses with the LaunchPad and any development board.

1. Power Supply
2. Digital Multimeter (DMM)
3. Oscilloscope (Scope)
4. Signal Generator
5. Logic Analyzer

The two most important ones which everyone should have is a Power Supply and a multimeter. One important thing to note is that good professional versions of all of these tools are out of the price range of most people. I would love to have the $5000 scope or the $500 power supply I use at work on my home bench. Not gonna happen anytime soon.


Power Supply

A power supply is important because it makes prototyping easier, I would hate if I had to worry about batteries, voltage regulator circuits and the like every time I wanted to prototype something. One nice tip I learned throughout the years is to use a computer power supply unit (PSU) as your power supply! They are very cheap and provide stable and high current power! You get 12V, 5V and 3.3V supply, what else do you really need?? If you do need other voltages I will show in a future blog an easy way to get voltages without a voltage regulator if you’re using a power supply. Just be careful if you are using one of these since they can provide a super high current, it might be beneficial for you to put in a separate fuse to protect your circuits (somewhat).

There are a ton of websites online that detail how to do this safely and whatnot, so I will not be going over this here. Here's a website I quickly found on Google. I'm going to find a way soon for comments to have pictures so anyone who has one of these up and running can post their pictures.

Look into getting a power supply if you don't have one, I could not live without mine.


Multimeter

Everyone needs a multimeter, even people who only work with digital electronics such as FPGAs. A multimeter is the most important tool you will ever own. It measures AC and DC voltages, AC and DC currents, and resistance. Newer more expensive models also do all kinds of things such as measure capacitance, inductance, and frequency.

You will need one to troubleshoot your circuit anytime something goes wrong. I'm a huge proponent of ALWAYS testing your power supply voltages before and after you hook it up to your circuit. This makes sure you do not blow your chip because of a stupid power supply mistake. Recently not using a multimeter halted my entire project since my meter broke; I decide to just trust my power supply, big mistake. For some reason my supply was wrong, and blew my MSP430 and ez430 programmer. It's not fun when that happens, trust me.

Now, about what multimeter to get; this is a tough question to answer. There are the cheap $3-$10 multimeters out there, that might suit your purposes but they are quite unreliable and prone to failure. If you have ever seen Daves EEVBlog he has quite a few episodes about cheap multimeters and the higher end multimeters. Sure, I'd like to have the Fluke multimeters (they are the best name brand), but I can't afford one. So I have mixed feelings about these cheap multimeters. I would recommend getting one if you’re a hobbyist and you realize it’s not going to be too accurate and could mess things up. Getting a wrong reading will not cost you thousands or millions of dollars as it could in a company. What am I doing to do? Well, I ordered a cheap $3 multimeter from eBay, and I'm also planning on getting one that’s in the price range of $40-60 or so that I can rely on. But to start out use your judgment. Keep in mind though that you can really get screwed with a $5 multimeter.


Oscilloscope

Oscilloscopes are in my opinion the coolest, best, and most useful tool you will ever have. I wish I had my own, but I can't rationalize spending the money on one when I can just use one at work, or go to the school labs. I won't talk much about scopes here, but I will say that Dave's EEVBlog has some interesting reviews on a really cheap ($400...who decided that was cheap?) scope from Rigol. I think it was his first blog. You can buy a PC based scope but I don't recommend it, save your money for something worthwhile (like a cool development kit).

It's possible to use your soundcard as a scope by using the microphone input. There are a few challenges with this though, the first being the voltage. You have to make sure the size of your signal will not exceed what voltage your sound card can handle. The second and major thing which turns most people away from this is the limitations in the bandwidth of the soundcard. I will not talk about this here since again, there is more than enough information on the internet about this. Google away.


Signal Generator

This is a very useful tool if you are working with analogue applications such as sensing or filtering. This is a hugely valuable tool, somewhat more so in my opinion than an oscilloscope when working on hobby projects. This is due to the fact that when you work with microcomputers you can easily get by without a scope, but if you are working with an ADC it is almost 100% necessary to have an input signal to test your code and hardware with. Aliasing can be annoying for sure; having a signal generator can help you make sure you won’t be aliasing. I will be writing a post later about using the ADCs in the MSP430s specifically, and will mention aliasing a bit.

That being said, signal generators are quit expensive so I do not have one. What do I use to test my ADC and filters when I can't make it to the labs at school or work? I use my sound card. Again, the sound card is a really cool piece of hardware which can do a lot of things! The limit of the soundcard though is that you have to work in the frequency ranges supported by your card; in most general cases that is more than enough to test an ADC or filter.

How do I generate my signal? Well, I use Matlab to do it since I do not like any of the software I have found which do this for you. In Matlab it is stupid easy to generate any arbitrary waveform (as long as you stay in the soundcards bandwidth) and play it. For those of you with Matlab, look into the command 'wavplay'.

One problem I have had with setting this up though, are weird ground loops with references on my ADC. Discussing that should be a blog in itself, so all I will say for now is be careful with your reference voltages and grounds when using the sound card as a signal generator. A cheap way to set this up is to just pull apart old headphones and solder nice connectors on the end.


Logic Analyzer

If you do a lot of work with microcomputers or FPGA's, consider buying one of these. Professional models are quite expensive but you can buy many computer based ones for quite cheap. I use Saleae's Logic which costs $150, and is well worth it in my opinion despite the few things I really don't like about it. It makes debugging chips and communication buses very very easy. I could not imagine developing for a microcomputer without it; that being said, I developed without one for years so it is not 100% necessary, it just makes life easier.


One of the first things I will do after I get the blinking light program running, is to verify that the SBW is working on the connector on the board so I can hook it up to my MSP430F2013 chip, using my logic analyzer. This can also be tested with a multimeter. One of the most useful things a multimeter has is the continuity check. I rarely use this to check diodes; I mostly use this to find which pin is connected where in complex designs with many wires. This is VERY useful for debugging and this technique should be always kept in mind.

So, this post is already quite long, longer than I would like it to be; the longer it is the less people will read it. I will be talking about getting a good set of components for development and using a breadboard and all that good stuff in a future post. I also will talk about soldering equipment and building PCBs and how I think this should be done in another post.

Comments, I love them. Help me out, what I am doing wrong? What am I doing well? Topic suggestions? Anything? I'll be keeping a list of topics and will be widdling away at them as time continues. Every now and then I might put up a pole as to which topic should be next.

Till next time.

-NJC



PS: Some unrelated World Cup humor for anyone who watched the final match.

Saturday, July 10, 2010

So, What's next?

I would like to write one or two more posts while we are waiting for our LaunchPads to come in. I have been throwing a few ideas around in my head about what to write of next, and can't decide; so I thought I would ask anyone and everyone who reads this blog to give me their opinions (I know your all out there, Google Analytics says so :-P )


I have four ideas so far:

1. Peripherals and Microcomputer Architecture - This would talk about some theory behind RISC processors and also would talk about the peripherals that come with our MSP430s (and other µCs).

2. How to Read Data Sheets and User Guides - I would go over the TI data sheets and user guides and give tips on how to get useful and meaningful information out of them.

3. Useful Tools and Practices - I can talk about the equipment I use during development, all of the equipment I have comes from a "student budget", which is probably less than the average hobbyiest (maybe not, who knows?).

4. My Take on Microcontrollers and TI - I can discuss what I think about the MSP430 compared to other chips, and talk about where I see things going in the future as far as µCs goes.


Whatever you guys would like me to write about I will. This blog can go in any direction pertaining to the MSP430 and LaunchPad. Maybe someone has something particular they would like me to write about other than these three things. I'm actually hoping for some suggestions and constructive critisim about my blog (even if it is about my bad grammar). If I don't hear any feedback, expect to see one of those four ideas posted somewhat soon.

The goal here is to start up a nice community around the MSP430. In the past I've seen a chip become popular because there was one place with nice information about it that people can get started with. From there a community will build up. I've set it up so you don't have to register to make comments, so please, comment away.

PS: I'm working on changing the hyper-link color since I know it's hard to read on the dark background (at least it is for me).