I am doing a double sided two way ranging implementation. When I try to get the RX timestamps, all the function that are responsible for it, returns 0, even though I can read the received data.
I have used the following functions:
dwt_readrxtimestamphi32();
dwt_readrxtimestamplo32();
dwt_readrxtimestamp();
I can however read the system time and TX timestamps. In addition to that I have discovered that, it is possible to read the raw RX timestamp.
Does anyone have any idea what could be the problem here?
When are you reading them? If you re-arm the receiver or do certain other operations that reset the receiver state then the rx time is reset. You could also get a bad Rx time if the leading edge detect fails or there is an issue with the other adjustments that it makes to go from the raw to the corrected rx time but that will normally be obvious from the status register.
I read the timestamps right after receiving a frame. I can read the content of the frame just fine. Raw timestamp works as well. It’s just the RX_STAMP field with 5 bytes are 0.
I have also discovered that LDEDONE bit is not set as well.
That would explain it. The Rx time is the raw Rx time after it has been adjusted for various factors some of which depend on the leading edge detection results. If LDEDONE isn’t set then the leading edge detect hasn’t completed and so those corrections can’t be applied.
One of the stages of the startup process is to load the LDE algorithm. Are you doing this?
The API should provide a clean way to do it but you can also force it manually. From the user manual:
Write 2 bytes 0x0301 to Sub-Register 0x36:00 (PMSC_CTRL0)
Write 2 bytes 0x8000 to Sub-Register 0x2D:06 (OTP_CTRL)
Wait 150 µs
Write 2 bytes 0x0200 to Sub-Register 0x36:00 (PMSC_CTRL0)
I just did implemented this, however once it is done, all the status flags get set automatically. I also get a RX timestamp even though I have not received a frame. What could be the problem behind this?
You should do that only once on start-up before configuring the channel or starting a receive. If that causes flags to get set then clear them before starting the receive.