Comparison of RX signal strength measurement results

Dear Decawave Developer team
i use stm32, dwm1000 for distance measurement

i want measurement RX signal strength so i read the manual and wrote the code
(the above picture is the written code)

my measurement value(RX Signal) is between -95 ~ -120
(The distance of each device is 10cm ~ 20m on NLOS environment)
but other people measurement value is between -60 ~ -120

i want to ask if this situation is normal
if this situation is unnormal how to set it up

thank for listen my question

I think you have a c variable type bug.
(C * 131072) / (N*N) = (int *int) / (int * int)
which means the result will be rounded down to an int before doing the log10 function call.

Try changing your code to
float rssi = 10 * log10((C * 131072.0f)/(N*N)) - A
and see if that helps.

Why don’t you use dwt_readdiagnostics rather ?
I’m not sure, but it feels like you’re corrupting the memory reading 8 byte in a declared single one, or did I got it wrong ?

1 Like

No, you read that correctly. readfromdevice takes length in bytes and he his supplying length in bits. So while C will contain the correct value the next 7 bytes of memory will be randomly corrupted. A definite bug that would normally result in junk results or a crash.

However making some big assumptions about what the compiler is doing those 7 bytes will probably be 3 bytes of unused space, 2 bytes for N and then 2 more bytes of unused padding. Since N is the next variable set none of the corrupted memory is critical at the point the corruption happens.
So a definite bug, if the order of the lines reading C and N were swapped, the order of variable definitions changed or the compiler did some clever optimisation then you could get random results. But there is a fair chance that with this specific code, especially if optimisation is turned off for a debug build, the bug isn’t not actually impacting the results.

1 Like

The given index (2nd parameter) is also wrong 16 bytes while RX_FQUAL is only 8 bytes.

1 Like

I’ll take your word for it on that one. I #defined all the register names years ago so I didn’t have to remember the addresses. If nothing else it makes spotting errors like that a lot simpler.

1 Like