1
\$\begingroup\$

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?

\$\endgroup\$
8
  • \$\begingroup\$ 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? \$\endgroup\$
    – Alper91
    Jan 20 '16 at 21:37
  • \$\begingroup\$ 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; \$\endgroup\$
    – scuba
    Jan 20 '16 at 23:32
  • \$\begingroup\$ 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. \$\endgroup\$
    – vini_i
    Jan 21 '16 at 0:59
  • \$\begingroup\$ Sorry, I was doing that already. Probably it was a copy-paste problem. \$\endgroup\$
    – scuba
    Jan 21 '16 at 10:48
  • \$\begingroup\$ What is the exact model of you processor? \$\endgroup\$
    – vini_i
    Jan 21 '16 at 11:17
0
\$\begingroup\$

it seems the interrupt is not being enabled (don't know why) so I found another way to make it work.

Instead of: IEC0bits.T5IE = 1; // Enable timer interrupts

I am using: IEC0 = 0x100000;

\$\endgroup\$
1
  • \$\begingroup\$ You might submit this to technical support. Also you may want to use IEC0SET so you dont clear the other bits... \$\endgroup\$
    – Szidor
    Jan 23 '16 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.