Search Microcontrollers

Friday, June 8, 2012

MSP430G2 Tutorial - Microcontrollers

Hello,
I am learning to use & program the MSP430G2 microcontroller from Texas Instruments, so I thought I could write down my notes here as I am planning to use them for reference in the future, plus they might prove useful to others.
For this last reason I will add some background information, to make my minutes usable by others willing to learn.

Basic Concepts

You should be familiar with teh concept of what a microcontroller is, if not you should check here : http://en.wikipedia.org/wiki/Microcontroller

To put it plain simple a microcontroller is a microprocessor to which a number of different peripherals were added.
Each model has it's own mix of peripherals, providing different functionality, however the main "building blocks" you can expect to find are :
  1. Flash memory to store the code that will be executed
  2. RAM to store variables needed by your program
  3. Clock Systems : one or more are provided to service the CPU and it's peripherals. ome may use external crystals, some others might be "self contained"
  4. Timers to count delays, activate something periodically etc
  5. A Watchdog : a special timer that monitors the status of the code execution and resets the MCU if it appears "stuck"
  6. Serial communication (typically TTL UARTS, SPI, I2C)
  7. GPIO (General Purpose Inpu Ouutput) : allows to write or read digital signals
  8. ADC (Analogic To Digital Converter) : commonly a 10bit ADC to read analogic inputs, usually from sensors (temperature, voltage, current etc..)
  9. PWM (Pulse Width Modulation) : used to dim lights, drive electric motors etc.. 
  10. ....
Development boards

Normally microcotnrollers are programmed using a JTAG interface (http://en.wikipedia.org/wiki/Joint_Test_Action_Group) which is typically based on a SPI serial protocol (http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus).
This means that a "programmer" device is needed to send the firmware to the MCU, however for all the available MCU some dev boards were created, containing already the programmer circuit.
The most common solution nowadays is include a USB connection that emulates a serial port using FTDI chips (http://en.wikipedia.org/wiki/FTDI).

The MSP430G2 has a cheap and simple dev board created by Texas Instruments, called the "Launchpad".
www.ti.com/launchpad

Programming

Normally the software is created on a PC based IDE (there are various environments, some Opens Source, some proprietary, that support different devices) and then transferred (uploaded) into the flash ram of the MCU device, via USB cable.
The mainly used programming languages are C (ANSI C, not C++) and Assembly.
Being able to program an MCU requires a good understanding on how the hardware works and how the software can drive the various components of the MCU.
To turn on / off or to configure the peripherals the MCUs provide specific "registers", which are memory locations in which each bit has a specific function.
Since there might be hundreds of those individual bit "switches", normally a header file (.h) is provided so that they can be addressed by name.  

The best ide to work with the Launchpad is Code Composer Studio, which is based on Eclipse.
It can be downloaded here : http://www.ti.com/tool/ccstudio
It normally requires a license, but not for the MSP430G2, since the "code limitation" option is totally fine with these processors.

A great workshop which will be used as a reference in this tutorial can be found here : 

The present tutorial, in the next lessons, aims to provide further explanation on the topics covered by the launchpad workshop.
I strongly recommend to watch, at this point the introductory video of the workshop.


video platformvideo managementvideo solutionsvideo player
and



video platformvideo managementvideo solutionsvideo player
   
  

No comments: