<< Chapter < Page Chapter >> Page >
Using the MSP-EXP430FG4618 Development Tool and the eZ430 kits blink the LED1.

Laboratory gpio: lab1 - blinking the led

Introduction

The hands-on laboratory consists of configuring the I/O ports, setting up the input lines to read push buttons and the output lines to feed LEDs. The following exercises have been developed for the three hardware development tools.

The first to be discussed is the MSP-EXP430FG4618 Experimenter’s board. Modifications are later made to suit the other development boards. The main differences between the boards are related to the specific ports in which the buttons and LED are (or can be) connected. For the development of this laboratory, Code Composer Essentials v3 has been used.

Procedure

By analysis of the schematics, determine which I/O port pin is connected to the LED on the board:

- Consult the MSP430FG4618/F2013 Experimenter’s Board User's Guide slau213a.pdf

- LED1 is connected to Port 2.2

- Consult the eZ430-F2013 Development Tool User's Guide slau176b.pdf

- LED1 is connected to Port 1.1

- Consult the eZ430-RF2500 Development Tool User's Guide slau227c.pdf

- LED is connected to Port 1.0

Include the standard register and bit definitions for the TI MSP430 microcontroller device (example for the MSP430FG18/MSP430F2013 Experimenter's board):

#include<msp430xG46x.h>

Define the main routine:

void main (void){

The watchdog timer must be prevented from generating a PUC. Write 0x5A to the eight MSBs of the Watchdog timer control register, WDTCTL:

WDTCTL = WDTHOLD | WDTPW;

Port control registers:

- Set the LED port pin as an output;

P2DIR: Port 2.2 is set as an output:

P2DIR |= 0x04; // to force the pin setting. It is uses an OR operation ( | ) with P2DIR and 0x04

Use an infinite loop to modify the state of the port;

Use a software delay loop to generate the pause interval. (a long software delay loop is used here for simplicity - in real applications, a timer would be used)

- Because no clock is defined, the device will use the 32.768 kHz watch crystal. In order for a rate of one blinking LED state transition each second, the software delay loop should count to approximately 30000 {30000/32768 = +/- 1 sec};

volatile unsigned int i;

while(1){ //Infinite loop i=30000; //Delaydo (i--); while (i !=0);

- Port control registers inside the loop:

P2OUT: To switch the port state between low and high state during program execution:

P2OUT ^= 0x04}}; // It uses an XOR operation ( ^ ) between P2OUT and 0x04:

- The programming code for the other hardware kits follows the same sequence as given above, requiring only configuration the port.

This example and many others are available on the MSP430 Teaching ROM.

Request this ROM, and our other Teaching Materials here (External Link)

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials. OpenStax CNX. May 19, 2009 Download for free at http://cnx.org/content/col10706/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials' conversation and receive update notifications?

Ask