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/fe310/eos/ecp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'code/fe310/eos/ecp.c') diff --git a/code/fe310/eos/ecp.c b/code/fe310/eos/ecp.c index 85539f5..bf51b19 100644 --- a/code/fe310/eos/ecp.c +++ b/code/fe310/eos/ecp.c @@ -16,8 +16,9 @@ static ECPSocket *_sock = NULL; static void timer_handler(unsigned char type) { ecp_cts_t next = ecp_timer_exe(_sock); if (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, 0); } } -- cgit v1.2.3