Page 1 of 1

Interrupt GP2 and Port change on 12F675

Posted: Wed Dec 03, 2008 9:38 am
by mfo
Hello,

I'm currently trying to use at same time both GP2 and on Port change interrupts.
The compilation to .hex failed complaining about unknown iocb variable. I added a #define iocb ioc to the Add defines component to workaround this issue.
So I could build to .hex but only GP2 interrupt works on the board. By the way only GP2 interruption works under simulation (I know it's not a reason for the port chnage interrupt to fail on the breadboard).
Is ther any specific thing to do to make port change interrupt to work with Flowcode?
My first (very) quick read of the asm code seems Ok.

Marc

Re: Interrupt GP2 and Port change on 12F675

Posted: Wed Dec 03, 2008 12:37 pm
by mfo
I was not clear, here's an example:

BP0 on GP2: each interrupt makes DEL0 dim (that part runs fine on both flowcode and on the breadboard)
BP1 pn GP0: one interrupt should light on DEL1 (no way to make it run on both flowcode and the breadboard)

The .fcd is attached.

M.

Re: Interrupt GP2 and Port change on 12F675

Posted: Wed Dec 03, 2008 2:41 pm
by mfo
My previous flowcode was not totally correct, in the GP2 interrupt macro I forgot to disable the interrupt.
Here's a corrected version.

M.

Re: Interrupt GP2 and Port change on 12F675

Posted: Wed Dec 03, 2008 2:59 pm
by Benj
Hello

I have attached a corrected version of the program that hopefully should work correctly. Let me know how you get on.

Re: Interrupt GP2 and Port change on 12F675

Posted: Thu Dec 04, 2008 10:54 am
by mfo
Hello Benj,

Thanks for your reply.

Here's the result of my tests:

(For info:
- on-change port interrupt enabled on both GP0 and GP1; GP2/INT
enabled;
- GP2/INT macro commands a LED on GP4;
- on-change port macro commands a LED on GP5.)

First, I had a wrong value for one resistor leading to a non-working
LED (the one driven by the on-change port interrupt...);
Once the resistor correctly chosen, I tested your flowcode. It's not
correctly working: the GP5 LED is on from the beginning, I mean since
I switched-on the power-supply. Actually, we need to read the GPIO
just before enabling the on-change port interrupt to provide a correct
state of the GPIO. With that read, the things are better but when a
change occurs on GP2, sometimes the GP5 LED's state changes...).
I found a workaround to this problem: disabling both interrupt inside
GP2/INT macro, then a

intcon.INTE=1;
intcon.GPIE=1;

inside the main while (1) loop (well in fact only on-change port
disabling should be required).

I attached the .fcd, an example is always better than words.

So to sum up, the only bugs I found was the need to add the define for
the iocb variable and the fact flowcode simulation of on-change port
interrupt does not work (this last point is not a bug for me, I
understand that trying to simulate interrupts is not an easy thing)

I have a suggestion, is it possible to provide an example (in the help
or on your examples pages) of on-change port usage? This interrupt is
a bit tricky to use.

Thanks again for your help.