-
Home
- Elec 220 lab course (escape)
- Elec 220 lab course (escape)
- Lab 3-2 digital input and lab
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:
- 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
the diagram of the digestive system
allimentary cannel
Ogenrwot
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
Genetics is the study of heredity
Misack
how does twins formed?
Misack
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
the study of living organisms and their interactions with one another and their environments
AI-Robot
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Diversity of living thing
ISCONT
Cell division is the process by which a single cell divides into two or more daughter cells. It is a fundamental process in all living organisms and is essential for growth, development, and reproduction. Cell division can occur through either mitosis or meiosis.
AI-Robot
life is defined as any system capable of performing functions such as eating, metabolizing,excreting,breathing,moving,Growing,reproducing,and responding to external stimuli.
Mohamed
Got questions? Join the online conversation and get instant answers!
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.