<< 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

A golfer on a fairway is 70 m away from the green, which sits below the level of the fairway by 20 m. If the golfer hits the ball at an angle of 40° with an initial speed of 20 m/s, how close to the green does she come?
Aislinn Reply
cm
tijani
what is titration
John Reply
what is physics
Siyaka Reply
A mouse of mass 200 g falls 100 m down a vertical mine shaft and lands at the bottom with a speed of 8.0 m/s. During its fall, how much work is done on the mouse by air resistance
Jude Reply
Can you compute that for me. Ty
Jude
what is the dimension formula of energy?
David Reply
what is viscosity?
David
what is inorganic
emma Reply
what is chemistry
Youesf Reply
what is inorganic
emma
Chemistry is a branch of science that deals with the study of matter,it composition,it structure and the changes it undergoes
Adjei
please, I'm a physics student and I need help in physics
Adjanou
chemistry could also be understood like the sexual attraction/repulsion of the male and female elements. the reaction varies depending on the energy differences of each given gender. + masculine -female.
Pedro
A ball is thrown straight up.it passes a 2.0m high window 7.50 m off the ground on it path up and takes 1.30 s to go past the window.what was the ball initial velocity
Krampah Reply
2. A sled plus passenger with total mass 50 kg is pulled 20 m across the snow (0.20) at constant velocity by a force directed 25° above the horizontal. Calculate (a) the work of the applied force, (b) the work of friction, and (c) the total work.
Sahid Reply
you have been hired as an espert witness in a court case involving an automobile accident. the accident involved car A of mass 1500kg which crashed into stationary car B of mass 1100kg. the driver of car A applied his brakes 15 m before he skidded and crashed into car B. after the collision, car A s
Samuel Reply
can someone explain to me, an ignorant high school student, why the trend of the graph doesn't follow the fact that the higher frequency a sound wave is, the more power it is, hence, making me think the phons output would follow this general trend?
Joseph Reply
Nevermind i just realied that the graph is the phons output for a person with normal hearing and not just the phons output of the sound waves power, I should read the entire thing next time
Joseph
Follow up question, does anyone know where I can find a graph that accuretly depicts the actual relative "power" output of sound over its frequency instead of just humans hearing
Joseph
"Generation of electrical energy from sound energy | IEEE Conference Publication | IEEE Xplore" ***ieeexplore.ieee.org/document/7150687?reload=true
Ryan
what's motion
Maurice Reply
what are the types of wave
Maurice
answer
Magreth
progressive wave
Magreth
hello friend how are you
Muhammad Reply
fine, how about you?
Mohammed
hi
Mujahid
A string is 3.00 m long with a mass of 5.00 g. The string is held taut with a tension of 500.00 N applied to the string. A pulse is sent down the string. How long does it take the pulse to travel the 3.00 m of the string?
yasuo Reply
Who can show me the full solution in this problem?
Reofrir Reply
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, 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