Please Enable the Software Input On at the pin configuration. Additionally, make sure that the PinRead is outside the IRQ handler, it is suggested to keep them as short as possible.
Yeah, I did the same, but the issue persists. In debug mode, when I'm giving input to that pin, the error scenario occurs and the debug mode automatically closes. However, other than in debug mode, the functionality works fine.
What is the specific part number of your device? There are issues using those pads when the specific part supports tamper. The result obtained suggests that the tamper causes this as it disconnects the debug session when triggered.