Page 1 of 1
RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Mon May 16, 2011 9:56 pm
by fotios
I was faced with this problem:
On PIC16F887 the "IOC" interrupt is available on all pins of Port B, while in old PICs is available only from RB.4 to RB.7. In my project i have connected an IR receiver in RB.0 and i have enabled the "INT" interrupt on this pin of PortB. I have connected six push-buttons from RB.1 up to RB.6 and i wanted to use the IOC interrupt offered from P16F887. For enabling the IOC interrupt on PortB, you have to select the "PORT" interrupt in Flowcode (corresponding to IOC interrupt of PIC) but it is applicable on all 8 pins of PortB, you can't exclude from this Port RB.0. If i remember well, i tried everything on "PORT" interrupt (RB.0 on, RB.0 off) to simulate the IR receiver interrupt like a momentary switch, but i failed. Then, to complette my project, i added an extra Loop inside the main Loop to scan the state of the 6 switches and i used just the "INT" interrupt on Port RB.0. The final program works absolutely right in the actual project, but i am curious to know if there is a way (i think it might be) of using both interrupts. External interrupt on Port RB.0 and IOC interrupt from RB.1 to RB.6. Maybe a custom interrupt?
Thanks
Fotios
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Tue May 17, 2011 9:57 am
by Benj
Hello Fotios,
All you have to do is enable both the INT and Port interrupts and then use a line of C code in a C icon to mask off pin 0 from the Port interrupt.
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Tue May 17, 2011 11:49 am
by fotios
Wow! It was so simple! You may know, that i am - almost - completelly irrelevant with PIC assembly and that i know few things about C language. Moreover, for this reason i bought Flowcode
I will try it (i am sure that it will work) in few days and i will inform you for the expected success.
Thank you Ben!
Fotis
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Tue May 17, 2011 4:52 pm
by Benj
Your welcome
I'll keep my fingers crossed for you

Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Sun May 22, 2011 10:17 pm
by Eric Brouwer
Fotios
I do not have a 16F887, but I did have a look at the datasheet, and hope this program might help you on this specific chip.
Please note that the PORT interrupt does not seem to simulate correct, it only works for RB4..7. But I am sure it will work correct in your application. I have added the buttons to RB1..6, and disabled pins RB7 and RB0 in the IOCB register. Thus the IOC will not generate an interrupt for changes on RB0 or RB7.
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Tue May 24, 2011 5:21 am
by fotios
@ Eric Brouwer
Thank you very much Eric! You are very kind.
Yes, i know that PORT interrupt does not simulated from RB.0 up to RB.3. In your thread "Using Interrupts to scan Keypad" there is a reply of Steve Tandy explaining this issue. That is no problem to me, because i use "real" hardware for testing programs. I am sure that it will works. I will inform you for this.
Thanks again
Fotis
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Tue May 31, 2011 3:22 pm
by gabba-G
Hello,
i cant open the fcf file, but i need to learn more about the IOC in the 16f887.
is it possible to post the code (again)?
this would be great!
thx
gabriel
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Wed Jun 01, 2011 8:33 pm
by fotios
gabba-G wrote:Hello,
i cant open the fcf file, but i need to learn more about the IOC in the 16f887.
is it possible to post the code (again)?
this would be great!
thx
gabriel
Hi Gabriel
I downloaded and i opened the *fcf file of Eric, without problem using flowcode v4. You should know that i can't directly open *fcf files, i have to save these first on my HDD. Maybe this can resolve your problem?
Fotis
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Wed Aug 10, 2011 2:13 pm
by AndreasR
I have a very strange problem with interrupts and i don´t know what´s wrong.
i tried the sample program (16F877_Interrupts.fcf) and all works fine
Then i created a brand new program, included an interrupt, choosed interrupt at Port and here comes the strange.
The properties of the port interrupt are greyed out. I can´t get anything.
What i do wrong?
Andreas
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Wed Aug 10, 2011 3:32 pm
by Benj
Hello Andreas,
I have given this a go and the 16F887 is working correctly for me giving interrupt properties for the PORT interrupt.
The 16F877A does not give options for the PORT interrupt as the IOC mask register does not exist on this device. Instead you have to use software to decide if the interrupt was from a wanted or unwanted pin by retaining the port value from the last interrupt and using masking. Only pins RB4-RB7 can generate the PORT interrupt on this device.
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Posted: Wed Aug 10, 2011 4:48 pm
by AndreasR
I see...
Shame on me.
It´s better to read all the instruction sheets of the PICs that i will use.
Tanks again
Andreas