This post has been written by a new author, Chahat Ahuja. Give him heads up if you like this post.
Dear readers, please note that this is the old website of maxEmbedded. The articles are now no longer supported, updated and maintained. Please visit the new website here and search for this post. Alternatively, you can remove .wordpress from the address bar to reach the new location.
We apologize for the inconvenience. We just want to give you a better viewing and learning experience! Thanks!
Hey folks, I know you have a habit of seeing AVR microcontrollers related tutorials on maxEmbedded, but trust me, maxEmbedded is going to be full of surprises. This is my first post and it is going to be about MSP430, a 16 bit microcontroller family by Texas Instruments.
Pre-requisites: Basic knowledge of micro-controllers and embedded systems, Familiarity with terminologies related to computer architecture.
- MSP430 – An Introduction
- Central Processing Unit
- General Pin Configuration of MSP430
- Software Support and Development Environment
- MSP430 Evaluation Modules and Development Boards
MSP430 – An Introduction
“MSP430” interesting name, isn’t it? Want to know what it stands for? Well, MSP stands for Mixed Signal Processing. There are three types of signal processing techniques we generally deal with, namely, Analog signal processing, Digital signal processing and Mixed signal processing. Thus, the MSP430 family supports Mixed Signal Processing, making your tasks easier. To have a fuller idea about the nomenclature of the MSP family check out this wikipedia page.
What MSP430 has in package?
Recently, Apple Inc. launched its new Apple iPhone 5S, which runs on a 64-bit Micro-Processor Unit, the first of its kind mobile phone to run on a 64-bit architecture. The earlier ones used a 32-bit architecture. To know more about what 8 bit or 16 bit micro-controllers actually mean, read Mayank’s post on basics of microcontrollers. an MSP Micro-Controller is a 16 bit Micro-Controller, which means that it has 16 bit wide address and data buses. So, in a layman’s language, we can say that MSP is twice as fast as the AVR, in terms of processing (not always the case though). You can roughly relate this to your computer, which is probably a 32-bit or 64-bit machine. It may look confusing to a person who has a habit of using 8 bit controllers, but the fact is that it is much more convenient to use a 16 bit controller. Let us look at some highlights of the MSP430 family:
- Von Neumann Architecture: It is modern processor architecture which has shared memory for both data and instructions. This is in contrast to Harvard architecture, which has separate memories for instructions and data. In some systems having Harvard Architecture, instructions memory can be Read only memory. The following diagram shows the difference between Harvard architecture and Von Neumann architecture.
- RISC architecture: RISC expands to Reduced Instruction Set Computer. In simple language, hardware simplicity has been compromised to provide software simplicity.
- Bus width: 16 bit address and data buses.
- Memory access range: 16-bit Micro Controller Unit, hence it can address 216 = 64 kB of memory.
- Several low power modes: typical being 1µA, 3.3 volts consumption in idle mode.
- It has an internal Digitally Controlled Oscillator (DCO) oscillating at 1 MHz. An External Crystal Oscillator can also be used. MSP Controllers should be made to work at 32.768 kHz, when we need to provide a very accurate timer. This is because when we use 32.768 kHz, by the time the timer overflows, it is exactly and accurately 1 second. Can anybody figure out why?
- Timers available with PWM (Pulse Width Modulation)
- Selection of Analog to Digital Converter with a resolution of 10/12/14/16 bit.
Central Processing Unit
The general purpose of any CPU is to execute the instructions and store data in the memory. For that, it takes help of the ALU – Arithmetic Logic Unit, which performs all the calculation and computation for the CPU.
Let’s consider a CPU-industry analogy. Whole process of CPU works like an industry; just consider you have an industry for manufacturing goods. For that you need raw materials which are provided by a store called memory. Now the raw material is brought to the industry by a transport facility called data bus. Now the question arises, how will one know about which raw material you need or where it is placed and when do you need it? These are managed with two transport facilities namely control bus and address bus. Now, with the help of tools and machines called ALU, you have made the goods and you have to transport it back to store which is again done by data bus.
To control any operation, we need some special memory units, which holds which work to be done next and how it should be done etc. These memory units are present in CPU and are called registers. Registers are small size memory units which can be well described as the set of cells where each cell can hold one bit data i.e. either 0 or 1. For more generalized idea about registers, go ahead and read the first half of Mayank’s post, and then get back here. The width of registers in MSP430 is 16 bit which means each of the register can hold 16 bits of data. If you have worked with AVR, CPU register holds 8 bits of data. But in MSP430, CPU registers are 16 bits wide.
Some of the registers which is used by CPU very frequently are as follows–
- Program Counter, PC/R0
- Stack Pointer, SP/R1
- Status Register, SR/R2
- Constant Generator, CG2/R3
- General Purpose Registers, R4 to R15
We get 64kB of memory space in MSP430 i.e. address range is
0xFFFF which has been divided into several types of memories. So, we will have a brief look on the types of memory, we get in MSP430–
- Special Function Registers: It is mostly used to enable the registers which are associated with particular functions. For example, there is a register TACCR which is related to Timer A of MSP430. Setting some bits of this register can enable or disable timers and its modes.
- Peripheral Registers: These are actually used for communication between CPU and peripherals but are not used much a general user.
- RAM – Random Access Memory: All of us pretty aware of this type of memory. It is the memory space where variables are stored for operations.
- Bootstrap Loader: Now this is something which connects your controller with your personal computer. It contains the program to communicate using a serial protocol.
- Information Memory: It is flash memory which is used for storage of non-volatile data. It may have some kind of serial code to identify the equipment.
- Code Memory: As the name says, from where your controller reads the executable code or some constant values.
- Interrupt and Reset Vectors: This memory is utilized for handling interrupts or exceptions when normal operation of processor is interrupted. Reset is example of interrupt which has the highest position in Interrupt vector table. Vector table will be explained in future posts. 😀
All the members of MSP430 family almost have similar memory map which is shown in the following figure.
When you buy a laptop or a personal computer, the sales person says it has i3-2310m, 2.1 GHz, RAM 4 GB etc. But what is this 2.1 GHz? It is clock of the computer which wakes the computer 2.1 giga (billion) times a second. Faster the clock, faster will be your computer. The foremost purpose of clock in any embedded device is to synchronize the processes. There are three types of clock in MSP430 family:
- Master clock, MCLK: As name says, it is used by CPU and a few peripherals.
- Subsystem Master Clock, SMCLK: It is distributed to peripherals.
- Auxiliary clock, ACLK: It is also devoted to peripherals.
ACLK comes from low frequency crystal oscillator, typically at 32 KHz attached externally. Both MCLK and SMCLK are supplied by an internal digitally controlled oscillator (DCO) which usually generates pulse of 1 MHz.
General Pin Configuration of MSP430
The following diagram show the pin configuration of 14 and 20 pin DIP of MSPG2xx. Most of the members of MSP430 family share similar pin configurations. 14 pin and 20 pin Dual Inline Package (DIP) ICs have been shown in the following picture.
SMD (Surface Mounted Device) ICs for these microcontrollers are also available and are very useful if you want to make your circuit really small. If you are not familiar with SMD components, you can estimate the size of SMD component by following picture of two MSP ICs.
Yeah, these are MSP430G2102 ICs on my finger tip! 😀
Software Support and Development Environment
Consider the CPU-industry analogy once again. CPU is the hardware, just like industry is the place where you can find machines and tools, but to run that machinery you need engineers and workers there. Similarly, for a CPU to work, it needs software. In case of a PC, it is Operating System (OS) which tells CPU about the work to be done, priorities to be set, interrupts to respond, etc. For a microcontroller to work, no such operating system exists (well actually, there are some, like FreeRTOS, where RTOS stands for Real Time Operating System, which is designed to operate on bare hardware like microcontrollers). We write the instructions in form of assembly language or some high level language like C/C++ to tell the CPU of microcontroller how to operate. So, it is basically like you are making your own small sized computer, which can serve you for a particular task. Does it sound interesting?
Now the question is, where you are going to write the code and how you are going to transfer this code to your hardware? Also, it is not like just writing the code. If you have worked with microcontrollers before, you must be familiar with terminologies like code building, compilation, debugging, simulation, etc. You can have a look at the microcontroller based development process at the end of this post by Mayank. Though it mostly deals with AVR microcontrollers, the concepts hold good for any microcontroller, even MSP! Well, these are the necessary steps before you burn your controller with your code. Usually, these all steps are combined into an Integrated Development Environment (IDE). It keeps all paths of your linkers, libraries, source files etc. Sometimes, Flash Programmer which downloads or burns the code into the IC comes with IDE itself. Those who have worked with AVR must have worked with software like AVRDude or eXtreme Burner, to burn their code into controllers. To build and burn the codes in MSP430, there are two major IDEs are available.
- IAR Embedded Workbench Kickstart: I personally like this one, so, I will be writing my future posts on this only. It can be bought from IAR Workbench’s website but its limited versions are also available in two ways. One is limited version which stays for 30 days; another is a version with more limitations but with no time limit. I will suggest readers to subscribe the limited version with no time limit. The main limitation of this version is code limit which is limited to 4 KB of C code which is enough for learning purposes. To know more and download the software, visit IAR systems web page.
- Code Composer Essential Evaluation: Those who have worked with Code Composer Studio for its DSP chips, then you can estimate its working. Anyways, free version of CCS is made available by Texas Instruments, but code size is limited to 16KB of C code. Its installation file size is around 2 GB in comparison with IAR which has size of around 300 MB. To know more about CCS and download the software, visit TI’s webpage.
Please note that, you may get problems while trying to install either of the above software with Windows 8, but both of them work perfectly fine in Windows 7 and Linux.
MSP430 Evaluation Modules and Development Boards
Now that you have gotten a little idea about MSP430, it’s time to get your hands on some of the development boards and platforms. Texas Instruments sells the MSP430 development board with the name ‘LaunchPad’. Two types of LaunchPad are commonly available for beginners by TI. One is ‘MSP430G2 Value Line LaunchPad’ and another is ‘MSP430F5529 USB LaunchPad’. MSP430F5 series is more advanced as compared to MSP430G2 series in terms of more flash memory, more space for RAM, Timers and 12-bit ADC resolution as compared to 10-bit resolution of MSP430G2 series etc. The full comparison between these two LaunchPad is given in detail here by Texas Instruments.
MSP430G2 Value Line LaunchPad is the cheapest development board available by Texas Instrument. And it comes with 14 and 20 pin DIP target socket in which you can drop any 14 or 20 pin DIP MSP430 device and start developing your application. After you program the device, you can use it as a standalone system and put it in custom printed circuit board or breadboard. You can go for MSP430F5529 USB Launch pad if you need more number of General Purpose Input/Output (GPIO) pins, better ADC resolution, more RAM etc. It clearly depends upon the application where you are going to use the controller. You can buy any of these LaunchPad by Texas Instruments here.
So, readers, that was all about the basics of MSP430. Hope you liked my first post. Don’t forget to tell me about your views. I am waiting for your comments and queries. And subscribe to maxEmbedded to stay updated! 🙂
VIT University, Vellore
QC and Edited by–
Mayank Prasad (aka Max)
Arizona State University