IOC error

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

Moderator: Benj

Post Reply
User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

IOC error

Post by Jan Lichtenbelt »

I programmed an IOC on pushing button connected with B6 when going low to high. But I found that the IOC also happens when pushing B4, or B5 (low-> high). What to do on this unwanted situation?

Kind regards

Jan Lichtenbelt
Test_IOC_B6.fcfx
(9.99 KiB) Downloaded 300 times

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: IOC error

Post by Benj »

Hi Jan,

Hmm that's odd the masking on the generated C code looks ok to me.

Code: Select all

    st_bit(INTCON,GIE);
    IOCBP=0x40;
    IOCBN=0x0;
    st_bit(INTCON, IOCIE);
The BP is the rising edge and BP is the falling edge mask.

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: IOC error

Post by Jan Lichtenbelt »

Hi Ben

The C-code seems indeed Ok.

In the meanwhile I tried:
1) A different board with just the microchip 16LF1847 and a 3V3 LCD. But the same result
2) I tried the 16LF1847.fcdx file as given in
http://www.matrixtsl.com/mmforums/viewt ... 847#p79213.
But the same results all ports B4, B5 and B6 give a IOC.

I hope you or someone of this Forum can help me.

Kind regards

Jan Lichtenbelt

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: IOC error

Post by LeighM »

Maybe you could read IOCBF register, AND with 0x40 to check B6 caused the interrupt.
You might then need to clear the IOCBF bit. I dont currently have access to the interupt handler code to check.

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: IOC error

Post by Kenrix2 »

What is the value of the pulldown resistor on RB6?

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: IOC error

Post by Jan Lichtenbelt »

I found the problem. I put a scope probe to B6 and found the problem was solved. That means that either the pull down resistance must be smaller or there must be placed a condensor parallel to the resistance.
The pull down resistance was 10k. Replacing it by 1k solved the problem. Or placing a condensor of about 1nF parallel to the 10k resitance solved also the problem. The choice of one of both solutions depend on the power to be allowed to be consumed.

Conclusion: The problem was no software but a hardware problem. And indeed the question of Kenrix2 make sense.

Have a nice weekend

Jan Lichtenbelt

PS. In the meanwhile I found that the condensor necessary for a working solution.

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: IOC error

Post by Jan Lichtenbelt »

Can it be that the port B6 is still an output port? Is it made automatically an input port by the IOC?

Kind regards

Jan

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: IOC error

Post by Kenrix2 »

I think the answer to both questions is no.

On all resets, port pins are configured as inputs (all tris bits are set). Flowcode also configures port pins to digital I/O on startup (all ansel registers are cleared). So, unless you specifically make B6 an output in your program, it will be an input.
For this reason, it is usually a good idea to make unconnected pins an output to reduce noise and also lower the device's current draw. If possible, input pins should be set to something but, you already figured out a way to do that in a post above.

The IOC only sets interrupt conditions and does not configure the pin as an input or output. It will interrupt regardless of whether or not the pin is an input or output.

Post Reply