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
Interrupt on B0 too slow?
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Interrupt on B0 too slow?
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?
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?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 45
- Joined: Mon Dec 22, 2008 11:22 pm
- Location: Prospect, NS, Canada
- Has thanked: 7 times
- Been thanked: 2 times
- Contact:
Re: Interrupt on B0 too slow?
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
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Interrupt on B0 too slow?
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 45
- Joined: Mon Dec 22, 2008 11:22 pm
- Location: Prospect, NS, Canada
- Has thanked: 7 times
- Been thanked: 2 times
- Contact:
Re: Interrupt on B0 too slow?
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
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