Page 1 of 1

Interrupt on B0 too slow?

Posted: Sun Feb 08, 2015 9:42 pm
by henker
Hello All,
I'm trying to enable an interrupt on the falling edge of B0.
The signal is a 40khz pulse. As soon as this signal is present, the interrupt routine should be enabled. Unfortunately it doesn't.
Could this because the Interrupt frequency on B0 / INT0 is only 15Hz?

Thanks
Henk

Re: Interrupt on B0 too slow?

Posted: Tue Feb 10, 2015 6:25 pm
by Benj
Hello Henk,

Could you attach your program so we can see what your doing. Also what is the DC voltage of the 40KHz signal and is the signal a square wave or a sine wave?

Re: Interrupt on B0 too slow?

Posted: Wed Feb 25, 2015 3:50 pm
by henker
Hi Ben,
Thanks for your reply. In the meantime have changed the code in order to make it work. Let me try to describe the problem.

(I'm using the 18F4685)
On the B0 channel I'm receiving a 40Khz signal (pulse train) (Signal is 0-5V pk-pk). The hardware interrupt should be reacting on the first falling edge of the 40 Khz signal.
The only thing the Interrupt routine does is stop Timer 1 and read the values. As I know (using an Oscope) what the time is between the start of the the T1 and the first falling edge, I know that the Interrupt is not reacting on the first falling edge. It might be the 10th, 15th or even the 22nd falling edge...

I have now made a routine without using an interrupt where there is a wait loop that breaks when the B0 input goes from 1 to 0. As this soon this happens, T1 one is stopped and read. Although this is a very much a "poor mans" solution, it does work really well.

What I'm wondering if the actual hardware interrupt is reacting on an input change or if the input channel is actually being sampled. This as in the Interrupt Macro it shows "Interrupt Frequency" = 15Hz

Hopefully this explains my problems

Thanks
Henk

Re: Interrupt on B0 too slow?

Posted: Wed Feb 25, 2015 6:58 pm
by Benj
Hello Henk,

I have seen problems before where the INT type interrupt will not fire unless the voltage is very close to VSS and VCC. We had issues on the HP488 development board where the resistors for the LED caused the switch voltage to drop slightly meaning the INT interrupt may not fire every time. Increasing the resistance of the LED resistor solved the issue.

What voltage are you running the 18F device at and what are the voltages of the incoming signal? There will also likely be rise time and fall time issues if the signal is changing voltage slowly e.g. if your inputting a sine wave rather than a square wave.

Just had a look through the datasheet to see if I can find specifics but can't spot anything worth mentioning.

Re: Interrupt on B0 too slow?

Posted: Thu Feb 26, 2015 2:46 am
by henker
Thanks for your quick reply Ben,

The signal is a square wave, not a SIN.
Let me play around with some resistors. Both PIC and incoming 40Khz signal are 5V.!

Henk