例如,在如下一段代码中:
- /* 1 second interval when assuming 1 MHz clock frequency and 1024x prescaling */
- #define TOP (1000000/1024)
- /**************************************************************************//**
- * [url=home.php?mod=space&uid=247401]@brief[/url] Initialize TIMER0 in Up/Down Count mode and to give interrupts when
- * turning from counting up to down (overflow) and from down to up (underflow)
- *****************************************************************************/
- void initTimer()
- {
- TIMER_Init_TypeDef initValues = TIMER_INIT_DEFAULT;
-
- /* Enable clock for TIMER0 */
- CMU_ClockEnable(cmuClock_TIMER0, true);
-
- /* Enable underflow and overflow interrupt for TIMER0*/
- TIMER_IntEnable(TIMER0, TIMER_IF_OF);
- TIMER_IntEnable(TIMER0, TIMER_IF_UF);
-
- /* Enable TIMER0 interrupt vector in NVIC */
- NVIC_EnableIRQ(TIMER0_IRQn);
-
- /* Set TIMER0 Top value */
- TIMER_TopSet(TIMER0, TOP);
-
- /* Initialize TIMER0 in Up/Down mode with 1024x prescaling */
- initValues.prescale = timerPrescale1024;
- initValues.mode = timerModeUpDown;
- TIMER_Init(TIMER0, &initValues);
-
- /* Start TIMER0 */
- TIMER0->CMD = TIMER_CMD_START;
- }
- /**************************************************************************//**
- * @brief TIMER0 Interrupt Handler. Writes status to LCD display
- *****************************************************************************/
- void TIMER0_IRQHandler(void)
- {
- /* Store the interrupt flags before clearing */
- uint16_t intFlags = TIMER_IntGet(TIMER0);
-
- /* Clear the interrupt flags. Only clear the flags that were stored in */
- /* intFlags in case other flags have been set since then */
- TIMER_IntClear(TIMER0, intFlags);
- /* Overflow interrupt occured */
- if(intFlags & TIMER_IF_OF)
- {
- SegmentLCD_Write("OVER");
- }
-
- /* Underflow interrupt occured */
- if(intFlags & TIMER_IF_UF)
- {
- SegmentLCD_Write("UNDER");
- }
- }
- /**************************************************************************//**
- * @brief Main function
- *****************************************************************************/
- int main(void)
- {
- /* Chip revision alignment and errata fixes */
- CHIP_Init();
-
- /* Set system frequency to 1 MHz */
- CMU_HFRCOBandSet(cmuHFRCOBand_1MHz);
-
- /* Initialize LCD */
- SegmentLCD_Init(false);
- /* Initialize TIMER0 */
- initTimer();
-
- /* Go to EM1 when not servicing interrupts */
- while(1)
- {
- EMU_EnterEM1();
- }
- }
当产生中断时,系统如何知道要去调用TIMER0_IRQHandler函数,而不是其他函数?
又是一个新手问题,烦请各位高手指点。
|