void Timer::interruptHandler() { // DEBUG("timer irq 0x%x\r\n", this); if(TIM_GetIntStatus(TIMER_PERIPHERAL, TIM_MR0_INT) == SET) { // DEBUG("overflow 0x%x\r\n", this); // if(isLast) // { // TIM_ClearIntPending(TIMER_PERIPHERAL, TIM_MR0_INT); // } overflows++; } if(TIM_GetIntStatus(TIMER_PERIPHERAL, TIM_MR1_INT) == SET) { // if(isLast) // { // // DEBUG("clearing 0x%x\r\n", this); // TIM_ClearIntPending(TIMER_PERIPHERAL, TIM_MR1_INT); // } if(callbackActive && read_us() >= callbackDelay) { frozenTimerValue = TIMER_PERIPHERAL->TC; // DEBUG("calling 0x%x\r\n", this); callbackActive = false; _removeMatch(matchValue); callbackFunction->call(); } else { // DEBUG("not calling 0x%x\r\n", this); } } }
void TIMER1_IRQHandler(void){ // xprintf("TIMER1_IRQ"); if (TIM_GetIntStatus(LPC_TIM1,TIM_MR0_INT)){ TIM_ClearIntPending(LPC_TIM1, TIM_MR0_INT); LatchIn(); } }
void TIMER2_IRQHandler(void){ // xprintf("TIMER2_IRQ\r\n"); if (TIM_GetIntStatus(LPC_TIM2,TIM_MR0_INT)){ TIM_ClearIntPending(LPC_TIM2, TIM_MR0_INT); LED_INT_OCCURED = 1; } }
/*********************************************************************//** * @brief Timer 0 interrupt handler. This sub-routine will set/clear * two Phase A-B output pin to their phase state * @param[in] None * @return None **********************************************************************/ void TIMER0_IRQHandler(void) { if (TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT)) { // Set/Clear phase A/B pin corresponding to their state switch (PhaseCnt) { case 0: GPIO_SetValue(0,PHASE_A_PIN); GPIO_ClearValue(0,PHASE_B_PIN); break; case 1: GPIO_SetValue(0, PHASE_A_PIN | PHASE_B_PIN); break; case 2: GPIO_SetValue(0, PHASE_B_PIN); GPIO_ClearValue(0, PHASE_A_PIN); break; case 3: GPIO_ClearValue(0, PHASE_A_PIN | PHASE_B_PIN); break; default: break; } // update PhaseCnt PhaseCnt = (PhaseCnt + 1) & 0x03; // Clear Timer 0 match interrupt pending TIM_ClearIntPending(LPC_TIM0,TIM_MR0_INT); } }
/////////////////////////////////////////////////////////////////////////////// /// @brief TIMER1 interrupt handler sub-routine /// @param[in] None /// @return None /////////////////////////////////////////////////////////////////////////////// void TIMER1_IRQHandler1(void) { // if (TIM_GetIntCaptureStatus(LPC_TIM1,0)) // { // TIM_ClearIntCapturePending(LPC_TIM1,0); if(TIM_GetIntStatus(LPC_TIM1, TIM_CR0_INT)) { TIM_ClearIntPending(LPC_TIM1, TIM_CR0_INT); uint32_t capt = TIM_GetCaptureValue(LPC_TIM1,0); uint32_t diff = capt - Timer1Capture0Value; if(diff > 5000) { if(Recv.index != 12) { GPIO_SetValue(TRIG_PORT, TRIG_PIN); tim_cr0_int_error++; GPIO_ClearValue(TRIG_PORT, TRIG_PIN); } Recv.index = 0; } else { if(Recv.index < MAX_CHANNELS && diff > 500 && diff < 2500) { Recv.channel[Recv.index] = diff; } Recv.index++; } Timer1Capture0Value = capt; } }
int Timer_delay_ms(int count) { // Initialize timer 0, prescale count time of 100uS TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; TIM_ConfigStruct.PrescaleValue = 1000; // use channel 0, MR0 TIM_MatchConfigStruct.MatchChannel = 0; // Disable interrupt when MR0 matches the value in TC register TIM_MatchConfigStruct.IntOnMatch = TRUE; //Enable reset on MR0: TIMER will reset if MR0 matches it TIM_MatchConfigStruct.ResetOnMatch = TRUE; //Stop on MR0 if MR0 matches it TIM_MatchConfigStruct.StopOnMatch = FALSE; //Toggle MR0.0 pin if MR0 matches it TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE; // Set Match value, count value of 1000 (1000 * 100uS = 100mS --> 10Hz) TIM_MatchConfigStruct.MatchValue = count; // Set configuration for Tim_config and Tim_MatchConfig TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct); TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct); TIM_Cmd(LPC_TIM0,ENABLE); // Wait for 1000 millisecond while(!(TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT))); TIM_ClearIntPending(LPC_TIM0,TIM_MR0_INT); return 0; }
/*********************************************************************//** * @brief Delay millisecond * @param[in] time (ms) * @return None **********************************************************************/ void Timer_Wait(uint32_t time) { // Initialize timer 0, prescale count time of 1ms TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; TIM_ConfigStruct.PrescaleValue = 1000; // use channel 0, MR0 TIM_MatchConfigStruct.MatchChannel = 0; // Enable interrupt when MR0 matches the value in TC register TIM_MatchConfigStruct.IntOnMatch = TRUE; //Enable reset on MR0: TIMER will not reset if MR0 matches it TIM_MatchConfigStruct.ResetOnMatch = FALSE; //Stop on MR0 if MR0 matches it TIM_MatchConfigStruct.StopOnMatch = TRUE; //do no thing for external output TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_NOTHING; // Set Match value, count value is time (timer * 1000uS =timer mS ) TIM_MatchConfigStruct.MatchValue = time; // Set configuration for Tim_config and Tim_MatchConfig TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct); TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct); // To start timer 0 TIM_Cmd(LPC_TIM0,ENABLE); while ( !(TIM_GetIntStatus(LPC_TIM0,0))); TIM_ClearIntPending(LPC_TIM0,0); }
int c_entry(void) { // Init LED port LED_Init(); /* * Initialize debug via UART */ debug_frmwrk_init(); // print welcome screen print_menu(); // Read back TimeOut flag to determine previous timeout reset if (WDT_ReadTimeOutFlag()){ _DBG_(info1); // Clear WDT TimeOut WDT_ClrTimeOutFlag(); } else{ _DBG_(info2); } // Initialize WDT, IRC OSC, interrupt mode, timeout = 2000000 microsecond WDT_Init(WDT_CLKSRC_IRC, WDT_MODE_RESET); // Start watchdog with timeout given WDT_Start(WDT_TIMEOUT); // set timer 100 ms Timer_Wait(100); while (1){ // Wait for 100 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); TIM_ClearIntPending(LPC_TIM0,0); //turn on led FIO_ByteSetValue(2, 0, LED_PIN); // Wait for 100 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); TIM_ClearIntPending(LPC_TIM0,0); //turn off led FIO_ByteClearValue(2, 0, LED_PIN); } return 0; }
void TIMER0_IRQHandler(void) { if (TIM_GetIntStatus(LPC_TIM0, TIM_MR0_INT) != RESET) { TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); rt_device_hwtimer_isr(&_timer0); } }
Status Timer0_Status(void) { if (TIM_GetIntStatus(TIMER0,TIM_MR0_INT)) { return SUCCESS; } else { return ERROR; } }
void TIMER0_IRQHandler(void){ char msg[BUFFLENGTH] = ""; char* strPtr = &msg; if (TIM_GetIntStatus(LPC_TIM0, TIM_MR0_INT)== SET){ TIM_Cmd(LPC_TIM0,DISABLE); TIM_ResetCounter(LPC_TIM0); tim0_flag = 1; TIM_Cmd(LPC_TIM0,ENABLE); } TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); }
void TIMER1_IRQHandler(void) { PWM_MATCHCFG_Type PWMMatchCfgDat; if (TIM_GetIntStatus(LPC_TIM1, TIM_MR1_INT)== SET) { amp += 0.5; freq += 100; } TIM_ClearIntPending(LPC_TIM1, TIM_MR1_INT); }
void TIMER1_IRQHandler (void) { if(TIM_GetIntStatus(LPC_TIM1,TIM_MR0_INT)) // if MR0 interrupt { LPC_TIM1->IR |= 1<<0; stopTimerInt(0); UartRx_interrupt = 1; } else if(TIM_GetIntStatus(LPC_TIM1,TIM_MR1_INT)) // if MR1 interrupt { LPC_TIM1->IR |= 1<<1; stopTimerInt(1); } else if(TIM_GetIntStatus(LPC_TIM1,TIM_MR2_INT)) // if MR1 interrupt { LPC_TIM1->IR |= 1<<2; stopTimerInt(2); } else if(TIM_GetIntStatus(LPC_TIM1,TIM_MR3_INT)) // if MR1 interrupt { LPC_TIM1->IR |= 1<<3; stopTimerInt(3); } }
/*********************************************************************//** * @brief TIM3 interrupt handler sub-routine * @param None * @return None **********************************************************************/ void TIMER3_IRQHandler(void) { if (TIM_GetIntStatus(LPC_TIM3, TIM_MR0_INT)== SET) { TIM_Cmd(LPC_TIM3,DISABLE); // Disable Timer TIM_ResetCounter(LPC_TIM3); if(toggle_tim3 == TRUE) { TIM_UpdateMatchValue(LPC_TIM3,0,T1*10);//MAT3.0 toggle_tim3=FALSE; } else { TIM_UpdateMatchValue(LPC_TIM3,0,T2*10); toggle_tim3=TRUE; } TIM_Cmd(LPC_TIM3,ENABLE); // Start Timer } TIM_ClearIntPending(LPC_TIM3, TIM_MR0_INT); // clear Interrupt }
void TIMER0_IRQHandler () { if (TIM_GetIntStatus(LPC_TIM0, TIM_MR0_INT) == SET) { NVIC_DisableIRQ(TIMER0_IRQn); //disable interrupt, to prevent it from overlapping if it takes too long to process TIM_ClearIntPending(LPC_TIM0,TIM_MR0_INT); TIM_ResetCounter(LPC_TIM0); #if DEBUG==1 && TRACE==1 tty_writeln("Timer trigger"); #endif if (scramble_mode) { scramble_timer_handler(); } else { filter_loop(); } cycle++; //used for sine wave generation if(cycle > frequency) cycle = 0; NVIC_EnableIRQ(TIMER0_IRQn); } }
int c_entry(void) { // DeInit NVIC and SCBNVIC NVIC_DeInit(); NVIC_SCBDeInit(); /* Configure the NVIC Preemption Priority Bits: * two (2) bits of preemption priority, six (6) bits of sub-priority. * Since the Number of Bits used for Priority Levels is five (5), so the * actual bit number of sub-priority is three (3) */ NVIC_SetPriorityGrouping(0x05); // Set Vector table offset value #if (__RAM_MODE__==1) NVIC_SetVTOR(0x10000000); #else NVIC_SetVTOR(0x00000000); #endif // Init LED port LED_Init(); /* Init debug */ debug_frmwrk_init(); // print welcome screen print_menu(); // Initialize timer 0, prescale count time of 100uS TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; TIM_ConfigStruct.PrescaleValue = 100; // use channel 0, MR0 TIM_MatchConfigStruct.MatchChannel = 0; // Disable interrupt when MR0 matches the value in TC register TIM_MatchConfigStruct.IntOnMatch = TRUE; //Enable reset on MR0: TIMER will reset if MR0 matches it TIM_MatchConfigStruct.ResetOnMatch = TRUE; //Stop on MR0 if MR0 matches it TIM_MatchConfigStruct.StopOnMatch = FALSE; //Toggle MR0.0 pin if MR0 matches it TIM_MatchConfigStruct.ExtMatchOutputType =TIM_EXTMATCH_TOGGLE; // Set Match value, count value of 10000 (10000 * 100uS = 1S --> 1Hz) TIM_MatchConfigStruct.MatchValue = 10000; // Set configuration for Tim_config and Tim_MatchConfig TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct); TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct); TIM_Cmd(LPC_TIM0,ENABLE); while (1) { // Wait for 1000 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); { TIM_ClearIntPending(LPC_TIM0,0); //turn on led LPC_GPIO2->FIOSET = LED0_PIN; UART_Send(LPC_UART0, info1, sizeof(info1), BLOCKING); } // Wait for 1000 millisecond while ( !(TIM_GetIntStatus(LPC_TIM0,0))); { TIM_ClearIntPending(LPC_TIM0,0); //turn off led LPC_GPIO2->FIOCLR = LED0_PIN; UART_Send(LPC_UART0, info2, sizeof(info2), BLOCKING); } } TIM_DeInit(LPC_TIM0); return (1); }
void TIMER0_IRQHandler(void){ // xprintf("TIMER0_IRQ"); if (TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT)){ TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); #if 0 if(TOG[0]) // FIO_SetValue(LED_LE_PORT, LED_LE_BIT); GPIO_SetValue(LED_4_PORT, LED_4_BIT); else // FIO_ClearValue(LED_LE_PORT, LED_LE_BIT); GPIO_ClearValue(LED_4_PORT, LED_4_BIT); TOG[0]=!TOG[0]; // TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); // return; #endif // xprintf(INFO "RIT N=%d B=%x NXT_T=%d TX=%x\n",SENDSEQ,SEND_BIT,DELAY_TIME,LED_PRECALC[0][SEND_BIT]); //Setup new timing for next Timer DELAY_TIME=SEQ_TIME[SENDSEQ]; SEND_BIT=SEQ_BIT[SENDSEQ]; //Retart sequence if required SENDSEQ++; SENDSEQ>=no_SEQ_BITS ? SENDSEQ=0 : 0; #ifdef DMA // xprintf("SEND_BIT:%d\n",SEND_BIT); // xprintf("DELAY_TIME:%d\n",DELAY_TIME); GPDMACfg.DMALLI = (uint32_t) &LinkerList[0][SEND_BIT][BufferNo]; GPDMA_Setup(&GPDMACfg); GPDMA_ChannelCmd(0, ENABLE); #endif TIM_UpdateMatchValue(LPC_TIM0,0,DELAY_TIME); FIO_SetValue(LED_OE_PORT, LED_OE_BIT); #ifdef RxDMA GPDMA_ChannelCmd(1, ENABLE); uint8_t reg; for(reg=6; 0<reg;reg--){ xprintf("%d ",reg-1); #if 0 if(BUFFER==1) SSP_SendData(LED_SPI_CHN, LED_PRECALC1[reg][SEND_BIT]); else SSP_SendData(LED_SPI_CHN, LED_PRECALC2[reg][SEND_BIT]); #endif //WaitForSend();//Wait if TX buffer full //while(LED_SPI_CHN->SR & SSP_STAT_BUSY); while(SSP_GetStatus(LED_SPI_CHN, SSP_STAT_BUSY)){ }; SSP_SendData(LED_SPI_CHN, LED_PRECALC[reg-1][SEND_BIT]); xprintf("%4x ",(LED_PRECALC[reg-1][SEND_BIT])); } for(reg=12; reg>6;reg--){ xprintf("%d ",reg-1); #if 0 if(BUFFER==1) SSP_SendData(LED_SPI_CHN, LED_PRECALC1[reg][SEND_BIT]); else SSP_SendData(LED_SPI_CHN, LED_PRECALC2[reg][SEND_BIT]); #endif //WaitForSend();//Wait if TX buffer full while(SSP_GetStatus(LED_SPI_CHN, SSP_STAT_BUSY)){ } SSP_SendData(LED_SPI_CHN, LED_PRECALC[reg-1][SEND_BIT]); // if (reg==7){ xprintf("%4x ",(LED_PRECALC[reg-1][SEND_BIT])); // } } LatchIn(); #endif /* UPDATE_COUNT+=1; ATE_COUNT=0; LED_UPDATE_REQUIRED=1; }*/ } }
void TIMER0_IRQHandler() { flag_RCV = TIM_GetIntStatus(TIMER0, TIM_CR0_INT); // WTF ? }