void __ISR(_TIMER_5_VECTOR, ipl4) _Timer5Handler(void) { //Reset the flag mT5ClearIntFlag(); //Put code here }
void __ISR(_TIMER_5_VECTOR, ipl7) Timer5Handler(void) { // Read the raw state of the button pins. btnBtn1.stCur = ( prtBtn1 & ( 1 << bnBtn1 ) ) ? stPressed : stReleased; btnBtn2.stCur = ( prtBtn2 & ( 1 << bnBtn2 ) ) ? stPressed : stReleased; // Update state counts. btnBtn1.cst = ( btnBtn1.stCur == btnBtn1.stPrev ) ? btnBtn1.cst + 1 : 0; btnBtn2.cst = ( btnBtn2.stCur == btnBtn2.stPrev ) ? btnBtn2.cst + 1 : 0; // Save the current state. btnBtn1.stPrev = btnBtn1.stCur; btnBtn2.stPrev = btnBtn2.stCur; // Update the state of button 1 if necessary. if ( cstMaxCnt == btnBtn1.cst ) { btnBtn1.stBtn = btnBtn1.stCur; btnBtn1.cst = 0; } // Update the state of button 2 if necessary. if( cstMaxCnt == btnBtn2.cst ) { btnBtn2.stBtn = btnBtn2.stCur; btnBtn2.cst = 0; } mT5ClearIntFlag(); }
//============================================= // Configure the Timer 5 interrupt handler //============================================= void __ISR(_TIMER_5_VECTOR, T5_INTERRUPT_PRIORITY) Timer5InterruptHandler(void) { oTimerChngMode = 1; // Increment the number of overflows from this timer. Used primarily by Input Capture Timer.Var.nOverflows[4]++; mT5ClearIntFlag(); }
void vPortIncrementTick( void ) { unsigned portBASE_TYPE uxSavedStatus; uxSavedStatus = uxPortSetInterruptMaskFromISR(); vTaskIncrementTick(); vPortClearInterruptMaskFromISR( uxSavedStatus ); /* If we are using the preemptive scheduler then we might want to select a different task to execute. */ #if configUSE_PREEMPTION == 1 SetCoreSW0(); #endif /* configUSE_PREEMPTION */ /* Clear timer 0 interrupt. */ mT5ClearIntFlag(); }
/** * @function TmrLaunch * @brief enable a given timer, if this one is correctly configured * @param tmr_t tmr_id: timer id * @return none */ void TmrLaunch(tmr_t tmr_id) { switch(tmr_id) { case TMR_1: if(timer1Configured == 1 && tmr1PtrCallback != NULL) { mT1ClearIntFlag(); T1CONSET = 0x8000; } break; case TMR_4: if(timer4Configured == 1 && tmr4PtrCallback != NULL) { mT4ClearIntFlag(); T4CONSET = 0x8000; } break; case TMR_5: if(timer5Configured == 1 && tmr5PtrCallback != NULL) { mT5ClearIntFlag(); T5CONSET = 0x8000; } break; default: break; } }
/** * @function TmrSetFrequency * @brief configure a given timer with a desired frequency * @param tmr_t tmr_id: timer id * @param uint32_t desiredFrequency: desired frequency, in Hz * @return int8_t: 0 sucess, otherwise error */ int8_t TmrSetFrequency(tmr_t tmr_id, uint32_t desiredFrequency) { uint16_t tmrValue = 0xFFFF; uint16_t prescale; uint32_t cfg; int8_t res = -1; switch(tmr_id) { case TMR_1: if(SetTimerFrequency(TMR_TYPE_A, desiredFrequency, &tmrValue, &prescale) == 0) { TmrStop(TMR_1); mT1ClearIntFlag(); ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_1 | T1_INT_SUB_PRIOR_1); cfg = T1_SOURCE_INT | T1_IDLE_CON; if(prescale == 1) cfg |= T1_PS_1_1; else if(prescale == 8) cfg |= T1_PS_1_8; else if(prescale == 64) cfg |= T1_PS_1_64; else cfg |= T1_PS_1_256; OpenTimer1(cfg, tmrValue); timer1Configured = 1; res = 0; } break; case TMR_4: if(SetTimerFrequency(TMR_TYPE_B, desiredFrequency, &tmrValue, &prescale) == 0) { TmrStop(TMR_4); mT4ClearIntFlag(); ConfigIntTimer4(T4_INT_ON | T4_INT_PRIOR_4 | T4_INT_SUB_PRIOR_1); cfg = T4_SOURCE_INT | T4_IDLE_CON; if(prescale == 1) cfg |= T4_PS_1_1; else if(prescale == 2) cfg |= T4_PS_1_2; else if(prescale == 4) cfg |= T4_PS_1_4; else if(prescale == 8) cfg |= T4_PS_1_8; else if(prescale == 16) cfg |= T4_PS_1_16; else if(prescale == 32) cfg |= T4_PS_1_32; else if(prescale == 64) cfg |= T4_PS_1_64; else cfg |= T4_PS_1_256; OpenTimer4(cfg, tmrValue); timer4Configured = 1; res = 0; } break; case TMR_5: if(SetTimerFrequency(TMR_TYPE_B, desiredFrequency, &tmrValue, &prescale) == 0) { TmrStop(TMR_5); mT5ClearIntFlag(); ConfigIntTimer5(T5_INT_ON | T5_INT_PRIOR_5 | T5_INT_SUB_PRIOR_1); cfg = T5_SOURCE_INT | T5_IDLE_CON; if(prescale == 1) cfg |= T5_PS_1_1; else if(prescale == 2) cfg |= T5_PS_1_2; else if(prescale == 4) cfg |= T5_PS_1_4; else if(prescale == 8) cfg |= T5_PS_1_8; else if(prescale == 16) cfg |= T5_PS_1_16; else if(prescale == 32) cfg |= T5_PS_1_32; else if(prescale == 64) cfg |= T5_PS_1_64; else cfg |= T5_PS_1_256; OpenTimer5(cfg, tmrValue); timer5Configured = 1; res = 0; } break; default: break; } return res; }
/** * @function Timer5Handler * @brief Timer5 interruption handler * @param none * @return none */ void __ISR(_TIMER_5_VECTOR, ipl5) Timer5Handler(void) { tmr5PtrCallback(); mT5ClearIntFlag(); }
// stopped working with newer C32 dist (V2.02) void __ISR(_TIMER_5_VECTOR, ipl5) _T5Interrupt(void) { gTimerHigh++; mT5ClearIntFlag(); }