Chapter 3 Appendix
1. What three functions choices are there for setting up a pin for GPIO
input?
Hint, one place to look would be the MSP430 Driverlib Users Guide
found in the MSP430ware folder:
\MSP430ware_1_60_01_11\driverlib\doc\MSP430F5xx_6xx\
_________________________________________
_________________________________________
_________________________________________
2. What can happen to an input pin that isn’t tied high or low?
_________________________________________
_________________________________________
3. Assuming you need a pull-up resistor for a GPIO input, write line of
code required to setup pin P1.0 for input:
_________________________________________;
Lab3b – Worksheet
The input pin could end up floating up or down. This uses
more power … and can give you erroneous results.
GPIO_setAsInputPinWithPullUpresistor (
GPIO_PORT_P1, GPIO_PIN0)
GPIO_setAsInputPin()
GPIO_setAsInputPinWithPullDownresistor()
GPIO_setAsInputPinWithPullUpresistor()
Lab3b – Worksheet
GPIO_getInputPinValue ( GPIO_PORT_P2, GPIO_PIN1 )
“Polling”
4. Complete the following code to read pin P2.1:
volatile unsigned short usiButton1 = 0;
while(1) {
// Read push-button pin (SW1)
usiButton1 =
_____________________________________;
if ( usiButton1 == GPIO_INPUT_PIN_LOW ) {
// If button is down, turn on LED
GPIO_setOutputHighOnPin( GPIO_PORT_P1, GPIO_PIN0 );
}
else {
// Otherwise, if button is up, turn off LED
GPIO_setOutputLowOnPin( GPIO_PORT_P1, GPIO_PIN0 );
}
}
5. In embedded systems, what is the name given to the way in which
we are reading the button? (Hint, it’s not an interrupt)
____________________________
3 - 36 MSP430 Workshop - Using GPIO with MSP430ware