After getting a fixed .fcd to fix duplicate int handlers (thank you Ben!), I still think it isn't completely error free.
I have a simple flowchart to detect an encoder rotation. Uses int on change on port b5. See attached.
Works fine in sim, using rocker switches to sim the encoder rotation.
In actual h/w, it continues to detect enc rotations even when the encoder is stationary and the actual input lines to Port B b3 & b5 are steady at 0 or 1. The diagnostic printout of 'Dir' continues to spew out characters.
I've been at this for several days now, it's maddening! Anybody has a idea where to look? Is the enable and disable of the port B ioc correctly implemented in the code?
thanks,
jan didden
Port B ioc sims vs implementation
Moderator: Benj
- 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 B ioc sims vs implementation
Hello Jan
I have been through your code and it seems that the IOC interrupt mask is correctly being set with the mask value.
eg bx00100000
Are you pulling the to 5V or ground or is the pin ever left floating at all. I see you have enabled the weak port B pullups. It may be worth checking with a resistor that is not the internal pullups are not causing problems.
I have been through your code and it seems that the IOC interrupt mask is correctly being set with the mask value.
eg bx00100000
Are you pulling the to 5V or ground or is the pin ever left floating at all. I see you have enabled the weak port B pullups. It may be worth checking with a resistor that is not the internal pullups are not causing problems.
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
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
- Contact:
Re: Port B ioc sims vs implementation
Hello Ben,
I have put both enc inputs to b5 & b3 hard to ground with a jumper. Everytime I get an ioc I flash a led on c7 for diagnostics, what do you know, the led flashes continuously. I just burned a brand new pic straight out of the box. Still continuous ioc's....
If I remove the enable ioc before the main loop, I get no ioc's so it doesn't 'self-start' or something.
If I remove the enable ioc at the end of the processing loop, I just get (correctly) a single ioc, but, even with the enc lines grounded! That shouldn't be.
So the issue seems to be that I get an ioc even with the port b lines not moving.....
Edit: when I do a read of b5 just before enabling ioc before the main loop, to clear any existing ioc, I DON'T get the first ioc.
So I tried the same just before re-enabling ioc at the end of the main processing loop, but that doesn't help, still continuous ioc's.
jan didden
I have put both enc inputs to b5 & b3 hard to ground with a jumper. Everytime I get an ioc I flash a led on c7 for diagnostics, what do you know, the led flashes continuously. I just burned a brand new pic straight out of the box. Still continuous ioc's....
If I remove the enable ioc before the main loop, I get no ioc's so it doesn't 'self-start' or something.
If I remove the enable ioc at the end of the processing loop, I just get (correctly) a single ioc, but, even with the enc lines grounded! That shouldn't be.
So the issue seems to be that I get an ioc even with the port b lines not moving.....
Edit: when I do a read of b5 just before enabling ioc before the main loop, to clear any existing ioc, I DON'T get the first ioc.
So I tried the same just before re-enabling ioc at the end of the main processing loop, but that doesn't help, still continuous ioc's.
jan didden
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
- Contact:
Re: Port B ioc sims vs implementation
I was just going to try this program on a 16F690 to see if the same issue arises, but there I get into the problem of duplicate int handlers.
So I need a new .fcd for the 690 with the same fix as was done for the .fcd for the 16f886...
jan didden
So I need a new .fcd for the 690 with the same fix as was done for the .fcd for the 16f886...
jan didden
- 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 B ioc sims vs implementation
Hi Jan
Here is the fixed 16F690 FCD that will be released with v4.3. It has the new ioc edits to allow you to specify the interrupt on change masks appropriatley.
Here is the fixed 16F690 FCD that will be released with v4.3. It has the new ioc edits to allow you to specify the interrupt on change masks appropriatley.
- Attachments
-
- 16F690.fcd
- (11.7 KiB) Downloaded 274 times
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
-
- Flowcode v5 User
- Posts: 273
- Joined: Thu Apr 17, 2008 9:59 am
- Has thanked: 19 times
- Been thanked: 16 times
- Contact:
Re: Port B ioc sims vs implementation
There appears to be an error in the int handler for an ioc on port B (16f886 in my case).
To clear the int, two things need to be done:
- read port b to clear the mismatch that caused the int and set the int flag;
- reset int flag rbif in intcon.
In the current implementation, rbif is not reset.
It seems that this causes a continuous generation of calls to the int handler, without actual interrupts present.
jan didden
To clear the int, two things need to be done:
- read port b to clear the mismatch that caused the int and set the int flag;
- reset int flag rbif in intcon.
In the current implementation, rbif is not reset.
It seems that this causes a continuous generation of calls to the int handler, without actual interrupts present.
jan didden
- 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 B ioc sims vs implementation
Hello Jan
You were right the interrupt enable was being cleared rather then the interrupt flag. Here is the updated file.
All of these updates plus any related family updates will be included in the v4.3 release when this is made available.
You were right the interrupt enable was being cleared rather then the interrupt flag. Here is the updated file.
All of these updates plus any related family updates will be included in the v4.3 release when this is made available.
- Attachments
-
- 16F886.fcd
- (11.44 KiB) Downloaded 293 times
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