Electronic – SIM card: Detected when the card is removed


I have an STM32 with a SIM card reader. For some reason the DETECT pin interrupt is triggered when the SIM card is removed, as opposed to when the SIM card is inserted.

What could be going wrong here?

Best Answer

Possible reasons I can think of:

  • the card detection switch switches from Vcc instead of ground, so that the logic is inverted and a falling edge becomes a rising edge and vice versa.

  • there's contact bounce, generating both types of edges. Solved with an RC filter.