Port Change Interrupt for 16F737

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Port Change Interrupt for 16F737

Post by medelec35 »

Hello.
I am having same issue with 16F737 as I did with 12F615 i.e. port B change interrupt option not available.
Copying port change from 12F675 did not work in this case.
I had a look at all 16F7x7 fcd files and none have the port B change interrupt option availabe.
Looking at datasheet on page 25, it states:

Code: Select all

bit 3 RBIE: RB Port Change Interrupt Enable bit
1 = Enables the RB port change interrupt
0 = Disables the RB port change interrupt
so port change option should be available?
It looks like ioc is used on 12F675, but not on 16F737.
If it is possible, can a new 16F737.fcd be posted please.
Much appreciated.
Martin

User avatar
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: Port Change Interrupt for 16F737

Post by Benj »

Hello

Here is a copy of the 16F737.fcd including the PORT interrupt. Note with this device there is no interrupt mask so pins RB4 - RB7 will all be used to trigger the interrupt.
Attachments
16F737.fcd
(6.85 KiB) Downloaded 422 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Port Change Interrupt for 16F737

Post by medelec35 »

Thanks Benj.
Port change is still greyed out. I’m not sure how to proceed.
I am just tying to start off with a very simple example.

E.g. If Port RB4 changes then call macro called Port_BB4 and set variable called port_RB4 to 1
If Port RB5 changes then call macro called Port_BB5 set variable called port_RB5 to 1.

I would be really grateful post a Flowchart that functions as above.
Many thanks.
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Port Change Interrupt for 16F737

Post by medelec35 »

Forgot to ask:
Would it be possible for some one to post an example file with RB Port detection enabled (RB4 - RB7), before the weekend please?
I would really appreciate help since I plan on completing my project by This Saturday, and no support is given over the weekend.
Thank you.
Martin

User avatar
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: Port Change Interrupt for 16F737

Post by Benj »

Hello

I have tested the PORT interrupt in Flowcode V3.6 and V4 and it is appearing correctly which version of Flowcode are you using? If you are using an earlier version you should be able to install the latest download to get the interrupt working.

As the interrupts are unmasked you have to do the masking yourself. To do this in your interrupt routine you would have to read each individual pin from RB4 to RB7 into seperate variables. Two variable per input are required, one for the current data and one for the previous data. Once you have a record of each variable you can do a comparison to see if the variable has changed since the previous interrupt. If the variable has changed then you know that particular pin has toggled state. At the end of the interrupt routine make sure to assign the previous variables with the current variables to allow the functionality to work on the next interrupt cycle.

User avatar
Dan81
Valued Contributor
Valued Contributor
Posts: 268
Joined: Sun Jan 15, 2006 4:07 pm
Location: Albi France
Been thanked: 60 times
Contact:

Re: Port Change Interrupt for 16F737

Post by Dan81 »

Hello

Try these Flowcharts ( for a 16F887)


Daniel
Attachments
RB_edge.fcf
(7 KiB) Downloaded 372 times
RB_change.fcf
(4.5 KiB) Downloaded 366 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Port Change Interrupt for 16F737

Post by medelec35 »

Thanks to both of you for your replies.
Dan. Unfortunately the 16F737 does not allow RB port change interrupts to be masked (unlike 16F887 properties are greyed out) so won’t be able to use routine you posted. Thanks again anyway.

Ben. Are you saying I will have to use RB port change interrupt although properties are greyed out , and interrupt will call one macro on any port change detected (RB4 – RB7). I will then need to check each port to determine which port has change?
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Port Change Interrupt for 16F737

Post by medelec35 »

Ben, is this the way you would of done it, if you was creating the flowchart yourself?
Attachments
RB interrupt port test.fcf
(5.5 KiB) Downloaded 388 times
Martin

User avatar
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: Port Change Interrupt for 16F737

Post by Benj »

Hello

What you have done there is almost spot on. However you do not need the code inside the while loop in your main.

Also at the start of your program you may want to give the old variables a starting value say 0 or 1 depending on what the state of the I/O is by default.

RB6 and RB7 can also cause the interrupt but the way you have the code at the moment only RB4 and RB5 will call a macro so it will be as if the RB6 and RB7 interrupts are not happening. If you only want interrupts from RB4 and RB5 then jobs a good one.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Port Change Interrupt for 16F737

Post by medelec35 »

Thanks Ben,
That's great! Thanks for the feedback.
Martin

Post Reply