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))){ };
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.