Skip to content Skip to navigation

Connexions

You are here: Home » Content » Laboratory GPIO: Lab3 - Toggle the LED state by pressing the push button

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • TI MSP430 display tagshide tags

    This module is included inLens: Texas Instruments MSP430
    By: Texas InstrumentsAs a part of collection: "Teaching and classroom laboratories based on the “eZ430” and "Experimenter's board" MSP430 microcontroller platforms and Code Composer Essentials"

    Comments:

    "This is an excerpt from the MSP430 Teaching CD produced under TI sponsorship and review at the University Beira Interior in Portugal. The material covers everything from "hello world" on an eZ430 […]"

    Click the "TI MSP430" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Laboratory GPIO: Lab3 - Toggle the LED state by pressing the push button

Module by: Pedro Dinis, António Espírito Santo, Bruno Ribeiro. E-mail the authors

Summary: Use the S1 button in the MSP430-EXP430FG4618 development tool and in the eZ430-RF2500 kit to toggle the state of LED1. You must use interrupts to catch the button press and you should ensure that the MSP430 is in Lower Power Mode 3 when is not in use.

Laboratory GPIO: Lab3 - Toggle the LED state by pressing the push button

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 to which port pin the push button is connected:

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

- Button S1 is connected to Port 1.0;

- Consult the eZ430-RF2500 Development Tool User's Guide <slau227a.pdf>:

- Button S1 is connected to Port 1.2;

- The eZ430-RF2500 uses a device in 2xx family, so you need to additionally configure the button as pull-up or pull-down, in the P1REN register.

Ports control registers:

- Set push button pin port as an input

- P1DIR: Port 1.0 is set as an input:

P1DIR &= ~0x01 // to force the pin setting to 0. It is uses an AND operation ( & ) between P1DIR and 0xFE

- Enable interrupts to this pin port;

- P1IE: Enable interrupt to port 1.0:

P1IE |= 0x01; // Interrupt Enable in P1.0

- PIIES: Call the port interrupt on a high-to-low transition:

P1IES |= 0x01; // P1.0 Interrupt flag high-to-low transition

- Configure the watchdog timer to prevent a PUC during the program execution;

WDTCTL = WDTPW | WDTHOLD; //Stop Watchdog Timer

- Enable Global Interrupts and configure low power mode 3;

_BIS_SR (LPM3_bits + GIE); //Low Power Mode with interrupts enabled

- Create a interrupt service routine, that includes:

- Toggle LED1 pin port;

- Delay for button debounce;

- Clear interrupt flag.

#pragma vector=PORT1_VECTOR
__interrupt void Port_1 (void) {
 volatile unsigned int i;
 P2OUT ^= 0x04;            // Toggle Port P2.2
 i=1500;                   // Delay, button debounce 
 do (i--);
 while (i !=0);
  while (! (P1IN & 0x01)); // Wait for the release of the button
   i=1500;                 // Delay, button debounce 
   do (i--);
    while (i !=0);
    P1IFG & = ~0x01;        // Clean P1.0 Interrupt Flag
}

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

Request this ROM, and our other Teaching Materials here https://www-a.ti.com/apps/dspuniv/teaching_rom_request.asp

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks