Problem retrieving diagnostic data

Hi all guys!
I’m a master’s degree student and i’m using TREK1000 kit for my thesis (with original version 2.10).
Now, i’m trying to face the problem of NLOS condition. Doing some researches, I found out that I could need two functions of the DW1000 API: dwt_readdignostics() and dwt_readaccdata.
So, I build up two functions that retrieve the data I need and put them out in the USB (using TeraTerm i can see what happens).

  1. void readacc()

    uint8 usbCOMout_acc[LCD_BUFF_LEN*4];
    int n_acc;
    for(int i = 0;i<992;i++)
    uint8 *cir; cir = (uint8 )malloc(5sizeof(uint8));
    dwt_readaccdata(cir, 5, 4*i);
    int16 real =0;
    int16 imag =0;
    double amp = 0;

real = (int16)(cir[2] << 8) | (int16)(cir[1]);
imag = (int16)(cir[4] << 8) | (int16)(cir[3]);

amp = fmax(abs(real),abs(imag)) + 1/4*fmin(abs(real),abs(imag));

n_acc = sprintf((char*)&usbCOMout_acc[0], “REAL: %d, IMAG: %d, AMP: %f\n”,real,imag,amp);
send_usbmessage(&usbCOMout_acc[0], n_acc);

  1. void readdiag()

    uint8 usbCOMout_diag[LCD_BUFF_LEN*4];
    int n_diag;
    dw_rxdiag_t info_utili;
    n_diag = sprintf((char*)&usbCOMout_diag[0], “FP1_AMP: %d, FP2_AMP: %d, FP3_AMP: %d, FP_IND: %f\n”,info_utili.firstPathAmp1,info_utili.firstPathAmp2,info_utili.firstPathAmp3,info_utili.firstPath);
    send_usbmessage(&usbCOMout_diag[0], n_diag-2);

Now, my problem is where I should insert this functions.
At the beginning, I tried to insert them in main.c after the function instance_run() that implement the TWR application.
An example of what I see (using only readdiag() and 1 anchor with 1 tag):

mc 01 0000009f 00000000 00000000 00000000 47f1 c0 001d2698 a2:0
mr 01 ffffffba 00000000 00000000 00000000 47f1 c0 404b404b a2:0
FP1_AMP: [color=#ff3333]2242[/color], FP2_AMP: [color=#ff3333]2218[/color], FP3_AMP: [color=#ff3333]1827[/color], FP_IND: [color=#ff3333]0.00000[/color]

Clearly, data are wrong cause I know that these values should be about 17k-20k and the first path index should not be 0.

So, I tried to move the functions around the code, first in instance.c after the reception of the frame ( case DWT_SIG_RX_OKAY) and then also in instance_common.c, always in the case DWT_SIG_RX_OKAY.
The results are always the same, with these amplitudes of about 2k.

[color=#333333]What might be the cause?[/color]

[color=#333333][color=#333333]Thank you in advance[/color]

I have another question.
How can I retrieve the peak path in a CIR without reading all the accomulator (too much time consuming)?

Thank you in advance for the replies.

Hi Alessio,

if you need to read ACC data or diagnostc data, you should read these after packet/frame reception. When the receiver is stopped, and DW is in IDLE. Decawave also provide a simple example in the API package which reads out the diagnostic data.


Hi Zoran!

Yeah, I saw the example but in the example they use the polling strategy.
In the real firmware, there is the interrupt strategy.
I tried to read the data everywhere in the code, but probably I can’t read them in the right position.
Everytime I change location I retrieve different data but anyway they are always wrong.
This time I put the dwt_readdignostics() function before the TA_RXE_WAIT (where the rx is reenable), but I retrieve this:

mc 01 000000c5 00000000 00000000 00000000 5163 5f 002105ff a2:0
mr 01 ffffffe0 00000000 00000000 00000000 5163 5f 404b404b a2:0
FP1_AMP: 0, FP2_AMP: 0, FP3_AMP: 0, FP_IND: 0.000000, N: 95, C: 164

The preamble and the maxgrowcir are wrong as the other values.
It’s quite one week that I’m trying the right position in the code but nothing.


The diagnostic and CIR data will only be valid after RX has finished, you should not read it at other times, e.g. when RX is running as the receiver is updating the diagnostic registers and accessing the CIR memory, as you will have read conflicts.

I discovered a very strange thing.
I put the control lines

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

                { };

after the: dwt_rxenable(DWT_START_RX_IMMEDIATE) ; // turn RX on, without delay

And the code stucks in that while cycle!
It’s as my firmware doesn’t update the registers correctly, but it is the default code by Decawave!
I can’t think that the original code was incorrect…

I am using System Workbench for STM32 to build the example DW1000 codes “ex_02c_rx_diagnostics” and “ex_01a_simple_tx”. I’ve managed to build them and flash two EVK1000 boards using ST-Link V2, one with the .bin file generated from “ex_01a_simple_tx” and the other with “ex_02c_rx_diagnostics”.
However, for the “ex_02c_rx_diagnostics” example, I’ve included the following codes in the main file to get the CIR data :

        for(int i = 0;i<ACCUM_DATA_LEN;i++) //992 or 1016
                     uint8 *cir;
                     cir = (uint8*)malloc(5*sizeof(uint8));
                     dwt_readaccdata(cir,5, 4*i);
                     int16 real =0;
                     int16 imag =0;
                     double amp = 0;

                     real = (int16)(cir[2] << 8) | (int16)(cir[1]);
                     imag = (int16)(cir[4] << 8) | (int16)(cir[3]);

                     amp = fmax(abs(real),abs(imag)) + 1/4*fmin(abs(real),abs(imag));

                     printf("%d \r\n",imag);
                     printf("%f\n", amp);


However, nothing is displayed in a terminal when I connect to the board which has been flashed with the “ex_02c_rx_diagnostics” example. I use Teraterm to connect to the board via its USB interface.
The terminal remains blank. Is there any file that needs to be modified for data to be transmitted via the USB? or any other settings that need to be changed? I would be grateful if somebody can help me with this.

Thanks and best regards