I’m trying to estimate the received power from an antenna using the formula in section 4.7.2 (dw1000_user_manual_v2.05).
According to the equation, one needs to determine a couple of values set to specific registers:
C = the Channel Impulse Response Power value reported in the CIR_PWR field of Register file: 0x12 – Rx Frame Quality Information [pag 95]
N = the Preamble Accumulation Count value reported in the RXPACC field of Register file: 0x10 – RX Frame Information Register [pag 92]
A= is the value 115.72 for a PRF of 16 MHz, and, the value 121.74 for a PRF of 64 MHz.
I’m not particularly sure on how to properly read those values.
For examples, I used this code for determining the N value:
Assuming you are using the API
Why don’t u use the dwt_readdiagnostics() function from the API it fills a struct with the values you are looking for, something like this
uint16 C = diag.maxGrowthCIR;
uint16 N = diag.rxPreamCount;
Or read directly from register
uint32 N = ((dwt_read32bitreg(RX_FINFO_ID)& RX_FINFO_RXPACC_MASK)>> RX_FINFO_RXPACC_SHIFT);
which you can typecast to 16 bit since the upper 16 bits should be all zero’s since RX_FINFO_RXPACC_SHIFT=20
For C you could do
CIR_MXG_SHIFT/8 = 6 so you read the bits 63-48 from the RX_FQUAL_ID register.
Bitmasking and shifting is not necesarry here since you need the full 16 bits
I have the same problem as you. I use the function dwt_readdiagnostics() to read F1, F2, F3, but all of the values are 0.
The code is as follows:
I don’t know what went wrong with me. Did I read it at the wrong time? F1, F2, F3 register value will automatically clear 0? Are there any other considerations?