i've been trying to implement a Timer1 interrupt, but when i activate the interrupt the USB port have problems, can anyone helpme? The problem ocurr in the USBTasks() function when the timer1 goes off, and the interrupt is activate
void UserInit(void) { ..... T1CON = 0b01000100; PIR1bits.TMR1IF = 0; // Clear flag TMR1H = TIMER1H_VAL; TMR1L = TIMER1L_VAL; // Reinit timer value; T1Cont=0; PORTDbits.RD4=1; INTCONbits.GIE=0; INTCONbits.PEIE=1; PIE1bits.TMR1IE=1; //Habilito interrupcion Timer1 T1CONbits.TMR1ON=1; PIE2=0x00; .....} ------------------------------------------------------------------------------------- #pragma code _HIGH_INTERRUPT_VECTOR = 0x000808 void _high_ISR (void) { ProcessTMR1();
_asm retfie 0 _endasm; } -------------------------------------------------------------------------------------- void ProcessTMR1(void) { if(PIR1bits.TMR1IF == 1) { PIR1bits.TMR1IF = 0; // Clear flag TMR1H = TIMER1H_VAL; TMR1L = TIMER1L_VAL; // Reinit timer value; T1Cont++; if(T1Cont==Posicion){ LATDbits.LATD4=0; //PORTDbits.RD4=0; } if(T1Cont>=400){ TMR1H = TIMER1H_VA1; TMR1L = TIMER1L_VA1; // Reinit timer value; } if(T1Cont==404){ T1Cont =0; LATDbits.LATD4=1; //PORTDbits.RD4=1; mLED_3_Toggle(); TMR1H = TIMER1H_VAL; TMR1L = TIMER1L_VAL; } } }//end ProcessTMR1
|