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
IOC error
Moderator: Benj
- 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:
- 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
Hi Jan,
Hmm that's odd the masking on the generated C code looks ok to me.
The BP is the rising edge and BP is the falling edge mask.
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);
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
- 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
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
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
- 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
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.
You might then need to clear the IOCBF bit. I dont currently have access to the interupt handler code to check.
- 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
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.
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.
- 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
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
Kind regards
Jan
-
- 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
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.
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.