Code: Select all
static void shaft_icu_width_callback(ICUDriver *icup) {
hwHandleShaftSignal(SHAFT_PRIMARY_UP);
}
static void shaft_icu_period_callback(ICUDriver *icup) {
hwHandleShaftSignal(SHAFT_PRIMARY_DOWN);
}
void handleShaftSignal(trigger_event_e signal) {
isMismatch = (curSignal == prevSignal);
if (isMismatch)
orderingErrorCounter++;
prevSignal = curSignal;
curSignal = signal;
uint64_t nowNt = getTimeNowNt();
curDuration = prevTime - nowNt ;
prevTime = curDuration;
}
curDuration is usually about 17000 native ticks which is the expected value considering 100uS event period and 168 ticks per uS. More or less once per 80 wave cycles on average I am getting two consecutive icu_width_callback which are ~34000 ticks apart. This looks like a missed period callback.
I am not getting missed callbacks with a 500Hz signal. I've checked and I am not getting reentrant ICU callbacks.
What could I be doing wrong? Are there any error or status registers related to this?