Systime not approximatly the same as delaytime

Hi,

I am measuring the systime every 100 ms. Although the difference between the times i receive are not constant. This is my code:

while(1){
uint8 systime[5];
dwt_readsystime(systime);
HAL_UART_Transmit(&huart1,systime,5,100);
HAL_Delay(100);
}

I get the data on the uart in hex. I convert them by taking the 12 chars and convert them to decimal.
these are some of the times:

273534135419456
274333536200736
276722074969408
275849659597736
273751568281056
274786655264776
273798275992448

I do not know why these are not consistantly around the 100 ms apart.
help would be appreciated.

kind regards,

Hi J_K,

There is something wrong with your conversion.
First - the numbers are not in order.
Second - I’ve converted your dec numbers back to hex and got
F8C720F9C240
F98140F9A820
FBAD60FAE540
FAE240F8C3A8
F8F9C0FBEDE0
F9EAC0F9E008
F904A0FB0B80

6 bytes actually, not 5.

Can you provide the raw hex data?

Hi,

You are right, my bad…
Please correct me if i am wrong. When i request the systemtime of the dwm1000 module at a constant rate of once every 0.2008653333 s(measured with logic analyzer). These are a part of the responses:

So this are these values:

Returned time of DWM1000 Difference between times
253187223245000
3178049160000 -250009174085000
9214187252001 6036138092001
15211047181000 5996859928999
10240213250001 -4970833930999
13456048216001 3215834966000
33203231140001 19747182924000
29200183045001 -4003048095000
45138243250001 15938060205000
51195137060000 6056893809999
57128031242001 5932894182001
63122212107000 5994180864999
69187045182001 6064833075001
75184173212001 5997128030000
81181049010000 5996875797999
87178207102000 5997158092000
46096117240000 -41082089862000
49090131129000 2994013889000

Can someone explain these times? Why are these times not constant as they are requested a precise interval?

is it correct that these to assume that these are ticks of the 64 ghz clock. So that every tick is
1/(63.8976 * 1000000000) seconds long?

There are no messages coming in on the dwm1000, i use the function dwt_readsystime();
I use stm32f103RBT6 with a ported dw1000 library. And i use keil as an editor.

Kind regards,

From you dump I can see the first 4 timestamps, so if I calculate 3 time differences.
I have:
25607383808
26382851073
25710278911
In seconds:
0.400115372
0.412232048
0.401723108

So my conclusion is: you have two issues - with SPI reading and with converting raw timestamp data to decimal.
First - you read data seems to be correct except scaled twice (0.4s instead of 0.2s as expected) - read data is shifted one bit. I suggest check SPI clock/data polarity.
Second - you cannot simply concatenate decimal bytes to get a timestamp. It’s actually 5 binary octets, like uint8_t timestamp[5].
To get timestamp use this code (5 bytes don’t fit into standard uint32_t obviously):

uint64_t real_timestamp = (uint64_t)timestamp[0] + (uint64_t)timestamp[1]<<8 +
                          (uint64_t)timestamp[2]<<16 + (uint64_t)timestamp[3]<<24 + 
                          (uint64_t)timestamp[4]<<32;```