DW1000: Delay mask in ranging code example

Hello!

I have a question related to the DW1000 example ex_05a_ds_twr_init. In the message response, the code looks like this:

                /* Retrieve poll transmission and response reception timestamp. */
            poll_tx_ts = get_tx_timestamp_u64();
            resp_rx_ts = get_rx_timestamp_u64();

            /* Compute final message transmission time. See NOTE 10 below. */
            final_tx_time = (resp_rx_ts + (RESP_RX_TO_FINAL_TX_DLY_UUS * UUS_TO_DWT_TIME)) >> 8;
            dwt_setdelayedtrxtime(final_tx_time);

            /* Final TX timestamp is the transmission time we programmed plus the TX antenna delay. */
            final_tx_ts = (((uint64)(final_tx_time & 0xFFFFFFFEUL)) << 8) + TX_ANT_DLY;

My question is: What is the purpose of masking with 0xFFFFFFFEUL. Why is it necessary to make the last bit 0?
Thank you in advance!

Best regards,
Vlad

Hi,

I think I asked a similar question in the past. This is the answer I got plus some stuffs from the user manual.

“final_tx_time” contains the high 32 bits in the 40-bit register to be set by dwt_setdelayedtrxtime(). But the nine low bits of that 40-bit register are ignored. So when you set the delay, the actual value you set in that register is gonna be (final_tx_time & 0xFFFFFFFEUL)) << 8. And surely you want to use the same value for computing the ToF.

Thank you very much! Now it is all clear!