Interrupts

For general Flowcode discussion that does not belong in the other sections.
Post Reply
alanwms
Posts: 148
http://meble-kuchenne.info.pl
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Interrupts

Post 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?

medelec35
Valued Contributor
Posts: 2199
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 669 times
Been thanked: 745 times

Re: Interrupts

Post 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.
Martin

Post Reply