I know this will be simple for many but is there a basic example for using interrupts from PortB of a PIC?
Basically, a number of buttons on PortB, two of which need to break a function (reset and A.N.other)
Enable an interrupt
Run code as normal
If a key is pressed break from the run-mode and do 'something else'.
Sounds simple and probably is but I can't get my head around it in FlowCode.
FlowCode interrupts for RB0
- 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: FlowCode interrupts for RB0
Hello
An RB0 interrupt in Flowcode occurs when you switch the logic level from pin RB0 from low to high or visa versa depending on your interrupt enable properties.
To switch the RB0 input from high to low you are going to need an external pull up or pull down resistor.
Eg here is a typical circuit using a single push to make switch and a 4.7K resistor.
5V----Switch----RB0----4.7K Resistor-----GND
When the interrupt is triggered the macro you selected via Flowcode will be run once.
Hope this helps.
An RB0 interrupt in Flowcode occurs when you switch the logic level from pin RB0 from low to high or visa versa depending on your interrupt enable properties.
To switch the RB0 input from high to low you are going to need an external pull up or pull down resistor.
Eg here is a typical circuit using a single push to make switch and a 4.7K resistor.
5V----Switch----RB0----4.7K Resistor-----GND
When the interrupt is triggered the macro you selected via Flowcode will be run once.
Hope this helps.
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
Re: FlowCode interrupts for RB0
Ben,
I'm okay with that level. I guess the question was for a simple sample of using a port interrupt within Flowcode.
Doh!
sorted now.
I'm okay with that level. I guess the question was for a simple sample of using a port interrupt within Flowcode.
Doh!

Re: FlowCode interrupts for RB0
Hi,
I am trying to do an emergency stop using the RB0 interrupt. The problem is that when the interrupt is triggered,
the macro chosen is only done once,
What can I do to loop until the button is released? I did a loop in the macro but still it run only once :S
Thanks for your help
I am trying to do an emergency stop using the RB0 interrupt. The problem is that when the interrupt is triggered,
the macro chosen is only done once,
, and I need it to continue to run until the emergency stop is released.When the interrupt is triggered the macro you selected via Flowcode
will be run once
What can I do to loop until the button is released? I did a loop in the macro but still it run only once :S
Thanks for your help
tomcat14
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
Re: FlowCode interrupts for RB0
Hi kirmstom14,
This is how I would do it :
This only works well when there is no delay in the "else" part of the program.
Nicolas
This is how I would do it :
Code: Select all
//main program
char stop = 0; // variable for stopbutton used as a "flag"
while(1) // main loop
{
if (stop == 1)
{
// do stuff
// when stuff done
stop = 0;
}
else
{
// do some other stuff
}
}
Code: Select all
// interrupt
stop = 1; // stop button pressed
Nicolas