Page 1 of 1

IOC error

Posted: Fri Dec 01, 2017 2:28 pm
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 367 times

Re: IOC error

Posted: Fri Dec 01, 2017 4:14 pm
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.

Re: IOC error

Posted: Fri Dec 01, 2017 8:29 pm
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

Re: IOC error

Posted: Fri Dec 01, 2017 9:18 pm
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.

Re: IOC error

Posted: Fri Dec 01, 2017 11:28 pm
by Kenrix2
What is the value of the pulldown resistor on RB6?

Re: IOC error

Posted: Sat Dec 02, 2017 11:19 am
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.

Re: IOC error

Posted: Sun Dec 03, 2017 7:46 pm
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

Re: IOC error

Posted: Mon Dec 04, 2017 1:42 am
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.