MSP430

From Hackerspace ACKspace
Revision as of 13:38, 11 June 2011 by PsychiC (talk | contribs) (How-To)
Jump to: navigation, search
Project: MSP430
Featured:
State Active
Members
GitHub No GitHub project defined. Add your project here.
Description MSP430 16bit ultra low-power microcontroller
Picture
No project picture! Fill in form Picture or Upload a jpeg here

intro

Stolen from TI's wiki page:

"The MSP430 is a 16-bit, ultra-low power, mixed signal microcontroller from Texas Instruments. The strengths of the MSP430 lie in its easy-to-learn, C-compiler friendly, 16-bit CPU partnered with flexible low power modes and intelligent, low-power peripherals. As a catalog market product, its versatility is applied across a number of different end-equipments including medical equipment, electricity and sub-metering, and home appliances such as smoke detectors, thermostats, etc... With over 230 parts available, there is likely to be an MSP430 for almost any application."

More information at ti.com/430value

MSP430 LaunchPad

The space got two Texas Instruments MSP430 LaunchPad development kits donated, free for use within the space.

Each LaunchPad kit includes the following:

  • Quick start guide
  • MSP-EXP430G2 development/debugging PCB
    • MSP430G2231 IC (included on the PCB)
    • MSP430G2211 IC
  • 2x 10 pins header M/F for extension boards
  • micro crystal 32.768kHz
  • USB->mini-USB cable

See ti.com/launchpadwiki for more information

project

There is a rumour that the first person who writes a useful program on the MSP430 will get a month free access to ACKspace! ask the board for details.

Hint: the space could really use an automated window blind control mechanism, which includes the blinds/awning outside (controlled by the rotary momentum switches per two windows, overridden by a fubar central control)


How-To

Based on Debian 6.0

Most info from [1]

INSTALLING :

# Install required packages:

    sudo aptitude install git-core gcc-4.4 texinfo patch libncurses5-dev zlibc zlib1g-dev libx11-dev libusb-dev libreadline6-dev

Download and compile mspgcc:

    git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4
    cd mspgcc4
    sudo sh buildgcc.sh 


Press enter to use the default answers when the scripts ask you. 
Only write yes when it ask “Do you want to start build right now? (y/n) [n] ” because the default is no.
ATTENTION this will take some time depending on the speed of your machine (30-60min)


# Download and compile mspdebug:

    wget -O mspdebug.tar.gz http://sourceforge.net/projects/mspdebug/files/latest
    tar -zxvf mspdebug.tar.gz
    cd mspdebug
    make
    sudo make install

# Create a udev rule to be able to use the usb debug shield

    sudo nano /etc/udev/rules.d/46-TI_launchpad.rules

Now paste inside the following rule:

ATTRS{idVendor}=="0451", ATTRS{idProduct}=="f432", MODE="0660", GROUP="plugdev"

Restart the udev service:

    service udev restart

COMPILE / RUN :

# Compile the source code and create de elf file data to be uploaded to the chip:

    /opt/msp430-gcc-4.4.5/bin/msp430-gcc -Os -mmcu=msp430x2231 -o led.elf led.c

# Connect the platform to the pc and upload the program to chip:

    mspdebug rf2500
    prog <.ELF FILE>
    run


PROGRAMS :

Counter : Loop Lights no LED, red LED, Green LED, Both LEDs

Code dirived from blinking led sample.

counter.c


#include <msp430g2231.h>

/** Delay function. **/
delay(unsigned int d) {
  int i;
  for (i = 0; i<d; i++) {
    nop();
  }
}

int main(void) {
  int i;
  WDTCTL = WDTPW | WDTHOLD;
  P1DIR = 0xFF;
  P1OUT = 0x01;
 while (1)
  {
   for (i = 0 ; i<4 ; i++) 
    {
    int table [4] = {0,1,64,65};
    // get values from table
    // 0 = off , 1 = red , 64 = green , 65 = both
    P1OUT = table[i];
    delay(0x4fff);
    delay(0x4fff);
    delay(0x4fff);
    delay(0x4fff);
  }