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\$
  • \$\begingroup\$ How is the detect signal generated? \$\endgroup\$ – W5VO Jul 9 '12 at 18:26
  • \$\begingroup\$ "... why there aren't other answers.." should be read as "... why/if there aren't other answers..". \$\endgroup\$ – Johan.A Dec 13 '13 at 13:58
14
+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.

| improve this answer | |
\$\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.

| improve this answer | |
\$\endgroup\$
  • \$\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\$ – Anindo Ghosh Dec 20 '13 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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