DWM1000 Problem reading status register in loop

I am having trouble with SPI reading the Status Register in a loop.

The SPI works fine for all the configuration routines and for all the 32, 16 and 8 bit Write/read routines.
However, once I start repeatedly reading the Status Register to wait for received data, the SPS starts returning rubbish. ie. At various places in my code (all the way up to the line below) I call a small test routine to obtain the Deca_ID and it is fine. Directly after the code below, I no longer read valid Deca_ID.

The SPI is running at 16MHz. Is there a minimum time you need between reads of Status reg or can you repeatedly read it immediately?

while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR))){ };

1 Like

Not really an answer to your question, more a possible work around:
Any reason you can’t use the interrupt pin to tell you when there is data ready?
You don’t necessarily have to use it as an interrupt, you can still poll if you prefer but rather than polling the status register set the mask register then you can poll the IO pin that the interrupt is connected to. This would avoid constantly re-reading registers while you wait.

hi andy,
thanks for your suggestion. i could clear the int at this point in code then wait for flag to be set then read the status reg to verify valid rx.

still keen to hear from dw regarding any limitation to reading the status reg in loop at high speed.

Hi,

I have a similar problem working with DWM1001 (dev board as well as a custom board).
I also try to read via SPI a dw register in a loop:

while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS)) {};

Most of the time (~99.99%) this works, but sometimes the application is stuck in this loop until watchdog resets the chip.

Anyone has an idea what the reason for this behavior is?

Thanks!

Edit: I only call this while loop if the transmission of the frame was successful, i.e. dwt_starttx() == DWT_SUCCESS