Example #1
0
void TMR0_IRQHandler(void)
{
    // printf takes long time and affect the freq. calculation, we only print out once a while
    static int cnt = 0;
    static uint32_t t0, t1;

    if(cnt == 0)
    {
        t0 = TIMER_GetCaptureData(TIMER0);
        cnt++;
    }
    else if(cnt == 1)
    {
        t1 = TIMER_GetCaptureData(TIMER0);
        cnt++;
        if(t0 > t1)
        {
            // over run, do nothing
        }
        else
        {
            printf("Input frequency is %dHz\n", 22118400 / (t1 - t0)); // timer clock source is 22MHz
        }
    }
    else
    {
        cnt = 0;
    }


    TIMER_ClearCaptureIntFlag(TIMER0);

}
Example #2
0
/**
 * @brief       Timer-1 IRQ
 *
 * @param       None
 *
 * @return      None
 *
 * @details     The TIMER1 default IRQ, declared in startup_Mini51.s.
 */
void TMR1_IRQHandler(void)
{
#if 1
    TIMER_ClearIntFlag(TIMER1);
#else
    if (TIMER_GetIntFlag(TIMER1) == 1)
    {
        /* Clear TIMER1 Timeout Interrupt Flag */
        TIMER_ClearIntFlag(TIMER1);
    }else
    if (TIMER_GetCaptureIntFlag(TIMER1) == 1)
    {
        /* Clear TIMER1 Capture Interrupt Flag */
        TIMER_ClearCaptureIntFlag(TIMER1);
    }
#endif
    g_au32TMRINTCount++;
    if( brightlight_level[g_level_change] >=g_au32TMRINTCount )
    {
      /* dark lcd */
      P54 =1;       
    } else {
        /* bright lcd */        
        P54 = 0;  
        if(g_au32TMRINTCount>=100)
        {
            g_au32TMRINTCount=0;      
        } 
    }
}
void TMR1_IRQHandler(void)
{
    // Timer clock is 1 MHz ( prescaler is set to 11 + 1), counter value records the duration for 1000 event counts.
    printf("Event frequency is %d Hz\n", (1000000 * 1000) / TIMER_GetCounter(TIMER1));
    TIMER_ClearCaptureIntFlag(TIMER1);
    complete = 1;

}
Example #4
0
/**
 * @brief       Timer2 IRQ
 *
 * @param       None
 *
 * @return      None
 *
 * @details     The Timer2 default IRQ, declared in startup_NUC029xEE.s.
 */
void TMR2_IRQHandler(void)
{
    if(TIMER_GetCaptureIntFlag(TIMER2) == 1) {
        /* Clear Timer2 capture interrupt flag */
        TIMER_ClearCaptureIntFlag(TIMER2);

        g_au32TMRINTCount[2]++;
    }
}