HiFive1 Timer Interrupt Demo

Hi,

I think I am having a brain lag. Perhaps you can help to solve it.

In the demo_gpio.c from https://github.com/sifive/freedom-e-sdk/releases/tag/v1.0.3 is a timer interrupt implemented. Why is the interrupt time 3 seconds, when its 1.5*clock_frequency? Should it not be 1.5 seconds?

#define RTC_FREQUENCY 32768
// Set the machine timer to go off in 3 seconds.
// The
volatile uint64_t * mtime = (uint64_t*) (CLINT_BASE_ADDR + CLINT_MTIME);
volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_BASE_ADDR + CLINT_MTIMECMP);
uint64_t now = mtime;
uint64_t then = now + 1.5
RTC_FREQUENCY;
*mtimecmp = then;

My first thought was it could be the rtc_scale, but it is set to 0.

Thank you for your time and help

Not sure why 1.5 is used and my guess it’s depend on the target that you run the code on.

Reading another example, it didn’t divide by 2.