Virendra Kumar
Virendra Kumar

Reputation: 977

UART receive Interrupt enabled but with no ISR?

I am curious , if a interrupt in enabled but we have not written a ISR for it. Then what happens to the code flow if that interrupt comes(Ex: UART receive interrupt).

What is the default value in the Interrupt vector table for any particular Interrupt vector .

My Assumptions: When a interrupt will come then, the code will jump to the Interrupt vector table and since there will be no Jump instruction to a ISR( as we have not written the ISR). So, the Program counter will be stuck there.

Upvotes: 1

Views: 827

Answers (2)

kestasx
kestasx

Reputation: 1091

I think there may be different implementations, but at least x86 real mode interrupt table holds just addresses, not instructions. So if You enable interrupt before seting valid address and interrupt arrives - CPU jumps to whatever address is in the interrupt table.

If info here is correct - ARM interrupt table hold instruction instead of address. I would assume ARM executes whatever instructin it finds in this table, but I don't have experience to be sure.

Upvotes: 2

francis
francis

Reputation: 9817

Here is an abstract of 18f4550's datasheet ; 9.0 interrupts , on page 101 :

The high-priority interrupt vector is at 000008h and the low-priority interrupt vector is at 000018h.

Here some registers controlling interrupts of UART :

IPR1bits.RCIP=1; //priority of UART interrupt :1==high
PIR1bits.RCIF=0;//erase interruption flag if set
PIE1bits.RCIE=1;//enable interrupt on UART reception

If setting PIR1bits.RCIF=0;PIE1bits.RCIE=0; does not clear your porblem, the issue may be somewhere else.

Otherwise, add an interrupt code. If you use the XC8 compiler of microchip, it looks like :

//on high priority interrupt, going here
void interrupt high_isr (void)
{
    if(PIR1bits.RCIF){ //receiving something, UART
        //reading...
        c=getcUSART ();
        //doing someting...
        ...
        PIR1bits.RCIF=0; //clearing interrupt flag, UART
    }
}

//on low priority interrupt, going here
void interrupt low_priority low_isr (void)
{

}

It was slightly more tricky with compiler C18 of microchip :

void YourHighPriorityISRCode();
void YourLowPriorityISRCode();

#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
  _asm GOTO YourHighPriorityISRCode _endasm
}

#pragma code low_vector=0x18
void interrupt_at_low_vector(void)
{
  _asm GOTO YourLowPriorityISRCode _endasm
}

#pragma interrupt YourHighPriorityISRCode
  void YourHighPriorityISRCode()
  {
    ...
  }

#pragma interruptlow YourLowPriorityISRCode
  void YourLowPriorityISRCode()
  {
    ...
  }

Upvotes: 0

Related Questions