News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Interrupt

Started by Ivano, Dec 19, 2025, 10:14 PM

Previous topic - Next topic

Ivano

Good evening, I'm working with a PIC 18F46k42. By enabling the various registers that enable the interrupt with timer 0, when I also enable timer 0, the program resets after 2-3 seconds.
If I enable timer 0 without enabling its interrupt (PIR3.7), it counts and doesn't reset, but obviously the ISR doesn't work. The reset occurs when both the timer and interrupt enable are enabled. The same thing happens when using timer 1. Has this happened to anyone?

charliecoutas

It sounds like the Watch Dog Timer is causing this. In the config section check this:


   WDTEN = off                                   ;Watch dog timer disabled
   WDTPS = 2048                                  ;

Charlie

Ivano

Good morning, I solved it.
I disabled the WDT because I thought it was due to this. In Word configuration, I set MVECEN = off.
I disabled multi-vector and now it works.
Thanks anyway.
Ivano

Ivano

Good morning, out of curiosity, is it possible to use multi vector in positron with pic that have this feature?

charliecoutas

Glad you sorted the watch dog timer problem.

I've never heard of multi-vector. Do you mean that the processor has a means of going to predefined address depending on the type of interrupt?

Charlie

trastikata

He probably meant the Interrupt Vector Table on newer 8-bit PIC devices. But it is not as efficient as on 16b devices therefore it has not been implemented.

Ivano

Good evening, to run some tests, I disabled the WDT because I thought that was it. Instead, I discovered that it was the multi-vector setting that needed to be disabled. Some PICs like the 18F46K42 have this option. If you have multiple interrupts, you need to check the various flags in the routine to determine the type of interrupt. In PICs with multi-vectors, you no longer need to consult the flags but go directly to the relevant interrupt routine (faster) via an address table. This is what I understood.
Perhaps the compiler needs to be modified for this system, which is why I asked if anyone has used multi-vectors. For example, they don't exist on the PIC 18F46K22, but they do on the PIC 18F46K42.

RGV250

Hi,
There is a Microchip app note on it which might be worth a read. https://ww1.microchip.com/downloads/en/Appnotes/Vectored-Interrupt-Controller-90003162C.pdf
You might be able to do it yourself?

Regards,
Bob

trastikata

#8
Quote from: Ivano on Dec 21, 2025, 04:02 PMyou no longer need to consult the flags but go directly to the relevant interrupt routine (faster) via an address table.

Here comes the question - how are you going to manage the stack and SFRs, especially with interrupt priorities?

Compare this to the additional instructions for checking flags in a Select ...Case within the legacy Isr. What is it 3 additional instruction per flag? Worst case scenario your Isr code takes (3 * #of flags to check) extra instructions.

Ivano

I've been reading Microchip's apps and I've learned a few things. I generally use one interrupt and rarely two interrupts, so I don't feel the need to use multi-vectors, but I recently discovered multi-vectors and was curious to understand how they work.

Thanks everyone for your interest.

Ivano

tumbleweed

There are still only two interrupt priority levels, same as the standard 18F.

If you have a number of interrupts it can take quite a bit more than 3 instructions to find the cause. Multivector mode can be significantly faster, if that matters.