I’m currently testing out a HiFive1, and I’ve run into an interesting problem: the timing is off.
I began by investigating low scores in Whetstone (link removed as new users are limited to two links, apparently, but if you search for “Arduino Whetstone” on Google I’m the first hit) and Dhrystone benchmarks I’ve previously run on other microcontrollers via the Arduino IDE. They run, but on the HiFive1 I’m getting results way, way lower than I’d expect: 21.85 DMIPS and just 1.42 MWIPS.
So, I started poking at the timers - and here’s where things got interesting. I wrote a simple timing test which does nothing but record the current micros(); in an unsigned long variable, print that variable to the serial port, then wait for what should be one second.
The first thing I did was run it on an Arduino MKR1000 as a baseline. The result: every output was between 999999 microseconds and 1000001 microseconds, averaging out at 1000000 microseconds. In other words, a perfectly working timer.
Then I came to run it on the HiFive1, and the results were very, very different. The stable results ranged from 1000054 microseconds to 1002099 microseconds, with four major blips over the test run: 12529, 261104, and two instances of 743641 microseconds.
Now, I’m not sure if this is enough for my benchmarks to be thrown quite as far out of whack as they are - and I’m open to suggestions on that front, as while I know I can run the benchmarks included in the SDK I really wanted to run these two so I have a direct comparison to other microcontrollers I’ve run them on - but it certainly can’t be helping.
Is there an issue with the HiFive1’s timers? Is there a way to make a second be a second?