RA2E1 which timer to use?

I'm making a system that gets the signal of a hall sensor attached to a fan, the faster it spins the faster is the signal, i want to use the interrupts on the RA to count the rising edge and calculate the RPM with the amount of rising edges in a specific time, what timer should i use? i'm trying to use the R_GPT but when i StatusGet it giver me a tipe of data i cant use with an if statement, how can i do it and what is the best timer for this?

Parents Reply
  • Yes, and in the callback, look for the TIMER_EVENT_CAPTURE_A or TIMER_EVENT_CAPTURE_B event.  This if a fragment from code that is using input capture to do exactly what you are trying to do.  The pulse accumulator is for lower frequency signals that just count how many events have occurred:

    void ScCallback (timer_callback_args_t *pArgs)
        word wCapturedCount;
        if ((pArgs->event == TIMER_EVENT_CAPTURE_A) || (pArgs->event == TIMER_EVENT_CAPTURE_B))
            wCapturedCount = pArgs->capture;

No Data