Hi Darrel,
With RCON,IPEN = 0 it's in compatibility mode. I.E. no priority levels on any interrupts, and it's just as easy as say setting up & using interrupts on a 16F part.
There's no GIEH, GIEL, or any priority high/low bit settings to worry about. So, it's actually a bit easier than setting up & using high & low priority interrupts.
Here's an example;
Code:
list p=18f452
include "p18f452.inc"
CONFIG OSC=XT,OSCS=OFF,WDT=OFF,WDTPS=128,BOR=ON,BORV=45,LVP=OFF
CBLOCK 0x08
MyVar
ENDC
ORG 0x000
BRA Init
ORG 0x008 ; all ints vector here in compatibility mode
BRA TMR_INT ; and high-pri vectors here when enabled
ORG 0x018 ; low-pri int vector, but only when priority
BRA LOW_PRI ; interrupts are enabled
Init
CLRF MyVar ; clear MyVar
CLRF PORTB ; Clear PORTB
CLRF TRISB ; PORTB all outputs
MOVLW 0x07
MOVWF ADCON1 ; disable A/D
MOVLW B'11000111' ; TMR0 on, 8-bit, prescaler, 1:256
MOVWF T0CON
BCF RCON,IPEN ; disable priority interrupts
BCF INTCON,TMR0IF
; since RCON,IPEN=0, we don't need to worry about any priority
; bit settings for any interrupt source, and we refer to GIE,PEIE
; VS GIEH,GIEL because we're in "compatibility" mode. We don't
; have to mess with anything related to high or low priority
; interrupts. Compatibility mode is just as easy as interrupts on
; 16F parts.
BSF INTCON,TMR0IE ; enable Timer0 interrupt
BSF INTCON,PEIE ; peripheral ints enabled
BSF INTCON,GIE ; global enabled
Main
MOVFF MyVar,PORTB ; show count on PORTB LEDs
BRA Main
TMR_INT ; default int vector for all interrupts
INCF MyVar ; when in compatibility mode
BCF INTCON,TMR0IF
RETFIE FAST
LOW_PRI ; never gets here because priority ints
INCF MyVar ; are not enabled when RCON,IPEN = 0
BCF INTCON,TMR0IF
RETFIE FAST
END
And you still have the benefit of fast return with auto context restore even with low pri interrupts.
Maybe I should have said - I use NO priority levels or compatibility mode VS only low priority interrupts. The only time I enable priority levels is when I have more than one interrupt, and one or more needs to interrupt the less important interrupt assigned to the low vector.
Otherwise it's easier to just use compatibility mode with no priority levels to worry about.
I know you're already aware of this, but I figured it would be good to post so folks reading this didn't get confused between using priority levels - I.E. high & low VS compatibility mode where there are no priority levels enabled.
Bookmarks