From e91ae5e65be021ab5015f3faf7cdafcf44c27b94 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Wed, 6 Jul 2022 20:57:47 +0200 Subject: [PATCH] xvc_client: fix frequency convertion --- src/xvc_client.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/xvc_client.cpp b/src/xvc_client.cpp index ad511cb..077024b 100644 --- a/src/xvc_client.cpp +++ b/src/xvc_client.cpp @@ -195,8 +195,8 @@ int XVC_client::flush() int XVC_client::setClkFreq(uint32_t clkHz) { - float clk_periodf = (1 / clkHz) * 1e9; - uint32_t clk_period = (uint32_t)round(clk_periodf); + double clk_periodf = (1e9 / clkHz); + uint32_t clk_period = (uint32_t)floor(clk_periodf); _xfer_buf[0] = static_cast((clk_period >> 0) & 0xff); _xfer_buf[1] = static_cast((clk_period >> 8) & 0xff); @@ -208,7 +208,8 @@ int XVC_client::setClkFreq(uint32_t clkHz) return -EXIT_FAILURE; } - printf("freq %d\n", atoi((const char *)_xfer_buf)); + printf("freq %d %lf %d %d\n", clkHz, clk_periodf, clk_period, + atoi((const char *)_xfer_buf)); printf("%x %x %x %x\n", _xfer_buf[0], _xfer_buf[1], _xfer_buf[2], _xfer_buf[3]);