Reading GPIO on TM4C123G board

texas instrumentsti-ccstudio

With the TM4C123G board, I'm using Code Composer Studio v6. I want to read the GPIO pins that are connected to the user switches on the board (Pin F4 and Pin F0). The code at first did not work but after a search on the Internet it worked after I added this function:

GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4 , GPIO_STRENGTH_2MA , GPIO_PIN_TYPE_STD_WPU);

I opened the TivaWare documentation, I kinda got an idea on what this function does. But my questions are:
Why to specify the drive strength for the input pin ?
And why should I choose between pull up or pull down resistors ?

Best Answer

Choosing pull-up or pull-down for an input pin is a good idea if it is connected to a signal that can become tri-state / disconnected (like switch). In this case an input without a pulling resistor will have an undefined value. If it is pulled down, it will have a value of 0 when disconnected. If pulled up - it will be 1. As for the strength, it depends on your tradeoffs. Generally, the lower currents - the less energy you circuit consumes and cooler the components are getting. But if the pin should source/sink a higher current (to drive a LED, for example), it should be set to the appropriate current value. For the Input pins there is no effect of the strength parameter. As from the TivaWare driverlib user guide:

For pin(s) configured as input ports, the pad is configured as requested, but the only real effect on the input is the configuration of the pull-up or pull-down termination.