From 86957adfc5e2177010db896581763b4cba07273e Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 15 Oct 2019 20:20:38 +0200 Subject: timer bugfix --- code/ecp/fe310/time.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'code/ecp') diff --git a/code/ecp/fe310/time.c b/code/ecp/fe310/time.c index 69cf14d..455c762 100644 --- a/code/ecp/fe310/time.c +++ b/code/ecp/fe310/time.c @@ -21,6 +21,7 @@ void ecp_tm_sleep_ms(ecp_cts_t msec) { } void ecp_tm_timer_set(ecp_cts_t next) { - uint32_t tick = next * (uint64_t)RTC_FREQ / 1000; - eos_timer_set(tick, EOS_TIMER_ETYPE_ECP); + volatile uint64_t *mtime = (uint64_t *) (CLINT_CTRL_ADDR + CLINT_MTIME); + uint64_t tick = *mtime + next * (uint64_t)RTC_FREQ / 1000; + eos_timer_set(tick, EOS_TIMER_ETYPE_ECP, 1); } -- cgit v1.2.3