diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index a12bf607555..45cd2212bc8 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -332,18 +332,21 @@ uint64_t z_nrf_grtc_timer_get_ticks(k_timeout_t t) int64_t curr_tick; int64_t result; int64_t abs_ticks; + int64_t grtc_ticks; curr_time = counter(); curr_tick = sys_clock_tick_get(); + grtc_ticks = t.ticks * CYC_PER_TICK; abs_ticks = Z_TICK_ABS(t.ticks); if (abs_ticks < 0) { /* relative timeout */ - return (t.ticks > (int64_t)COUNTER_SPAN) ? -EINVAL : (curr_time + t.ticks); + return (grtc_ticks > (int64_t)COUNTER_SPAN) ? + -EINVAL : (curr_time + grtc_ticks); } /* absolute timeout */ - result = abs_ticks - curr_tick; + result = (abs_ticks - curr_tick) * CYC_PER_TICK; if (result > (int64_t)COUNTER_SPAN) { return -EINVAL; diff --git a/include/zephyr/drivers/timer/nrf_grtc_timer.h b/include/zephyr/drivers/timer/nrf_grtc_timer.h index 036d5851725..4cd3f8d14cb 100644 --- a/include/zephyr/drivers/timer/nrf_grtc_timer.h +++ b/include/zephyr/drivers/timer/nrf_grtc_timer.h @@ -113,7 +113,7 @@ int z_nrf_grtc_timer_compare_read(int32_t chan, uint64_t *val); * * @param chan Channel ID. * - * @param target_time Absolute target time in ticks. + * @param target_time Absolute target time in GRTC ticks. * * @param handler User function called in the context of the GRTC interrupt. *