Switch Inputs and LED Outputs in TM4C123
Revision as of 04:39, 2 January 2019 by Jshankar
Switch Inputs and LED Outputs
There are four ways to interface a switch to the microcontroller as shown in the following Figure:
We can use either positive or negative logic, and we can use an external resistor or select an internal resistor. Notice the positive logic circuit with external resistor is essentially the same as the positive logic circuit with internal resistance; the difference lies with whether the pull-down resistor is connected externally as a 10 kΩ resistor or internally by setting the corresponding PDR bit during software initialization.
SW1 and SW2 on LaunchPad
- SW1 push-button switch is connected directly to PF0 pin.
- SW2 push-button switch is connected directly to PF4 pin.
- There is no pull-up resistor connected to SW1 & SW2
- To use the SW1 and SW2, we need to enable the internal pull-up resistor for PF0 and PF4 pins.
The GPIOPUR register is the pull-up control register. When a bit is set, a weak pull-up resistor on the corresponding GPIO signal is enabled. Setting a bit in GPIOPUR automatically clears the corresponding bit in the GPIO Pull-Down Select (GPIOPDR) register. The GPIOPDR register is the pull-down control register. When a bit is set, a weak pull-down resistor on the corresponding GPIO signal is enabled. Setting a bit in GPIOPDR automatically clears the corresponding bit in the GPIO Pull-Up Select (GPIOPUR) register.