Re: unable to use PIC18 low isr

Started by Dennis Clark July 1, 2008
> I have been attempting to use the PIC18 low isr but can't seem to get
> anything but the high isr to fire. I have reduced my code to the
> following and it works fine as long as I use the high isr. If I set a
> break point on the low one, it never gets accessed. The original code was
> designed to use the low isr only and I have been able to make it work by
> pointing the high vector to the low handler. Changing IPEN makes no
> difference. Not really what I wanted!
>
> Any suggestions?

You have not enabled the low priority interrupts. When IPEN is set,
allowing high priority interrupts then the GIE bit is actually the GIEH
(high priority IRQ) only. You must also set INTCONbits.GIEL to turn on
the low priority interrupts.

DLC

> #include
> #include
> #include #pragma config OSC = HS
> #pragma config PWRT = OFF
> #pragma config BOREN = OFF
> #pragma config WDT = OFF
> #pragma config MCLRE = ON
> #pragma config PBADEN = OFF
> #pragma config LVP = OFF
> void timer0_isr(void); // Interrupt
>
> void init(void); // Initial
>
> #pragma code high_vector=0x08
>
> void high_vector(void)
> {
> _asm GOTO timer0_isr _endasm
> }
>
> #pragma code /* return to the default code section */
>
> #pragma code low_vector=0x18
>
> void low_vector(void)
> {
> _asm GOTO timer0_isr _endasm
> }
>
> #pragma code /* return to the default code section */
> //#pragma interruptlow timer0_isr
>
> void timer0_isr (void)
> {
> unsigned int i;
>
> TMR0H=0X80;
> TMR0L=0X00;
>
> i++;
>
> INTCONbits.TMR0IF = 0;
> INTCONbits.GIE = 1; //jb added when seen that GIE gets reset
>
> }
> /******************************************************/
> void main (void)
> {
>
> // timer0_isr(); //jb added as test to display temp prior to ints
> OpenTimer0 (TIMER_INT_ON & T0_SOURCE_INT & T0_16BIT);
> RCONbits.IPEN=1; //jb added due to c18 app note on no high isr
> INTCON2bits.TMR0IP = 1;
> INTCON2bits.RBIP = 0;
> INTCONbits.TMR0IF = 0; //jb added to clear the tmr0 flag
>
> INTCONbits.GIE = 1;
> while(1){};
> }
>
>
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions