DWM1000 "dwt_readcarrierintegrator()" method issue

Hi everyone, I am facing a weird issue with DW1000. Please help me out if you faced same problem and know the solution of that.
Basically, Whenever I uncomment the line ( clockOffsetRatio = dwt_readcarrierintegrator() * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_2 / 1.0e6) ) and compile my program, the STM32 is unable to initialize the DW1000 module. I discovered this by observing that the device ID of the DW1000 cannot be obtained. However, if I comment out that line, compile the program, and upload it to the STM32, the device ID is successfully retrieved, and the DW1000 module can be configured. I’m perplexed by this unexpected behavior of the compiled code, as it occurs without any errors or warnings.

int dw_main(void)
/* Display application name on LCD. */

/* Reset and initialise DW1000.
 * For initialisation, DW1000 clocks must be temporarily set to crystal speed. After initialisation SPI rate can be increased for optimum
 * performance. */
reset_DW1000(); /* Target specific drive of RSTn line into DW1000 low for a period. */
if (dwt_initialise(DWT_LOADUCODE) == DWT_ERROR)
    lcd_display_str("INIT FAILED");
    while (1)
    { };

/* Configure DW1000. See NOTE 6 below. */

/* Apply default antenna delay value. See NOTE 2 below. */

/* Set expected response's delay and timeout. See NOTE 1 and 5 below.
 * As this example only handles one incoming frame with always the same delay and timeout, those values can be set here once for all. */

/* Loop forever initiating ranging exchanges. */
while (1)
    /* Write frame data to DW1000 and prepare transmission. See NOTE 7 below. */
    tx_poll_msg[ALL_MSG_SN_IDX] = frame_seq_nb;
    dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_TXFRS);
    dwt_writetxdata(sizeof(tx_poll_msg), tx_poll_msg, 0); /* Zero offset in TX buffer. */
    dwt_writetxfctrl(sizeof(tx_poll_msg), 0, 1); /* Zero offset in TX buffer, ranging. */

    /* Start transmission, indicating that a response is expected so that reception is enabled automatically after the frame is sent and the delay
     * set by dwt_setrxaftertxdelay() has elapsed. */

    /* We assume that the transmission is achieved correctly, poll for reception of a frame or error/timeout. See NOTE 8 below. */
    while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_TO | SYS_STATUS_ALL_RX_ERR)))
    { };

    /* Increment frame sequence number after transmission of the poll message (modulo 256). */

    if (status_reg & SYS_STATUS_RXFCG)
        uint32 frame_len;

        /* Clear good RX frame event in the DW1000 status register. */
        dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_RXFCG);

        /* A frame has been received, read it into the local buffer. */
        frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFLEN_MASK;
        if (frame_len <= RX_BUF_LEN)
            dwt_readrxdata(rx_buffer, frame_len, 0);

        /* Check that the frame is the expected response from the companion "SS TWR responder" example.
         * As the sequence number field of the frame is not relevant, it is cleared to simplify the validation of the frame. */
        rx_buffer[ALL_MSG_SN_IDX] = 0;
        if (memcmp(rx_buffer, rx_resp_msg, ALL_MSG_COMMON_LEN) == 0)
            uint32 poll_tx_ts, resp_rx_ts, poll_rx_ts, resp_tx_ts;
            int32 rtd_init, rtd_resp;
            float clockOffsetRatio ;

            /* Retrieve poll transmission and response reception timestamps. See NOTE 9 below. */
            poll_tx_ts = dwt_readtxtimestamplo32();
            resp_rx_ts = dwt_readrxtimestamplo32();

            /* Read carrier integrator value and calculate clock offset ratio. See NOTE 11 below. */
            clockOffsetRatio = dwt_readcarrierintegrator() * (FREQ_OFFSET_MULTIPLIER * HERTZ_TO_PPM_MULTIPLIER_CHAN_2 / 1.0e6) ;

            /* Get timestamps embedded in response message. */
            resp_msg_get_ts(&rx_buffer[RESP_MSG_POLL_RX_TS_IDX], &poll_rx_ts);
            resp_msg_get_ts(&rx_buffer[RESP_MSG_RESP_TX_TS_IDX], &resp_tx_ts);

            /* Compute time of flight and distance, using clock offset ratio to correct for differing local and remote clock rates */
            rtd_init = resp_rx_ts - poll_tx_ts;
            rtd_resp = resp_tx_ts - poll_rx_ts;

            tof = ((rtd_init - rtd_resp * (1 - clockOffsetRatio)) / 2.0) * DWT_TIME_UNITS;
            distance = tof * SPEED_OF_LIGHT;

            /* Display computed distance on LCD. */
            sprintf(dist_str, "DIST: %3.2f m", distance);
        /* Clear RX error/timeout events in the DW1000 status register. */

        /* Reset RX to properly reinitialise LDE operation. */

    /* Execute a delay between ranging exchanges. */



I also attempted using hard-coded values instead of dwt_readcarrierintegrator(), but encountered an issue with the line tof = ((rtd_init - rtd_resp * (1.0f - clockOffsetRatio)) / 2.0f) * DWT_TIME_UNITS. Surprisingly, when I uploaded the code, the DW1000 failed to read the device ID correctly. However, when I commented out this line tof = ((rtd_init - rtd_resp * (1.0f - clockOffsetRatio)) / 2.0f) * DWT_TIME_UNITS, everything worked fine again. I’m perplexed by why these two lines are causing this behavior, and I’m hoping someone can shed some light on this issue.

Device ID that got: BC950360 (wrong ID)

Hello, I have also encountered the same problem. May I ask if this problem has been resolved and how has it been resolved?

I used float typecasting to resolve that issue.