This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123GH6PM: How to change the Input Pin Sensitivity level?

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Hello,

I am trying to set up a pin to be used as an input, and when it receives 5V, another pin is to be activated high and send an output.

I'm having difficulty because it seems that my input pin is being triggered without even receiving a voltage. Is there anyway to fix this?

Below is a sample of the code I use to initialize the pin:


    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

   MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6);

   int limitSwitchClosed = MAP_GPIOPinRead(GPIO_PORTA_BASE, GPIO_PIN_6);

if(limitSwitchClosed)

{

 do this...

}

....But is seems that even if I disconnect the wire from the limit switch, the pin gets activated. It only doesn't get activated once I completely remove any wire to that pin.

Any help would be very much appreciated!

  • Hi,

      I think what might have happened is that the input signal bounced. When you pressed the switch and then released, the input switch actually bounces up and down a few times due to the mechanical nature of the switch. This may also happen when you disconnect the wire. You can take a scope capture of the input to PA6 to confirm this behavior. Below is an article that talks about implementing debouncing using software. 

      reference.digilentinc.com/.../start  

      You can also look at the Debounce software implementation in the function ButtonsPoll() in C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\drivers/buttons.c file. 

  • Thank you for your response, I will definitely look into that. I'm just unsure if that's the problem because I have another input connected to A4 that activates via a motion detector, and that works fine.

    However, if I turn on my microcontroller and have no wires attached to pinA5 (My input pin for the limit switch), as soon as I simply touch a wire to the pin (the other end of the wire is not even connected to anything else) the pin goes high. I have no idea what's going on here.