Tuesday, December 11, 2012

MSP430

On MSP430 and why it's better than Arduino

MSP430 is a family of 16 bit micro controllers from Texas Instruments. As I'm not a hardware engineer or a really embedded software engineer by trade. I'm mostly interested in the low-cost, educational development boards. Here, the MSP430-based TI LaunchPad  (why did they use that name!) MSP-EXP430G2 board fits the bill perfectly. At the astonishing cost of $4.30 (with free worldwide shipping) it's really the best way, that I know of, to learn about pretty advanced, embedded, low power software. Unlike the ubiquitous Arduino, the family of LaunchPad boards requires some serious learning and has quite decent range of low-level, on-die hardware to work with. You may disagree with me here (Arduino is better in that it does not really require you to learn anything) but the point is that I do want to learn about all that the low-level stuff.


The beautiful hardware

I got my first MSP430-based board over a year ago. During that time, in my limited spare time, I learned about its extremely simple and elegant assembly language, about the way designers exposed all the hardware as memory-mapped registers, about the DMA engine and the several low-power sleep states and many other interesting things. And I found much joy in all of that, as it was the opposite side of the spectrum, filled with my daily duties as a python developer. Here I could cherish each of the 512 bytes of memory (that the particular variant, M430G2553, comes with), each of the 16 registers and all of the carefully crafted 27 instructions. While I got exactly nowhere with actual programming or hardware applications (applying the hardware to solve a particular problem) I did have more fun than I ever did with Arduino.


My learning process

A few months ago I created a small repository called hello-msp430 with a few really basic programs (so far only two, more are on the way) and detailed instructions on how to set everything up. My goal is to document my learning process by writing lots of small programs that use and explain a given piece of hardware (interrupts, timers, watchdog, GPIO pin, etc). If I can explain something then hopefully, I understand it myself. Most importantly all of my examples are designed to work well on free software desktops using free software toolchains  (mspgcc and mspdebug). I found the learning experience somewhat frustrating, finding mostly code and examples that only work with the proprietary IAR and Code Composer Studio IDE/compilers. I did try them out in a virtual windows box but it was annoying and complicated, filled with the kind of software interactions that I don't like.


There's a lot to read

MSP430 is a pretty well-documented piece of hardware, starting with the excellent user's guide from TI that in itself documents virtually everything there is about the hardware, to books and various online community resources. Lately I also came across a large collection of mspgcc tutorials that are a really great read if you don't have any books about the device yet. I really wish the same was true for the new ARM Cortex M4 based micro controllers, that in comparison, are a licensing minefield with no free software ecosystem in sight.