<< Chapter < Page Chapter >> Page >
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.2i=1500; // Delay, button debounce do (i--);while (i !=0); while (! (P1IN&0x01)); // Wait for the release of the button i=1500; // Delay, button debouncedo (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 (External Link)

Questions & Answers

what is mutation
Janga Reply
what is a cell
Sifune Reply
how is urine form
Sifune
what is antagonism?
mahase Reply
classification of plants, gymnosperm features.
Linsy Reply
what is the features of gymnosperm
Linsy
how many types of solid did we have
Samuel Reply
what is an ionic bond
Samuel
What is Atoms
Daprince Reply
what is fallopian tube
Merolyn
what is bladder
Merolyn
what's bulbourethral gland
Eduek Reply
urine is formed in the nephron of the renal medulla in the kidney. It starts from filtration, then selective reabsorption and finally secretion
onuoha Reply
State the evolution relation and relevance between endoplasmic reticulum and cytoskeleton as it relates to cell.
Jeremiah
what is heart
Konadu Reply
how is urine formed in human
Konadu
how is urine formed in human
Rahma
what is the diference between a cavity and a canal
Pelagie Reply
what is the causative agent of malaria
Diamond
malaria is caused by an insect called mosquito.
Naomi
Malaria is cause by female anopheles mosquito
Isaac
Malaria is caused by plasmodium Female anopheles mosquitoe is d carrier
Olalekan
a canal is more needed in a root but a cavity is a bad effect
Commander
what are pathogens
Don Reply
In biology, a pathogen (Greek: πάθος pathos "suffering", "passion" and -γενής -genēs "producer of") in the oldest and broadest sense, is anything that can produce disease. A pathogen may also be referred to as an infectious agent, or simply a germ. The term pathogen came into use in the 1880s.[1][2
Zainab
A virus
Commander
Definition of respiration
Muhsin Reply
respiration is the process in which we breath in oxygen and breath out carbon dioxide
Achor
how are lungs work
Commander
where does digestion begins
Achiri Reply
in the mouth
EZEKIEL
what are the functions of follicle stimulating harmones?
Rashima Reply
stimulates the follicle to release the mature ovum into the oviduct
Davonte
what are the functions of Endocrine and pituitary gland
Chinaza
endocrine secrete hormone and regulate body process
Achor
while pituitary gland is an example of endocrine system and it's found in the Brain
Achor
what's biology?
Egbodo Reply
Biology is the study of living organisms, divided into many specialized field that cover their morphology, physiology,anatomy, behaviour,origin and distribution.
Lisah
biology is the study of life.
Alfreda
Biology is the study of how living organisms live and survive in a specific environment
Sifune
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

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