Page 1 of 1
PIC16F18326 Interrupt error
Posted: Fri Apr 24, 2026 4:35 pm
by DirkB
Hello,
I've noticed that on the PIC 16F18326, interrupts always trigger on both edges when a falling edge is set. This applies to the IOC and INT pins.
Regards
Re: PIC16F18326 Interrupt error
Posted: Fri Apr 24, 2026 8:51 pm
by mnfisher
Can you post a simple demo showing this?
Looking at the datasheet - bits are set in IOCxP and IOCxN for rising and falling edge interrupts - both to detect both.
I added an IOC interrupt to a chart and selected some pins (the 'selection' image is too small - and I couldn't find keys to enlarge it) - then looking at the code generated:
Code: Select all
// Interrupt
st_bit(INTCON,GIE);
IOCAP=0x28;
IOCAN=0x18;
IOCCP=0x0;
IOCCN=0x0;
st_bit(PIE0, IOCIE);
Which looks okay?
Martin
Re: PIC16F18326 Interrupt error
Posted: Sat Apr 25, 2026 11:35 am
by DirkB
Hi Martin,
these are exactly the entries (C code) in my interrupt handler. It works with other chips such as the 16F1825/27, the 18F14K22, and many others as well. You have to use a chip. In the simulation, it almost always works, even if it doesn't work on the chip.
Re: PIC16F18326 Interrupt error
Posted: Sat Apr 25, 2026 2:13 pm
by mnfisher
I don't have that part to test with - sorry.
As a simple 'thought experiment' - can you add code to set the interrupt pins as 'inputs' before the interrupt icon? (set TRISA or use read a pin using input)
Set the pins to be 'digital' (set ANSELA)
Add a simple ISR that toggles a different pin.
Add a signal and let us know how the results look..
It's a long shot that the default values are different on this MCU for some reason?
Martin