4 Replies Latest reply on Jan 15, 2020 10:22 PM by YashwantK_46

    FX3 firmware library/documentation bug - tick interval is not 1ms

    OlJo_4577026

      The FX3 documentation (SDK version 1.3.4) for CyU3POsTimerInit claims that the default timer tick interval is 1ms.

       

      This does not match the implementation. The actual tick interval is around 0.976ms (250/256 ms). This means that all delays, timeouts, and so on are slightly too fast. It adds up to human-visible differences fairly quickly, I could easily verify the difference by hand with a stopwatch. You can also see this effect by comparing the values returned by CyU3PGetTime() to the values returned by CyU3PGpioComplexSampleNow() on a complex GPIO configured for a known frequency.

       

      The underlying cause of this is that the timer interrupt handling in system/cyu3vic.c appears to assume that the watchdog clock runs at exactly 32.000kHz. But the hardware actually runs this clock at 32.768kHz per the TRM.

       

      Workaround: scale all delays and timeouts passed to the firmware by 256/250. Scale the return value of CyU3PGetTime() by 250/256.

       

      Any plans to fix this in the firmware library? It's possible to get the average tick interval much closer to 1ms (I prototyped a fix and with a little fixed-point math got the average error down to < 1ppm fairly easily). Failing that, the documentation needs to be updated to reflect that ticks are not 1ms.