Thanks for the response.. Yes I'm using the second method, where the TACH signal is connected to the capture pin (not sure if it has to be a particular channel).. But as you can see, the initialization code above is how I've set it up..
void fan_tach_isr(uint32_t flags)
{
static int8_t count = 1;
uint8_t tc_read_count = 4; //4 poles for the fan = 1 rotation
uint32_t tc = CTIMER_GetTimerCountValue(g_ctx.fanCtrlHandle.tach_ctimer_handle);
if(++count > tc_read_count)
{
//uint32_t tc = CTIMER_GetTimerCountValue(g_ctx.fanCtrlHandle.tach_ctimer_handle);
g_ctx.fanCtrlHandle.rpm = (60000/tc);
CTIMER_Reset(g_ctx.fanCtrlHandle.tach_ctimer_handle);
LOG_DEBUG("ISR count = %d, TC = %ld RPM = %ld", count, tc, g_ctx.fanCtrlHandle.rpm);
count = 1;
}
}
where tach_timer_handle is
CTIMER0_FAN_TACH_PERIPHERAL
The interrupts are firing only when I connect and disconnect, and they're weird.. as in the TC field in the handle keeps increasing even when the fan is disconnected - (this may be expected? )
and the interrupts don't fire when the fan is running after a few rounds.. not sure what's going on here! any ideas ?
Btw, I'm using Ctimer2 to control the PWM pin on the same fan.. The config for that looks like this:
amithrao_0-1674590073303.png
and the corresponding Tach pin to ctimer0, and the config looks like this:
amithrao_1-1674590208228.png
Does it look okay ? or am I missing something ?