title: TIMER 32-bit on pic32 can't use interrupts
body: <p>Hi I have a PIC32MX370F512L from microchip.</p>
  
  <p>I want to use TIMER2 and TIMER3 as a 32-bit timer for interrupts.</p>
  
  <p>I CAN use 16-bit Timer interrupt but CAN'T use 32-bit Timer interrupt, I will show you both codes:</p>
  
  <p>16-bit timer:</p>
  
  <pre><code>void init16(){
  T2CONbits.ON = 0;           //Timer disabled
  
  T2CON = 0;      //Stop any 16-bit Timer2 operation
  
  T2CONbits.T32 = 0;          //16 bit mode on, tmr2 
  T2CONbits.TCKPS = 0b100;    //prescaler 
  T2CONbits.TCS = 0;          //Select internal peripheral clock
  PR2 = 0x0000FFFF;
  
  TMR2 = 0;                   //Clear contents of TMR2
  
  T2CONbits.ON = 1;           //Timer enable
  
  //====INTERRUPT PART========
  IEC0bits.T2IE   = 0;        //Disable interrupt
  IPC2bits.T2IP = 1; //Priority 1
  //IPC3bits.T3IS = 0; //Sub-priority 3
  
  IFS0bits.T2IF = 0; //Interrupt flag putted at zero
  //IFS0bits.T3IF = 0; //Interrupt flag putted at zero
  IEC0bits.T2IE   = 1;        //Enable interrupt
  }
  </code></pre>
  
  <p>32-bit timer:</p>
  
  <pre><code>void init32(){
  
  T2CONbits.ON = 0;           //Timer disabled
  
  T2CON = 0;      //Stop any 16/32-bit Timer2 operation
  T3CON = 0;      //Stop any 16-bit Timer3 operation
  
  T2CONbits.T32 = 1;          //32 bit mode on, tmr2 + tmr3
  T2CONbits.TCKPS = 0b100;    //Prescaler
  T2CONbits.TCS = 0;          //Select internal peripheral clock
  PR2 = 0x000FFFFF;
  //PR3 = 0;
  
  TMR2 = 0;                   //Clear contents of TMR2 and TMR3
  
  T2CONbits.ON = 1;           //Timer enable
  
  //====INTERRUPT PART========
  IEC0bits.T3IE = 0;        //Disable interrupt
  IPC3bits.T3IP = 1; //Priority 1
  //IPC3bits.T3IS = 0; //Sub-priority 0
  
  IFS0bits.T3IF = 0; //Interrupt flag putted at zero
  //IFS0bits.T3IF = 0; //Interrupt flag putted at zero
  IEC0bits.T3IE = 1;        //Enable interrupt
  }
  </code></pre>
  
  <p>main :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;p32xxxx.h&gt;
  #include &lt;plib.h&gt;
  #include "timer32Interrupt.h"
  #include &lt;xc.h&gt;
  
  /* Disable JTAG to use RA0 */
  #pragma config JTAGEN = OFF
  #pragma config FWDTEN = OFF //Watchdog disabled
  
  /* Device Config Bits in DEVCFG1: */
  #pragma config FNOSC = FRCPLL   //Fast RC Osc with PLL
  #pragma config FSOSCEN = OFF    //Secondary Oscillator disabled
  #pragma config POSCMOD = XT     //Primary Oscillator mode: Resonator, crystal or resonator
  #pragma config OSCIOFNC = ON    //CLKO Output Signal Active on the OSCO Pin
  #pragma config FPBDIV = DIV_2   //Peripheral Clock Divisor:  PBCLK is SYSCLK divided by 2
  
  /* Device Config Bits in DEVCFG2: */
  #pragma config FPLLIDIV = DIV_2 //PLL Input Divider
  #pragma config FPLLMUL = MUL_20 //PLL Multiplier
  #pragma config FPLLODIV = DIV_2 //System PLL Output Clock Divider: PLL Divide by 2
  
  
  void main(){
      TRISA = 0;
      LATA = 0;
      LATAbits.LATA0 = 1;
      //LATAbits.LATA0 =~LATAbits.LATA0
  
      INTEnableSystemMultiVectoredInt();
      init32();
      //init16();
  
      while(1){
          int i = 0;
          if(TMR2 &gt;= PR2 - 10 ){
  
              //LATAbits.LATA0 =~LATAbits.LATA0;
              //LATAbits.LATA2 =~LATAbits.LATA2;
              LATAINV = 0b10;
          }
  
      }
  
  
  
  }
  
  
  void __ISR(_TIMER_2_VECTOR, ipl1)Timer32Handler(void){
      LATAINV = 0b101;
      IFS0bits.T3IF = 0; //Interrupt flag putted at zero
      IFS0bits.T2IF = 0; //Interrupt flag putted at zero
  
  }
  </code></pre>
  
  <p>The 16 bit implementation works and the 32 not, enabling interrupt on TIMER3 and not on TIMER2 is required in the data-sheet, section 14.3.4 of the timers.</p>