jlaitine commented on code in PR #15929: URL: https://github.com/apache/nuttx/pull/15929#discussion_r1979137563
########## arch/risc-v/src/common/riscv_mtimer.c: ########## @@ -349,11 +345,11 @@ riscv_mtimer_initialize(uintreg_t mtime, uintreg_t mtimecmp, priv = kmm_zalloc(sizeof(*priv)); if (priv != NULL) { - priv->lower.ops = &g_riscv_mtimer_ops; - priv->mtime = mtime; - priv->mtimecmp = mtimecmp; - priv->freq = freq; - priv->alarm = UINT64_MAX; + priv->lower.ops = &g_riscv_mtimer_ops; + priv->mtime = mtime; + priv->mtimecmp = mtimecmp; + priv->cycle_per_tick = freq / TICK_PER_SEC; Review Comment: I must add that I don't understand the motivation behind https://github.com/apache/nuttx/commit/eac99370e581 37bc444fe68a86ed5088c935a74d Each OS tick *must* be equally long; so if the mtime frequency is not evenly divisible with the requested cycle time, then you don't just get exactly the cycle time you requested. There must not be variation in the cycle time. Then totally different thing is, that if you want to do e.g. sleep for a longer period, and the single tick time is a tad shorter than requested due to the timer inaccuracy / rounding error, you need to calculate the amount of ticks properly taken account the realized tick time (xSEC2TICK macros). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org