summaryrefslogtreecommitdiff
path: root/code/ecp/fe310
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2019-10-15 20:20:38 +0200
committerUros Majstorovic <majstor@majstor.org>2019-10-15 20:20:38 +0200
commit86957adfc5e2177010db896581763b4cba07273e (patch)
treec7513c2e5953cb664e9cb5e4d30180dc94b1d758 /code/ecp/fe310
parent98b5515f2ada43ca84ab4e8cfbec2c4844eaad6e (diff)
timer bugfix
Diffstat (limited to 'code/ecp/fe310')
-rw-r--r--code/ecp/fe310/time.c5
1 files changed, 3 insertions, 2 deletions
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);
}