Hi.
I'm not sure which are the correct pins to use to enable a rising edge interrupt.
The editor suggests RB0 to RB3 for INT0 to INT3 but the chip image does not have pins RB0 to RB3 but instead shows INT0 to INT2 on pins RC0 to RC2.
What has me more confused the data sheet appears (I'm only a beginner) to suggest that INT0 to INT2 is on pins RA0 to RA2.
Have I miss read this and can a rising edge interrupt be done on this chip using Flowcode? If so what am I missing?
Thanks.
Rising edge Interrupt 18F14K22
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Rising edge Interrupt 18F14K22
Hi Andrew,
I can totally understand the confusion.
The correct interrupt pins should be the ones stated within the datasheet.
The RB0 - RB3 within Flowcode for INT0 to INT3 is just an error.
If you select RB0/INT0 you hardware should work if you connect your switch or whatever your using for interrupt to pin RA0, then your interrupt service macro should be triggered when RA0 a rising ( or falling depending on which edge you have selected) edge has been detected.
If you are using a switch and rising edge for example, it's vital that a pull down resistor(Say 4K7 to 10K) is connected between interrupt pin and 0V
Switch is connected between interrupt pin and +5V
Or if using falling edge interrupt is selected then you must either have a pull-up resistor connected between interrupt pin and +5V
Switch is connected between interrupt pin and 0V
Note: instead of a physical pull-up resistor you can enable a internal weak pull=up on port A (WPUA) or port B(WPUB)
Will only expand on that if you really want to go down that route since it gets slightly more complex.
If I can find a simular target device, I will see of my theory of connecting to RA0 for INT0 is correct.
I can totally understand the confusion.
The correct interrupt pins should be the ones stated within the datasheet.
The RB0 - RB3 within Flowcode for INT0 to INT3 is just an error.
If you select RB0/INT0 you hardware should work if you connect your switch or whatever your using for interrupt to pin RA0, then your interrupt service macro should be triggered when RA0 a rising ( or falling depending on which edge you have selected) edge has been detected.
If you are using a switch and rising edge for example, it's vital that a pull down resistor(Say 4K7 to 10K) is connected between interrupt pin and 0V
Switch is connected between interrupt pin and +5V
Or if using falling edge interrupt is selected then you must either have a pull-up resistor connected between interrupt pin and +5V
Switch is connected between interrupt pin and 0V
Note: instead of a physical pull-up resistor you can enable a internal weak pull=up on port A (WPUA) or port B(WPUB)
Will only expand on that if you really want to go down that route since it gets slightly more complex.
If I can find a simular target device, I will see of my theory of connecting to RA0 for INT0 is correct.
Martin
-
- Flowcode v5 User
- Posts: 28
- Joined: Wed Oct 02, 2013 12:16 pm
- Has thanked: 7 times
- Been thanked: 7 times
Re: Rising edge Interrupt 18F14K22
Thank you for the clarification. I'll try that and report back.If you select RB0/INT0 you hardware should work if you connect your switch or whatever your using for interrupt to pin RA0, then your interrupt service macro should be triggered when RA0 a rising ( or falling depending on which edge you have selected) edge has been detected.
That will explain some of the erroneous behaviour I've been getting, Nice one.If you are using a switch and rising edge for example, it's vital that a pull down resistor(Say 4K7 to 10K) is connected between interrupt pin and 0V
Switch is connected between interrupt pin and +5V
Or if using falling edge interrupt is selected then you must either have a pull-up resistor connected between interrupt pin and +5V
Switch is connected between interrupt pin and 0V
Thanks very much for the help.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Rising edge Interrupt 18F14K22
Yes there will be some very unexpected triggering.AndrewC wrote:That will explain some of the erroneous behaviour I've been getting, Nice one.
Since the input resistance is very high, if no pull-up or pull-down resistor is connected between i/p pin and supply, then the input will be classed as floating.
A finger placed near the i/p or other electrical interference will case the voltage of the i/p to rise to more than is required for logic 1.
Your welcome, just hope I'm not wrong.AndrewC wrote:Thank you for the clarification.
There is also another issue you may need to deal with and that's switch contact bounce.
As the switch closes, the contacts may open and close a few times within a few milliseconds.
Each time that could happen, the interrupt will get fired.
The cure is to either use a resistor/capacitor filter circuit.
Or
Add delay in your software.
Avoid added a delay within interrupt routine as this is bad practice and prevents other interrupts from triggering whilst within the interrupt routine.
Martin
Martin
-
- Flowcode v5 User
- Posts: 28
- Joined: Wed Oct 02, 2013 12:16 pm
- Has thanked: 7 times
- Been thanked: 7 times
Re: Rising edge Interrupt 18F14K22
[quoteA finger placed near the i/p or other electrical interference will case the voltage of the i/p to rise to more than is required for logic 1.
][/quote]
That would explain why I thought I had a poor connection somehow triggering the chip as I went to press the button.
In this project the switching high will hopefully be done by another chip.
][/quote]
That would explain why I thought I had a poor connection somehow triggering the chip as I went to press the button.

I also had this issue but did use a delay although it was during the interrupt routine. But I do like that r/c filter idea and will use it next time. Thanks for that. Another awesome tip.There is also another issue you may need to deal with and that's switch contact bounce.
As the switch closes, the contacts may open and close a few times within a few milliseconds.
Each time that could happen, the interrupt will get fired.
The cure is to either use a resistor/capacitor filter circuit.
Or
Add delay in your software.
Avoid added a delay within interrupt routine as this is bad practice and prevents other interrupts from triggering whilst within the interrupt routine.

In this project the switching high will hopefully be done by another chip.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- 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: Rising edge Interrupt 18F14K22
Thanks for this, I have now fixed these FCDs for v6 so they show the correct pins.
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