# PIC32mx Timer5 not working

I am struggling to put my Timer5 working properly. I think I have enabled all the registers but the interrupt never occurs. I already put a break point inside in the FingerprintRun() in the asm("nop") sentence and I found the TMR5 never goes above 0x0000.

void __ISR(_TIMER_5_VECTOR,IPL4) _T5Interrupt(void)
{
T5CONbits.ON = 0;
TMR5 = 0;
IFS0bits.T5IF = 0;
UART_TX = 0;
char x = 'b';
UARTFingerprintWriteChar( x );
}

void initTIMER5( void ){
__asm__("EI");
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR); //configure multi vector
INTEnableSystemMultiVectoredInt(); //enable interrupts

T5CONbits.TON = 0;

T5CONbits.TGATE = 0;
T5CONbits.SIDL = 0;
T5CONbits.TCKPS = 0;// 0b111;1:256 prescale value
TMR5 = 0;
PR5=0xD0;
IFS0bits.T5IF = 0; // Clear timer interrupt flag
IPC5bits.T5IP = 4; // Setting Timer 5 priority to level 4 of 7
IPC5bits.T5IS = 1; // setting timer 5 sub priority to level 1 of 3

IEC0bits.T5IE = 1; // Enable timer interrupts
T5CONbits.TON = 1;
}

void main() {
initTIMER5();
asm("nop");
while(1);
}


Am I missing something?

• I upvoted, cheer up! But you need to be more specific, for example I can't see where do you set the counter or increment TMR5. Where do you call FingerprintRun, what is the class Task and more importantly where is your main function? Jan 20 '16 at 21:37
• Ok, I will update the code for better understading. Thanks for the tip. @Alperözel the timer should increment by himself, no? I just set TMR5 = 0; Jan 20 '16 at 23:32
• Insert a while(1); after the asm("nop"); inside the main. The code may be crashing because getting to the end of main is bad. Jan 21 '16 at 0:59
• Sorry, I was doing that already. Probably it was a copy-paste problem. Jan 21 '16 at 10:48
• What is the exact model of you processor? Jan 21 '16 at 11:17