6
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ How is the detect signal generated? \$\endgroup\$
    – W5VO
    Commented Jul 9, 2012 at 18:26
  • \$\begingroup\$ "... why there aren't other answers.." should be read as "... why/if there aren't other answers..". \$\endgroup\$
    – Johan.A
    Commented Dec 13, 2013 at 13:58

2 Answers 2

15
+50
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

Sounds like a classic logic inversion problem.

Could be that

  • The signal from the card reader is the opposite polarity to what you expect (as also suggested by stevenvh)
  • The micro is set up to respond to the opposite interrupt edge to what you expect
  • There's a (maybe programmable) inverter within the micro between the pin and the IRQ logic
  • There's an inverting buffer on the micro PCB between the SIM reader and the micro pin

Off-topic for the question, but is it required that you respond to that signal particularly quickly? I'm not sure I see a need for an interrupt on that event, I would've thought just polling in the background loop would be sufficient.

\$\endgroup\$
1
  • \$\begingroup\$ The use of an interrupt instead of polling for detecting SIM card insertion has its merits: One avoids a polling loop that would very rarely yield results, wasting cycles the rest of the time. It isn't an uncommon requirement. \$\endgroup\$ Commented Dec 20, 2013 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.