Greetings,
PA14 connected to switch S2 of the LaunchPad was configured as the GPIO input.
Upon pressing the switch, LED connected to PA0 (GPIO output pin) was configured to toggle (to switch it on) and a timer with its down-counter of 1s is started.
When the Counter reaches zero, an interrupt is attended which toggles the LED again (to switch it off)
In summary, upon pressing the switch - The LED should light-up for 1 second, every time the switch is pressed.
But the LED only Lit up after an interval of 5-6 seconds between each switch press, and I tried using clearPins and setPins for lighting and dimming the LED which did not solve this issue either.
Later, after some trial and error I contacted the back of the switch with my finger, which had two metal contact points. That was able to close the circuit and light up the LED repeatedly, without any interval between each press.
Can someone explain why this might be happening as I tested the switch for toggling the LED without the timer and it seems to toggle the LED without any problem in that case.
I have attached photos of the flowchart of the program and the GPIO and Timer instances' Interrupt handler code for reference. I am happy to provide more information if required.
Thanks in advance!
https://drive.google.com/file/d/1fIIaREzWVo7PaxHhoyMgUTzgGJSWXUT-/view?usp=sharing (flowchart)