RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
- fotios
- Posts: 458
- Joined: Mon Feb 08, 2010 10:17 am
- Location: Greece
- Has thanked: 109 times
- Been thanked: 117 times
RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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
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
Best Regards FOTIS ANAGNOSTOU
- 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: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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.
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.
Code: Select all
iocb = 0xFE;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
- fotios
- Posts: 458
- Joined: Mon Feb 08, 2010 10:17 am
- Location: Greece
- Has thanked: 109 times
- Been thanked: 117 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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
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
Best Regards FOTIS ANAGNOSTOU
- 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: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Your welcome
I'll keep my fingers crossed for you
I'll keep my fingers crossed for you
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
- Eric Brouwer
- Posts: 20
- Joined: Sat Oct 30, 2010 10:17 am
- Has thanked: 3 times
- Been thanked: 11 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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.
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.
- Attachments
-
- 16F887_Interrupts.fcf
- (8 KiB) Downloaded 766 times
- fotios
- Posts: 458
- Joined: Mon Feb 08, 2010 10:17 am
- Location: Greece
- Has thanked: 109 times
- Been thanked: 117 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
@ 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
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
Best Regards FOTIS ANAGNOSTOU
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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
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
- fotios
- Posts: 458
- Joined: Mon Feb 08, 2010 10:17 am
- Location: Greece
- Has thanked: 109 times
- Been thanked: 117 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
Hi Gabrielgabba-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
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
Best Regards FOTIS ANAGNOSTOU
- AndreasR
- Posts: 44
- Joined: Tue Aug 02, 2011 9:27 am
- Location: Germany
- Has thanked: 5 times
- Been thanked: 3 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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
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
often i ask myself:
why i´m not a gardener ?
=:-)
why i´m not a gardener ?
=:-)
- 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: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
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.
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.
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
- AndreasR
- Posts: 44
- Joined: Tue Aug 02, 2011 9:27 am
- Location: Germany
- Has thanked: 5 times
- Been thanked: 3 times
Re: RB.0 interrupt + RB.1 to RB.6 "IOC" on PIC16F887
I see...
Shame on me.
It´s better to read all the instruction sheets of the PICs that i will use.
Tanks again
Andreas
Shame on me.
It´s better to read all the instruction sheets of the PICs that i will use.
Tanks again
Andreas
often i ask myself:
why i´m not a gardener ?
=:-)
why i´m not a gardener ?
=:-)