<< Chapter < Page Chapter >> Page >
This module goes over the basics of digital I/O and the digital interface between a microcontroller and the outside world.

Basic digital i/o in the real world

In this lab you'll go over the basics of how to setup and use the GPIO on the MSP430. This will allow you to get data from the outside world, run some processing on it, and then output it again as useful information. You only have one task this week:

  1. Coding in MSP430 assembly, write a simple I/O echo program . Setup the GPIO pins and poll the input DIP switches for any changes. Take the input and display it to the output so any changes are immediately reflected. Step through this program to observe how it behaves. Assignment Details

Digital i/o basics

Gpio

    Philosophy

  • The MSP430 uses a limited number of GPIO hardware pins that are assignable to several functions depending on your specific model and your program's needs. For example, our version, the MSP430F5637, can have the pins act as digital output, digital input, or ADC input.
  • The pins are organized into ports, with each port usually one byte (8 bits/pins) wide. On larger versions of the processor (different format chips with physically many more pins...) you can encounter several ports. In this lab our MSP430F5637 has 9 different ports we will use.
  • You can set each pin's function independently (input or output) by modifying some memory mapped I/O registers. Since we want to do both, we will assign different tasks to different pins as needed.

    Usage

  • The I/O ports are memory mapped into the top of the MSP430 address space.
  • There are several registers associated with each port. For now, you only need to worry about six (P4IN, P4OUT, P4DIR, and P9IN, P9OUT, P9DIR).

      P9in

    • The P9IN register is located in memory, which you can refer to using the C symbol &P9IN
    • The register holds the values the MSP430 sees at each associated pin, regardless of the pin direction setting.
    • To read the register, it is good practice to use a mov.b instruction to avoid accidentally reading adjacent registers
    • If you are looking to test or read just the pins set to input, you will have to mask the P9IN register to zero out the other unwanted/output pins. Reading P1IN reads the entire port, regardless of pin direction.

      P4out

    • The P4OUT register is located in memory, which you can refer to using the C symbol &P4OUT
    • If their direction bits in P4DIR are set to output/ "1", the corresponding pins will output the values set in P1OUT.
    • If a pin's direction bits are set to input in P4DIR and its resistors are enabled in P4REN, P4OUT controls the pin's connection to the pull-up resistor. Setting P4REN to "1" enables the pull-up, while setting it to "0" leaves the input to float in a high impedance state.
    • To set P1OUT, use a mov.b instruction to set several pins at once. To set individual bits to "1", you can use an or.b instruction with a "1" in the positions you want to set. To clear individual bits/ set them to zero, use an and.b instruction with mostly "1"s except for a "0" for the bits you want to clear.

      P4dir

    • The P4DIR register is located in memory, which you can also refer to using the C symbol &P4DIR
    • The value of the bits in P4DIR determines whether the MSP430 hardware leaves the pin in a high impedance state where it responds to external voltage changes (which you can read at P4IN), or in a low impedance state where the MSP430 drives the output voltage to a certain value determined by P1OUT.
    • To set the bit directions all at once, use a mov.b instruction, but to change individual bits regardless of the others, use an and.b or a or.b
    • Set the corresponding bits to "0" to set pins to input mode, or to "1" to set them to output mode.

Questions & Answers

what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
How can I make nanorobot?
Lily
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
how can I make nanorobot?
Lily
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Elec 220 lab course (escape). OpenStax CNX. Apr 07, 2013 Download for free at http://cnx.org/content/col11513/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Elec 220 lab course (escape)' conversation and receive update notifications?

Ask