Page 1 of 1

Interrupts

Posted: Wed Dec 03, 2025 9:20 pm
by alanwms
Using PIC18f27q10. FC11
I have two interrupts. One is a hardware input interrupt. The other is a timer0 interrupt. I believe that priorities are settable but requires a few c code register adjustments such as (maybe):
IPR0bits.INT0IP = 1; // High priority
IPR0bits.TMR0IP = 0; // Low priority
I don't seem to be able to locate these registers in the data sheet, but this seems to compile ok.
If you have any details on this, I would appreciate feedback but.... - If I do not assign priorities, what default priority takes place?

Re: Interrupts

Posted: Thu Dec 04, 2025 12:00 am
by medelec35
Hello.

For Timer 0 and IOC interrupts High Priority, try:

Code: Select all

INTCONbits.IPEN = 1;    // Enable priority mode
IPR0bits.TMR0IP = 1;    // Timer0 = HIGH
IPR0bits.IOCIP = 1;     // IOC = HIGH
INTCONbits.GIEH = 1;    // Enable high priority interrupts
For Timer 0 High Priorit yand IOC interrupt low, try:

Code: Select all

INTCONbits.IPEN = 1;    // Enable priority mode
IPR0bits.TMR0IP = 1;    // Timer0 = HIGH
IPR0bits.IOCIP = 0;     // IOC = LOW
INTCONbits.GIEH = 1;    // Enable high priority interrupts
INTCONbits.GIEL = 1;    // Enable low priority interrupts
Or

INT0:
Always high priority

INT1:

Code: Select all

IPR0bits.INT1IP = 1;  // High priority

IPR0bits.INT1IP = 0;  // Low priority

INT2:

Code: Select all

IPR0bits.INT2IP = 1;  // High priority

IPR0bits.INT2IP = 0;  // Low priority


Without setting any priority bits, you get:

INT0 = HIGH priority (automatic)
INT1 = LOW priority (default)
INT2 = LOW priority (default)
Timer0 = LOW priority (default)
IOC = LOW priority (default)
All other interrupts = LOW priority (default)

So if you want any interrupt besides INT0 to be high priority, you must explicitly set its priority bit to 1.


I hope this helps.