1
\$\begingroup\$

I am trying to build an IR remote receiver using a PIC16F628A. To do that, I need to catch both the falling and rising edge of the external interrupt pin. From the datasheet it appears you can only receive an interrupt on one or the other edges. How would you recommend going about this problem?

\$\endgroup\$

3 Answers 3

3
\$\begingroup\$

If you want to interrupt on both edges, then you can use an interrupt on change pin. If you can't wire to one of those, I'd switch the edge of the INT interrupt early in the interrupt routine.

\$\endgroup\$
3
  • \$\begingroup\$ Does an interrupt on change pin cause an interrupt for both going high and low \$\endgroup\$ Oct 8, 2014 at 14:59
  • \$\begingroup\$ Yep, that's the definition of "interrupt on change". Any change, up or down, will cause an interrupt. \$\endgroup\$
    – Dan Laks
    Oct 8, 2014 at 15:53
  • \$\begingroup\$ Keep in mind that it's the same interrupt that happens for both edges, so you'll need some way to tell which edge it was, if you care. Reading the pin first-thing usually works for most cases, but there is a short time between the trigger and when you read it that might cause problems for really fast signals. \$\endgroup\$
    – AaronD
    Oct 8, 2014 at 20:11
0
\$\begingroup\$

Here are a couple of simple ways if you don't need anything fancy:

enter image description here

\$\endgroup\$
0
\$\begingroup\$

The selectable edge you mentioned above is only for RB0 pin, and PortB 4-7 are on change. You don't need to sample both rising and falling edge, you can only use one. Also you will need to use timer or some counter in software for the width of the pulses. I suggest you send data to pc and analyse it on your pc so you can calibrate your PIC side software better. Buy some universal IR receiver circuit they are cheap and simple to use (dont bother with photo transistors and some homemade circuits). There are lots of good tutorials on this subject maybe even some complete projects you should check them out.

\$\endgroup\$

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.