title: How to simulate Interrupts in debug mode with PIC18?
body: <p>I tried to debug timer 1 interrupt with MPLAB Simulator, but it seems like the debugger never goes to the interrupt service routine.</p>
  
  <p>The settings for timer 1 seem correct to me , not sure if I missed something else. Here is the <a href="http://seniordesign.ee.nd.edu/2008/Design%20Teams/Awesome-o/datasheets/39778b.pdf" rel="nofollow">datasheet</a></p>
  
  <pre><code>/*  
       File: main.c
       Date: 2011-SEP-4
       Target: PIC18F87J11
       IDE: MPLAB 8.76
       Compiler: C18 3.40
  
   */
  #include &lt;p18cxxx.h&gt;
  
  #pragma config FOSC = INTOSC, WDTEN = OFF, XINST = OFF
  
  #pragma code HighISR = 0x08 // high priority 0x18
  #pragma interrupt HighISR
  
  
  
  int time = 0;
  
  void main(void) {
      /* set FOSC clock to 8MHZ */
      OSCCON = 0b01110000;
  
      /* turn off 4x PLL */
      OSCTUNE = 0x00;
  
      /* make all ADC inputs digital I/O */
      ANCON0 = 0xFF;
      ANCON1 = 0xFF;
  
      // 1/1 prescalar
      T1CONbits.T1CKPS1 = 0;
      T1CONbits.T1CKPS0 = 0;
  
      // Use Internal Clock
      T1CONbits.TMR1CS = 0;
  
      // Timer1 overflow interrupt
      PIE1bits.TMR1IE = 1;
  
      // Enable Timer 1
      T1CONbits.TMR1ON = 1;
  
      INTCONbits.PEIE = 1; // Enable Perpherial Interrupt
      INTCONbits.GIE = 1; // Enable Global Interrupt
  
  
  
      while (1);
  
  }
  
  
  // Timer Interrupt
  
  void HighISR(void) {
      if (PIR1bits.TMR1IF == 1) {
          time++;
          PIR1bits.TMR1IF = 0;
      }
  
  
  }
  </code></pre>