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?

  • In your example, timer_status_t is a structure, so you are mismatching types.  The timer count would be in status.counter.

    A better way to do what you are attempting is to use the GPT with the input capture function.  It will latch the count on the rising or falling edge of the input (configurable) and that latched count would be available in the timer callback function when the input is triggered.  Calculate the difference in count between the  and you can determine the frequency of the input signal.

  • if i try to use the interrupt pin as capture A it gives me an error

Reply Children