This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to access the TIMER3 in wireless timer sync?

Hello,

I found this great blog entry about synchronizing timers on different devices: https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/wireless-timer-synchronization-among-nrf5-devices

It works just fine on a nRF52840DK and a nRF52DK. Timers on multiple nRF5 devices are synced by one device (master) sending sync packets containing captured timer values to other devices (nodes). (TIMER3 is free running, TIMER2 counts TIMER3 overflows).

At the moment I am struggeling to access this synchronized TIMER3 on the two boards. I am familiar with setting up a TIMER without wireless timer sync. 

So here are my questions:

1. How can I define CC, Prescaler, Mode, Bitmode, the interrupt handler and so forth when using wireless timer sync?

2. Can anybody provide me some advice how to access this synchronized TIMER3 properly? 

Thank you very much in advance.

  • Hello Audun,

    thank you very much for your detailed reply. I really appreciate your help.

    which means there either isn't any more sync packets from the transmitter received, or that there is an issue with appying a received packet.

    This is caused by the procedure how I catched the offset in my previous reply. I generated an error at the central when the offset occurs to catch the relevant debug data. So the central stopped transmitting sync beacons when the offset occured.

    I swapped my previous timers_capture() function with your timers_capture() function. Unfortunately, this does not solve the offset issue.

    You can see the debug logs for the peripheral and the central in the following. These logs are generated with your recommended timers_capture() function. I also delayed the generation of the error on my central when the offset occurs. So the central does not stop immediatly transmitting sync beacons. Instead the central continues sending sync beacons for ~560ms after the offset occured before the central stops itself.

    --------------------------------------------------------------

    Peripheral

    This is the debug log on the peripheral side.

    [00:05:18.499,877] <info> time_sync: 39602, 5, 539575    timestamp: 1348952
    [00:05:18.539,855] <info> time_sync: 39608, 8, 539588    timestamp: 1348992
    [00:05:18.579,895] <info> time_sync: 39607, 24, 539588    timestamp: 1349032
    [00:05:18.619,873] <info> time_sync: 39620, 1, 539627    timestamp: 1349072
    [00:05:18.659,851] <info> time_sync: 39625, 4, 539640    timestamp: 1349112
    [00:05:18.699,890] <info> time_sync: 39630, 7, 539653    timestamp: 1349152
    [00:05:18.739,868] <info> time_sync: 39634, 10, 539666    timestamp: 1349192
    [00:05:18.779,907] <info> time_sync: 39634, 26, 539666    timestamp: 1349232
    [00:05:18.819,885] <info> time_sync: 39648, 3, 539705    timestamp: 1349272
    [00:05:18.859,863] <info> time_sync: 39653, 6, 539718    timestamp: 1349312
    [00:05:18.899,902] <info> time_sync: 39657, 9, 539731    timestamp: 1349352
    [00:05:18.939,880] <info> time_sync: 39657, 25, 539731    timestamp: 1349392
    [00:05:18.979,919] <info> time_sync: 39672, 2, 539770    timestamp: 1349432
    [00:05:19.019,897] <info> time_sync: 39675, 5, 539783    timestamp: 1349472
    [00:05:19.059,875] <info> time_sync: 39680, 8, 539796    timestamp: 1349512
    [00:05:19.099,914] <info> time_sync: 39680, 24, 539796    timestamp: 1349552
    [00:05:19.139,892] <info> time_sync: 39694, 1, 539835    timestamp: 1349592
    [00:05:19.179,931] <info> time_sync: 39698, 4, 539848    timestamp: 1349632
    [00:05:19.219,909] <info> time_sync: 39703, 7, 539861    timestamp: 1349672
    [00:05:19.259,887] <info> time_sync: 39707, 10, 539874    timestamp: 1349712
    [00:05:19.299,926] <info> time_sync: 39707, 26, 539874    timestamp: 1349752
    [00:05:19.339,904] <info> time_sync: 39721, 3, 539913    timestamp: 1349792
    [00:05:19.379,882] <info> time_sync: 39726, 6, 539926    timestamp: 1349832
    [00:05:19.419,921] <info> time_sync: 39731, 9, 539939    timestamp: 1349872
    [00:05:19.459,899] <info> time_sync: 39730, 25, 539939    timestamp: 1349912
    [00:05:19.499,938] <info> time_sync: 39744, 2, 539978    timestamp: 1349952
    [00:05:19.539,916] <info> time_sync: 39748, 5, 539991    timestamp: 1349992
    [00:05:19.579,895] <info> time_sync: 39753, 8, 540004    timestamp: 1350032
    [00:05:19.619,934] <info> time_sync: 39753, 24, 540004    timestamp: 1350072
    [00:05:19.659,912] <info> time_sync: 39767, 1, 540043    timestamp: 1350112
    [00:05:19.699,951] <info> time_sync: 39771, 4, 540056    timestamp: 1350152
    [00:05:19.739,929] <info> time_sync: 39776, 7, 540069    timestamp: 1350192
    [00:05:19.779,907] <info> time_sync: 39781, 10, 540082    timestamp: 1350232
    [00:05:19.819,946] <info> time_sync: 39781, 26, 540082    timestamp: 1350272
    [00:05:19.859,924] <info> time_sync: 39795, 3, 540121    timestamp: 1350312
    [00:05:19.899,963] <info> time_sync: 39799, 6, 540134    timestamp: 1350352
    [00:05:19.939,941] <info> time_sync: 39803, 9, 540147    timestamp: 1350392
    [00:05:19.979,919] <info> time_sync: 39803, 25, 540147    timestamp: 1350432
    [00:05:20.019,958] <info> time_sync: 39818, 2, 540186    timestamp: 1350472
    [00:05:20.059,936] <info> time_sync: 39822, 5, 540199    timestamp: 1350512
    [00:05:20.099,975] <info> time_sync: 39826, 8, 540212    timestamp: 1350552
    [00:05:20.139,953] <info> time_sync: 39826, 24, 540212    timestamp: 1350592
    [00:05:20.179,931] <info> time_sync: 39840, 1, 540251    timestamp: 1350632
    [00:05:20.219,970] <info> time_sync: 39844, 4, 540264    timestamp: 1350672
    [00:05:20.259,948] <info> time_sync: 39849, 7, 540277    timestamp: 1350712
    [00:05:20.299,926] <info> time_sync: 39854, 10, 540290    timestamp: 1350752
    [00:05:20.339,965] <info> time_sync: 39853, 26, 540290    timestamp: 1350792
    [00:05:20.379,943] <info> time_sync: 39867, 3, 540329    timestamp: 1350832
    [00:05:20.419,982] <info> time_sync: 39872, 6, 540342    timestamp: 1350872
    [00:05:20.459,960] <info> time_sync: 39876, 9, 540355    timestamp: 1350912
    [00:05:20.499,938] <info> time_sync: 39876, 25, 540355    timestamp: 1350952
    [00:05:20.539,978] <info> time_sync: 39890, 2, 540394    timestamp: 1350992
    [00:05:20.579,956] <info> time_sync: 39895, 5, 540407    timestamp: 1351032
    [00:05:20.619,995] <info> time_sync: 39900, 8, 540420    timestamp: 1351072
    [00:05:20.659,973] <info> time_sync: 39900, 24, 540420    timestamp: 1351112
    [00:05:20.699,951] <info> time_sync: 39913, 1, 540459    timestamp: 1351152
    [00:05:20.739,990] <info> time_sync: 39918, 4, 540472    timestamp: 1351192
    [00:05:20.779,968] <info> time_sync: 39922, 7, 540485    timestamp: 1351232
    [00:05:20.820,007] <info> time_sync: 39927, 10, 540498    timestamp: 1351272
    [00:05:20.859,985] <info> time_sync: 39927, 26, 540498    timestamp: 1351312
    [00:05:20.899,963] <info> time_sync: 39940, 3, 540537    timestamp: 1351352
    [00:05:20.940,002] <info> time_sync: 39945, 6, 540550    timestamp: 1351392
    [00:05:20.979,980] <info> time_sync: 39949, 9, 540563    timestamp: 1351432
    [00:05:21.020,019] <info> time_sync: 39949, 25, 540563    timestamp: 1351472
    [00:05:21.059,997] <info> time_sync: 39964, 2, 540602    timestamp: 1351512
    [00:05:21.099,975] <info> time_sync: 39968, 5, 540615    timestamp: 1351552
    [00:05:21.140,014] <info> time_sync: 39972, 8, 540628    timestamp: 1351592
    [00:05:21.179,992] <info> time_sync: 39973, 24, 540628    timestamp: 1351632
    [00:05:21.219,970] <info> time_sync: 39986, 1, 540667    timestamp: 1351672
    [00:05:21.260,009] <info> time_sync: 39990, 4, 540680    timestamp: 1351712
    [00:05:21.299,987] <info> time_sync: 39995, 7, 540693    timestamp: 1351752
    [00:05:21.340,026] <info> time_sync: 0, 10, 540706    timestamp: 1351790
    [00:05:21.380,004] <info> time_sync: 0, 26, 540706    timestamp: 1351830
    [00:05:21.419,982] <info> time_sync: 14, 4, 540745    timestamp: 1351873
    [00:05:21.460,021] <info> time_sync: 18, 7, 540758    timestamp: 1351913
    [00:05:21.500,000] <info> time_sync: 23, 10, 540771    timestamp: 1351953
    [00:05:21.540,039] <info> time_sync: 23, 26, 540771    timestamp: 1351993
    [00:05:21.580,017] <info> time_sync: 36, 3, 540810    timestamp: 1352033
    [00:05:21.619,995] <info> time_sync: 42, 6, 540823    timestamp: 1352073
    [00:05:21.660,034] <info> time_sync: 45, 9, 540836    timestamp: 1352113
    [00:05:21.700,012] <info> time_sync: 45, 25, 540836    timestamp: 1352153
    [00:05:21.740,051] <info> time_sync: 59, 2, 540875    timestamp: 1352193
    [00:05:21.780,029] <info> time_sync: 64, 5, 540888    timestamp: 1352233
    [00:05:21.820,007] <info> time_sync: 68, 8, 540901    timestamp: 1352273
    [00:05:21.860,046] <info> time_sync: 73, 11, 540914    timestamp: 1352313
    [00:05:21.900,024] <info> time_sync: 73, 27, 540914    timestamp: 1352353
    [00:05:21.940,063] <info> time_sync: 86, 4, 540953    timestamp: 1352393
    [00:05:21.980,041] <info> time_sync: 74, 20, 540953    timestamp: 1352433
    [00:05:22.020,019] <info> time_sync: 74, 36, 540953    timestamp: 1352473
    [00:05:22.060,058] <info> time_sync: 74, 52, 540953    timestamp: 1352513
    [00:05:22.100,036] <info> time_sync: 74, 68, 540953    timestamp: 1352553
    [00:05:22.140,014] <info> time_sync: 74, 84, 540953    timestamp: 1352593
    [00:05:22.180,053] <info> time_sync: 74, 100, 540953    timestamp: 1352633
    [00:05:22.220,031] <info> time_sync: 74, 116, 540953    timestamp: 1352673
    [00:05:22.260,070] <info> time_sync: 74, 132, 540953    timestamp: 1352713
    [00:05:22.300,048] <info> time_sync: 74, 148, 540953    timestamp: 1352753
    [00:05:22.340,026] <info> time_sync: 74, 164, 540953    timestamp: 1352793
    [00:05:22.380,065] <info> time_sync: 74, 180, 540953    timestamp: 1352833
    [00:05:22.420,043] <info> time_sync: 74, 196, 540953    timestamp: 1352873
    [00:05:22.460,083] <info> time_sync: 74, 212, 540953    timestamp: 1352913
    [00:05:22.500,061] <info> time_sync: 74, 228, 540953    timestamp: 1352953
    [00:05:22.540,039] <info> time_sync: 74, 244, 540953    timestamp: 1352993
    [00:05:22.580,078] <info> time_sync: 74, 260, 540953    timestamp: 1353033
    [00:05:22.620,056] <info> time_sync: 74, 276, 540953    timestamp: 1353073
    [00:05:22.660,095] <info> time_sync: 74, 292, 540953    timestamp: 1353113
    [00:05:22.700,073] <info> time_sync: 74, 308, 540953    timestamp: 1353153
    [00:05:22.740,051] <info> time_sync: 74, 324, 540953    timestamp: 1353193
    [00:05:22.780,090] <info> time_sync: 74, 340, 540953    timestamp: 1353233
    [00:05:22.820,068] <info> time_sync: 74, 356, 540953    timestamp: 1353273
    [00:05:22.860,046] <info> time_sync: 74, 372, 540953    timestamp: 1353313
    [00:05:22.900,085] <info> time_sync: 74, 388, 540953    timestamp: 1353353
    [00:05:22.940,063] <info> time_sync: 74, 404, 540953    timestamp: 1353393
    [00:05:22.980,102] <info> time_sync: 74, 420, 540953    timestamp: 1353433
    [00:05:23.020,080] <info> time_sync: 74, 436, 540953    timestamp: 1353473
    [00:05:23.060,058] <info> time_sync: 74, 452, 540953    timestamp: 1353513
    [00:05:23.100,097] <info> time_sync: 74, 468, 540953    timestamp: 1353553
    [00:05:23.140,075] <info> time_sync: 74, 484, 540953    timestamp: 1353593
    [00:05:23.180,114] <info> time_sync: 74, 500, 540953    timestamp: 1353633
    [00:05:23.220,092] <info> time_sync: 74, 516, 540953    timestamp: 1353673

    You can see that the offset happened in line 72. We can also see that the peripheral still receives the beacon sync pakets until line 87. At this point the central stops sending sync beacons as a consequence of the selfmade error to catch the relevant debug data. So the peripheral can not receive any sync beacon pakets anymore, because there are none.

    It is also interesting that the offset occures when the sync_timer_val goes to zero.

    --------------------------------------------------------------

    Central

    This is the debug log on the central side. The debug log is the corresponding one to debug log of the peripheral, which I descriped a few lines earlier.

    This is pretty much the same as in my previous reply.

    <info> time_sync: 32680, 540718, 0    timestamp: 1351797
    <info> time_sync: 8651, 540719, 0    timestamp: 1351798
    <info> time_sync: 16656, 540722, 0    timestamp: 1351806
    <info> time_sync: 32656, 540722, 0    timestamp: 1351807
    <info> time_sync: 8656, 540723, 0    timestamp: 1351808
    <info> time_sync: 24656, 540723, 0    timestamp: 1351809
    <info> time_sync: 656, 540724, 0    timestamp: 1351810
    <info> time_sync: 16656, 540724, 0    timestamp: 1351811
    <info> time_sync: 32656, 540724, 0    timestamp: 1351812
    <info> time_sync: 8656, 540725, 0    timestamp: 1351813
    <info> time_sync: 24656, 540725, 0    timestamp: 1351814
    <info> time_sync: 656, 540726, 0    timestamp: 1351815
    <info> time_sync: 16656, 540726, 0    timestamp: 1351816
    <info> time_sync: 32656, 540726, 0    timestamp: 1351817
    <info> time_sync: 8656, 540727, 0    timestamp: 1351818
    <info> time_sync: 24656, 540727, 0    timestamp: 1351819
    <info> time_sync: 656, 540728, 0    timestamp: 1351820
    <info> time_sync: 16656, 540728, 0    timestamp: 1351821
    <info> time_sync: 32657, 540728, 0    timestamp: 1351822
    <info> time_sync: 8656, 540729, 0    timestamp: 1351823
    <info> time_sync: 24656, 540729, 0    timestamp: 1351824
    <info> time_sync: 656, 540730, 0    timestamp: 1351825
    <info> time_sync: 32657, 540730, 0    timestamp: 1351827
    <info> time_sync: 8647, 540731, 0    timestamp: 1351828
    <info> time_sync: 24657, 540731, 0    timestamp: 1351829
    <info> time_sync: 656, 540732, 0    timestamp: 1351830
    <info> time_sync: 16656, 540732, 0    timestamp: 1351831
    <info> app: diff: 38
    <info> time_sync: 34937, 540732, 0    timestamp: 1351832
    <info> app: Zeit bei Emfpfang: 1351832 ms
    <info> time_sync: 37943, 540732, 0    timestamp: 1351832
    <info> time_sync: 8654, 540733, 0    timestamp: 1351833
    <info> time_sync: 24770, 540733, 0    timestamp: 1351834
    <info> time_sync: 733, 540734, 0    timestamp: 1351835
    <info> time_sync: 16680, 540734, 0    timestamp: 1351836
    <info> time_sync: 32728, 540734, 0    timestamp: 1351837
    <info> time_sync: 8648, 540735, 0    timestamp: 1351838
    <info> time_sync: 32656, 540738, 0    timestamp: 1351847
    <info> time_sync: 8656, 540739, 0    timestamp: 1351848
    <info> time_sync: 24656, 540739, 0    timestamp: 1351849
    <info> time_sync: 656, 540740, 0    timestamp: 1351850
    <info> time_sync: 16656, 540740, 0    timestamp: 1351851
    <info> time_sync: 32656, 540740, 0    timestamp: 1351852
    <info> time_sync: 8656, 540741, 0    timestamp: 1351853
    <info> time_sync: 24656, 540741, 0    timestamp: 1351854
    <info> time_sync: 656, 540742, 0    timestamp: 1351855
    <info> time_sync: 16656, 540742, 0    timestamp: 1351856
    <info> time_sync: 32656, 540742, 0    timestamp: 1351857
    <info> time_sync: 8656, 540743, 0    timestamp: 1351858
    <info> time_sync: 24656, 540743, 0    timestamp: 1351859
    <info> time_sync: 656, 540744, 0    timestamp: 1351860
    <info> time_sync: 16655, 540744, 0    timestamp: 1351861
    <info> time_sync: 32656, 540744, 0    timestamp: 1351862
    <info> time_sync: 8655, 540745, 0    timestamp: 1351863
    <info> time_sync: 24657, 540745, 0    timestamp: 1351864
    <info> time_sync: 647, 540746, 0    timestamp: 1351865
    <info> time_sync: 16656, 540746, 0    timestamp: 1351866
    <info> time_sync: 32656, 540746, 0    timestamp: 1351867
    <info> time_sync: 24657, 540747, 0    timestamp: 1351869
    <info> time_sync: 647, 540748, 0    timestamp: 1351870
    <info> time_sync: 16657, 540748, 0    timestamp: 1351871
    <info> app: diff: 40
    <info> time_sync: 37541, 540748, 0    timestamp: 1351872
    <info> time_sync: 8804, 540749, 0    timestamp: 1351873
    <info> time_sync: 24655, 540749, 0    timestamp: 1351874
    <info> time_sync: 716, 540750, 0    timestamp: 1351875
    <info> time_sync: 16697, 540750, 0    timestamp: 1351876
    <info> time_sync: 32655, 540752, 0    timestamp: 1351882
    <info> time_sync: 8656, 540753, 0    timestamp: 1351883
    <info> time_sync: 24656, 540753, 0    timestamp: 1351884
    <info> time_sync: 656, 540754, 0    timestamp: 1351885
    <info> time_sync: 16656, 540754, 0    timestamp: 1351886
    <info> time_sync: 32656, 540754, 0    timestamp: 1351887
    <info> time_sync: 8656, 540755, 0    timestamp: 1351888
    <info> time_sync: 24656, 540755, 0    timestamp: 1351889
    <info> time_sync: 656, 540756, 0    timestamp: 1351890
    <info> time_sync: 16656, 540756, 0    timestamp: 1351891
    <info> time_sync: 32656, 540756, 0    timestamp: 1351892
    <info> time_sync: 8655, 540757, 0    timestamp: 1351893
    <info> time_sync: 24656, 540757, 0    timestamp: 1351894
    <info> time_sync: 655, 540758, 0    timestamp: 1351895
    <info> time_sync: 16657, 540758, 0    timestamp: 1351896
    <info> time_sync: 32647, 540758, 0    timestamp: 1351897
    <info> time_sync: 8656, 540759, 0    timestamp: 1351898
    <info> time_sync: 24656, 540759, 0    timestamp: 1351899
    <info> time_sync: 656, 540760, 0    timestamp: 1351900
    <info> time_sync: 16657, 540760, 0    timestamp: 1351901
    <info> time_sync: 32647, 540760, 0    timestamp: 1351902
    <info> time_sync: 8656, 540761, 0    timestamp: 1351903
    <info> time_sync: 24656, 540761, 0    timestamp: 1351904
    <info> time_sync: 656, 540764, 0    timestamp: 1351910
    <info> time_sync: 16656, 540764, 0    timestamp: 1351911
    <info> app: diff: 43
    <info> time_sync: 35004, 540764, 0    timestamp: 1351912
    <info> app: Zeit bei Emfpfang: 1351912 ms
    <info> time_sync: 38010, 540764, 0    timestamp: 1351912
    <info> time_sync: 8701, 540765, 0    timestamp: 1351913
    <info> time_sync: 24834, 540765, 0    timestamp: 1351914
    <info> time_sync: 647, 540766, 0    timestamp: 1351915
    <info> time_sync: 16703, 540766, 0    timestamp: 1351916
    <info> time_sync: 32825, 540766, 0    timestamp: 1351917
    <info> time_sync: 8655, 540767, 0    timestamp: 1351918
    <info> time_sync: 24656, 540767, 0    timestamp: 1351919
    <info> time_sync: 656, 540770, 0    timestamp: 1351925
    <info> time_sync: 16655, 540770, 0    timestamp: 1351926
    <info> time_sync: 32656, 540770, 0    timestamp: 1351927
    <info> time_sync: 8655, 540771, 0    timestamp: 1351928
    <info> time_sync: 24656, 540771, 0    timestamp: 1351929
    <info> time_sync: 656, 540772, 0    timestamp: 1351930
    <info> time_sync: 16656, 540772, 0    timestamp: 1351931
    <info> time_sync: 32656, 540772, 0    timestamp: 1351932
    <info> time_sync: 8656, 540773, 0    timestamp: 1351933
    <info> time_sync: 24656, 540773, 0    timestamp: 1351934
    <info> time_sync: 656, 540774, 0    timestamp: 1351935
    <info> time_sync: 16656, 540774, 0    timestamp: 1351936
    <info> time_sync: 32656, 540774, 0    timestamp: 1351937
    <info> time_sync: 8656, 540775, 0    timestamp: 1351938
    <info> time_sync: 24656, 540775, 0    timestamp: 1351939
    <info> time_sync: 657, 540776, 0    timestamp: 1351940
    <info> time_sync: 16647, 540776, 0    timestamp: 1351941
    <info> time_sync: 32656, 540776, 0    timestamp: 1351942
    <info> time_sync: 8656, 540777, 0    timestamp: 1351943
    <info> time_sync: 24656, 540777, 0    timestamp: 1351944
    <info> time_sync: 657, 540778, 0    timestamp: 1351945
    <info> time_sync: 16647, 540778, 0    timestamp: 1351946
    <info> time_sync: 32656, 540778, 0    timestamp: 1351947
    <info> time_sync: 24657, 540779, 0    timestamp: 1351949
    <info> time_sync: 647, 540780, 0    timestamp: 1351950
    <info> time_sync: 16657, 540780, 0    timestamp: 1351951
    <info> app: diff: 40
    <info> time_sync: 37450, 540780, 0    timestamp: 1351952
    <info> time_sync: 8707, 540781, 0    timestamp: 1351953
    <info> time_sync: 24832, 540781, 0    timestamp: 1351954
    <info> time_sync: 830, 540782, 0    timestamp: 1351955
    <info> time_sync: 16813, 540782, 0    timestamp: 1351956
    <info> time_sync: 32760, 540782, 0    timestamp: 1351957
    <info> time_sync: 8656, 540785, 0    timestamp: 1351963
    <info> time_sync: 24656, 540785, 0    timestamp: 1351964
    <info> time_sync: 656, 540786, 0    timestamp: 1351965
    <info> time_sync: 16656, 540786, 0    timestamp: 1351966
    <info> time_sync: 32656, 540786, 0    timestamp: 1351967
    <info> time_sync: 8656, 540787, 0    timestamp: 1351968
    <info> time_sync: 24656, 540787, 0    timestamp: 1351969
    <info> time_sync: 656, 540788, 0    timestamp: 1351970
    <info> time_sync: 16656, 540788, 0    timestamp: 1351971
    <info> time_sync: 32656, 540788, 0    timestamp: 1351972
    <info> time_sync: 8657, 540789, 0    timestamp: 1351973
    <info> time_sync: 24647, 540789, 0    timestamp: 1351974
    <info> time_sync: 656, 540790, 0    timestamp: 1351975
    <info> time_sync: 16656, 540790, 0    timestamp: 1351976
    <info> time_sync: 32656, 540790, 0    timestamp: 1351977
    <info> time_sync: 8657, 540791, 0    timestamp: 1351978
    <info> time_sync: 24656, 540791, 0    timestamp: 1351979
    <info> time_sync: 24656, 540793, 0    timestamp: 1351984
    <info> time_sync: 656, 540794, 0    timestamp: 1351985
    <info> time_sync: 16656, 540794, 0    timestamp: 1351986
    <info> time_sync: 32656, 540794, 0    timestamp: 1351987
    <info> time_sync: 8656, 540795, 0    timestamp: 1351988
    <info> time_sync: 24656, 540795, 0    timestamp: 1351989
    <info> time_sync: 656, 540796, 0    timestamp: 1351990
    <info> time_sync: 16656, 540796, 0    timestamp: 1351991
    <info> app: diff: 40
    <info> time_sync: 37594, 540796, 0    timestamp: 1351992
    <info> time_sync: 8654, 540797, 0    timestamp: 1351993
    <info> time_sync: 24749, 540797, 0    timestamp: 1351994
    <info> time_sync: 696, 540798, 0    timestamp: 1351995
    <info> time_sync: 16744, 540798, 0    timestamp: 1351996
    <info> time_sync: 32792, 540798, 0    timestamp: 1351997
    <info> time_sync: 8656, 540799, 0    timestamp: 1351998
    <info> time_sync: 24657, 540799, 0    timestamp: 1351999
    <info> time_sync: 656, 540800, 0    timestamp: 1352000
    <info> time_sync: 32656, 540802, 0    timestamp: 1352007
    <info> time_sync: 8656, 540803, 0    timestamp: 1352008
    <info> time_sync: 24656, 540803, 0    timestamp: 1352009
    <info> time_sync: 656, 540804, 0    timestamp: 1352010
    <info> time_sync: 16656, 540804, 0    timestamp: 1352011
    <info> time_sync: 32656, 540804, 0    timestamp: 1352012
    <info> time_sync: 8656, 540805, 0    timestamp: 1352013
    <info> time_sync: 24656, 540805, 0    timestamp: 1352014
    <info> time_sync: 656, 540806, 0    timestamp: 1352015
    <info> time_sync: 16656, 540806, 0    timestamp: 1352016
    <info> time_sync: 32656, 540806, 0    timestamp: 1352017
    <info> time_sync: 8656, 540807, 0    timestamp: 1352018
    <info> time_sync: 24656, 540807, 0    timestamp: 1352019
    <info> time_sync: 656, 540808, 0    timestamp: 1352020
    <info> time_sync: 16657, 540808, 0    timestamp: 1352021
    <info> time_sync: 32656, 540808, 0    timestamp: 1352022
    <info> time_sync: 8655, 540809, 0    timestamp: 1352023
    <info> time_sync: 24656, 540809, 0    timestamp: 1352024
    <info> time_sync: 657, 540810, 0    timestamp: 1352025
    <info> time_sync: 16656, 540810, 0    timestamp: 1352026
    <info> time_sync: 32656, 540810, 0    timestamp: 1352027
    <info> time_sync: 24657, 540811, 0    timestamp: 1352029
    <info> time_sync: 647, 540812, 0    timestamp: 1352030
    <info> time_sync: 16657, 540812, 0    timestamp: 1352031
    <info> app: diff: 40
    <info> time_sync: 37366, 540812, 0    timestamp: 1352032
    <info> time_sync: 8654, 540813, 0    timestamp: 1352033
    <info> time_sync: 24819, 540813, 0    timestamp: 1352034
    <info> time_sync: 800, 540814, 0    timestamp: 1352035
    <info> time_sync: 16801, 540814, 0    timestamp: 1352036
    <info> time_sync: 8656, 540817, 0    timestamp: 1352043
    <info> time_sync: 24656, 540817, 0    timestamp: 1352044
    <info> time_sync: 656, 540818, 0    timestamp: 1352045
    <info> time_sync: 16656, 540818, 0    timestamp: 1352046
    <info> time_sync: 32656, 540818, 0    timestamp: 1352047
    <info> time_sync: 8656, 540819, 0    timestamp: 1352048
    <info> time_sync: 24656, 540819, 0    timestamp: 1352049
    <info> time_sync: 656, 540820, 0    timestamp: 1352050
    <info> time_sync: 16656, 540820, 0    timestamp: 1352051
    <info> time_sync: 32656, 540820, 0    timestamp: 1352052
    <info> time_sync: 8656, 540821, 0    timestamp: 1352053
    <info> time_sync: 24656, 540821, 0    timestamp: 1352054
    <info> time_sync: 656, 540822, 0    timestamp: 1352055
    <info> time_sync: 16655, 540822, 0    timestamp: 1352056
    <info> time_sync: 32656, 540822, 0    timestamp: 1352057
    <info> time_sync: 8655, 540823, 0    timestamp: 1352058
    <info> time_sync: 24656, 540823, 0    timestamp: 1352059
    <info> time_sync: 657, 540824, 0    timestamp: 1352060
    <info> time_sync: 16647, 540824, 0    timestamp: 1352061
    <info> time_sync: 32656, 540824, 0    timestamp: 1352062
    <info> time_sync: 8656, 540825, 0    timestamp: 1352063
    <info> time_sync: 657, 540826, 0    timestamp: 1352065
    <info> time_sync: 16647, 540826, 0    timestamp: 1352066
    <info> time_sync: 32647, 540826, 0    timestamp: 1352067
    <info> time_sync: 8656, 540827, 0    timestamp: 1352068
    <info> time_sync: 24656, 540827, 0    timestamp: 1352069
    <info> time_sync: 656, 540828, 0    timestamp: 1352070
    <info> time_sync: 16656, 540828, 0    timestamp: 1352071
    <info> time_sync: 35509, 540828, 0    timestamp: 1352072
    <info> app: diff: 40
    <info> time_sync: 8699, 540829, 0    timestamp: 1352073
    <info> time_sync: 24663, 540829, 0    timestamp: 1352074
    <info> time_sync: 737, 540830, 0    timestamp: 1352075
    <info> time_sync: 16649, 540830, 0    timestamp: 1352076
    <info> time_sync: 32648, 540830, 0    timestamp: 1352077
    <info> time_sync: 8648, 540831, 0    timestamp: 1352078
    <info> time_sync: 657, 540832, 0    timestamp: 1352080
    <info> time_sync: 16647, 540832, 0    timestamp: 1352081
    <info> time_sync: 32657, 540832, 0    timestamp: 1352082
    <info> time_sync: 8656, 540833, 0    timestamp: 1352083
    <info> time_sync: 16656, 540836, 0    timestamp: 1352091
    <info> time_sync: 32656, 540836, 0    timestamp: 1352092
    <info> time_sync: 8656, 540837, 0    timestamp: 1352093
    <info> time_sync: 24656, 540837, 0    timestamp: 1352094
    <info> time_sync: 656, 540838, 0    timestamp: 1352095
    <info> time_sync: 16656, 540838, 0    timestamp: 1352096
    <info> time_sync: 32656, 540838, 0    timestamp: 1352097
    <info> time_sync: 8656, 540839, 0    timestamp: 1352098
    <info> time_sync: 24656, 540839, 0    timestamp: 1352099
    <info> time_sync: 656, 540840, 0    timestamp: 1352100
    <info> time_sync: 16656, 540840, 0    timestamp: 1352101
    <info> time_sync: 32656, 540840, 0    timestamp: 1352102
    <info> time_sync: 8656, 540841, 0    timestamp: 1352103
    <info> time_sync: 24656, 540841, 0    timestamp: 1352104
    <info> time_sync: 656, 540842, 0    timestamp: 1352105
    <info> time_sync: 16656, 540842, 0    timestamp: 1352106
    <info> time_sync: 32656, 540842, 0    timestamp: 1352107
    <info> time_sync: 8657, 540843, 0    timestamp: 1352108
    <info> time_sync: 24656, 540843, 0    timestamp: 1352109
    <info> time_sync: 656, 540844, 0    timestamp: 1352110
    <info> time_sync: 16656, 540844, 0    timestamp: 1352111
    <info> app: diff: 40
    <info> time_sync: 37632, 540844, 0    timestamp: 1352112
    <info> time_sync: 8654, 540845, 0    timestamp: 1352113
    <info> time_sync: 24681, 540845, 0    timestamp: 1352114
    <info> time_sync: 644, 540846, 0    timestamp: 1352115
    <info> time_sync: 16680, 540846, 0    timestamp: 1352116
    <info> time_sync: 32728, 540846, 0    timestamp: 1352117
    <info> time_sync: 8656, 540847, 0    timestamp: 1352118
    <info> time_sync: 24657, 540847, 0    timestamp: 1352119
    <info> time_sync: 8656, 540851, 0    timestamp: 1352128
    <info> time_sync: 24656, 540851, 0    timestamp: 1352129
    <info> time_sync: 656, 540852, 0    timestamp: 1352130
    <info> time_sync: 16656, 540852, 0    timestamp: 1352131
    <info> time_sync: 32656, 540852, 0    timestamp: 1352132
    <info> time_sync: 8656, 540853, 0    timestamp: 1352133
    <info> time_sync: 24656, 540853, 0    timestamp: 1352134
    <info> time_sync: 656, 540854, 0    timestamp: 1352135
    <info> time_sync: 16656, 540854, 0    timestamp: 1352136
    <info> time_sync: 32656, 540854, 0    timestamp: 1352137
    <info> time_sync: 8656, 540855, 0    timestamp: 1352138
    <info> time_sync: 24656, 540855, 0    timestamp: 1352139
    <info> time_sync: 656, 540856, 0    timestamp: 1352140
    <info> time_sync: 16656, 540856, 0    timestamp: 1352141
    <info> time_sync: 32656, 540856, 0    timestamp: 1352142
    <info> time_sync: 8656, 540857, 0    timestamp: 1352143
    <info> time_sync: 24656, 540857, 0    timestamp: 1352144
    <info> time_sync: 656, 540858, 0    timestamp: 1352145
    <info> time_sync: 16657, 540858, 0    timestamp: 1352146
    <info> time_sync: 32647, 540858, 0    timestamp: 1352147
    <info> time_sync: 8656, 540859, 0    timestamp: 1352148
    <info> time_sync: 24656, 540859, 0    timestamp: 1352149
    <info> time_sync: 656, 540860, 0    timestamp: 1352150
    <info> time_sync: 16657, 540860, 0    timestamp: 1352151
    <info> app: diff: 40
    <info> time_sync: 37414, 540860, 0    timestamp: 1352152
    <info> time_sync: 8775, 540861, 0    timestamp: 1352153
    <info> time_sync: 24839, 540861, 0    timestamp: 1352154
    <info> time_sync: 644, 540862, 0    timestamp: 1352155
    <info> time_sync: 16718, 540862, 0    timestamp: 1352156
    <info> time_sync: 32719, 540862, 0    timestamp: 1352157
    <info> time_sync: 656, 540866, 0    timestamp: 1352165
    <info> time_sync: 16656, 540866, 0    timestamp: 1352166
    <info> time_sync: 32656, 540866, 0    timestamp: 1352167
    <info> time_sync: 8656, 540867, 0    timestamp: 1352168
    <info> time_sync: 24656, 540867, 0    timestamp: 1352169
    <info> time_sync: 656, 540868, 0    timestamp: 1352170
    <info> time_sync: 16656, 540868, 0    timestamp: 1352171
    <info> time_sync: 32656, 540868, 0    timestamp: 1352172
    <info> time_sync: 8656, 540869, 0    timestamp: 1352173
    <info> time_sync: 24656, 540869, 0    timestamp: 1352174
    <info> time_sync: 656, 540870, 0    timestamp: 1352175
    <info> time_sync: 16656, 540870, 0    timestamp: 1352176
    <info> time_sync: 32656, 540870, 0    timestamp: 1352177
    <info> time_sync: 8656, 540871, 0    timestamp: 1352178
    <info> time_sync: 24656, 540871, 0    timestamp: 1352179
    <info> time_sync: 656, 540872, 0    timestamp: 1352180
    <info> time_sync: 16656, 540872, 0    timestamp: 1352181
    <info> time_sync: 32656, 540872, 0    timestamp: 1352182
    <info> time_sync: 8657, 540873, 0    timestamp: 1352183
    <info> time_sync: 24647, 540873, 0    timestamp: 1352184
    <info> time_sync: 656, 540874, 0    timestamp: 1352185
    <info> time_sync: 16655, 540874, 0    timestamp: 1352186
    <info> time_sync: 32656, 540874, 0    timestamp: 1352187
    <info> time_sync: 8657, 540875, 0    timestamp: 1352188
    <info> time_sync: 24656, 540875, 0    timestamp: 1352189
    <info> time_sync: 656, 540876, 0    timestamp: 1352190
    <info> time_sync: 16657, 540876, 0    timestamp: 1352191
    <info> app: diff: 40
    <info> time_sync: 37701, 540876, 0    timestamp: 1352192
    <info> time_sync: 8743, 540877, 0    timestamp: 1352193
    <info> time_sync: 24807, 540877, 0    timestamp: 1352194
    <info> time_sync: 644, 540878, 0    timestamp: 1352195
    <info> time_sync: 16705, 540878, 0    timestamp: 1352196
    <info> time_sync: 32704, 540878, 0    timestamp: 1352197
    <info> time_sync: 16656, 540882, 0    timestamp: 1352206
    <info> time_sync: 32656, 540882, 0    timestamp: 1352207
    <info> time_sync: 8656, 540883, 0    timestamp: 1352208
    <info> time_sync: 24656, 540883, 0    timestamp: 1352209
    <info> time_sync: 656, 540884, 0    timestamp: 1352210
    <info> time_sync: 16656, 540884, 0    timestamp: 1352211
    <info> time_sync: 32656, 540884, 0    timestamp: 1352212
    <info> time_sync: 8656, 540885, 0    timestamp: 1352213
    <info> time_sync: 24656, 540885, 0    timestamp: 1352214
    <info> time_sync: 656, 540886, 0    timestamp: 1352215
    <info> time_sync: 16656, 540886, 0    timestamp: 1352216
    <info> time_sync: 32656, 540886, 0    timestamp: 1352217
    <info> time_sync: 8655, 540887, 0    timestamp: 1352218
    <info> time_sync: 24656, 540887, 0    timestamp: 1352219
    <info> time_sync: 655, 540888, 0    timestamp: 1352220
    <info> time_sync: 16656, 540888, 0    timestamp: 1352221
    <info> time_sync: 32656, 540888, 0    timestamp: 1352222
    <info> time_sync: 8656, 540889, 0    timestamp: 1352223
    <info> time_sync: 24656, 540889, 0    timestamp: 1352224
    <info> time_sync: 656, 540890, 0    timestamp: 1352225
    <info> time_sync: 16656, 540890, 0    timestamp: 1352226
    <info> time_sync: 32657, 540890, 0    timestamp: 1352227
    <info> time_sync: 8647, 540891, 0    timestamp: 1352228
    <info> time_sync: 24656, 540891, 0    timestamp: 1352229
    <info> time_sync: 656, 540892, 0    timestamp: 1352230
    <info> time_sync: 16657, 540892, 0    timestamp: 1352231
    <info> time_sync: 35557, 540892, 0    timestamp: 1352232
    <info> app: diff: 40
    <info> time_sync: 8747, 540893, 0    timestamp: 1352233
    <info> time_sync: 24711, 540893, 0    timestamp: 1352234
    <info> time_sync: 792, 540894, 0    timestamp: 1352235
    <info> time_sync: 16744, 540894, 0    timestamp: 1352236
    <info> time_sync: 32792, 540894, 0    timestamp: 1352237
    <info> time_sync: 8651, 540895, 0    timestamp: 1352238
    <info> time_sync: 16656, 540898, 0    timestamp: 1352246
    <info> time_sync: 32656, 540898, 0    timestamp: 1352247
    <info> time_sync: 8656, 540899, 0    timestamp: 1352248
    <info> time_sync: 24656, 540899, 0    timestamp: 1352249
    <info> time_sync: 656, 540900, 0    timestamp: 1352250
    <info> time_sync: 16655, 540900, 0    timestamp: 1352251
    <info> time_sync: 32656, 540900, 0    timestamp: 1352252
    <info> time_sync: 8655, 540901, 0    timestamp: 1352253
    <info> time_sync: 24656, 540901, 0    timestamp: 1352254
    <info> time_sync: 656, 540902, 0    timestamp: 1352255
    <info> time_sync: 16656, 540902, 0    timestamp: 1352256
    <info> time_sync: 32656, 540902, 0    timestamp: 1352257
    <info> time_sync: 8656, 540903, 0    timestamp: 1352258
    <info> time_sync: 24656, 540903, 0    timestamp: 1352259
    <info> time_sync: 656, 540904, 0    timestamp: 1352260
    <info> time_sync: 16656, 540904, 0    timestamp: 1352261
    <info> time_sync: 32656, 540904, 0    timestamp: 1352262
    <info> time_sync: 8656, 540905, 0    timestamp: 1352263
    <info> time_sync: 24657, 540905, 0    timestamp: 1352264
    <info> time_sync: 647, 540906, 0    timestamp: 1352265
    <info> time_sync: 16656, 540906, 0    timestamp: 1352266
    <info> time_sync: 32656, 540906, 0    timestamp: 1352267
    <info> time_sync: 24657, 540907, 0    timestamp: 1352269
    <info> time_sync: 647, 540908, 0    timestamp: 1352270
    <info> time_sync: 16657, 540908, 0    timestamp: 1352271
    <info> app: diff: 40
    <info> time_sync: 37433, 540908, 0    timestamp: 1352272
    <info> time_sync: 8690, 540909, 0    timestamp: 1352273
    <info> time_sync: 24835, 540909, 0    timestamp: 1352274
    <info> time_sync: 816, 540910, 0    timestamp: 1352275
    <info> time_sync: 16817, 540910, 0    timestamp: 1352276
    <info> time_sync: 8655, 540913, 0    timestamp: 1352283
    <info> time_sync: 24656, 540913, 0    timestamp: 1352284
    <info> time_sync: 655, 540914, 0    timestamp: 1352285
    <info> time_sync: 16656, 540914, 0    timestamp: 1352286
    <info> time_sync: 32656, 540914, 0    timestamp: 1352287
    <info> time_sync: 8656, 540915, 0    timestamp: 1352288
    <info> time_sync: 24656, 540915, 0    timestamp: 1352289
    <info> time_sync: 656, 540916, 0    timestamp: 1352290
    <info> time_sync: 16656, 540916, 0    timestamp: 1352291
    <info> time_sync: 32656, 540916, 0    timestamp: 1352292
    <info> time_sync: 8656, 540917, 0    timestamp: 1352293
    <info> time_sync: 24656, 540917, 0    timestamp: 1352294
    <info> time_sync: 656, 540918, 0    timestamp: 1352295
    <info> time_sync: 16656, 540918, 0    timestamp: 1352296
    <info> time_sync: 32657, 540918, 0    timestamp: 1352297
    <info> time_sync: 8647, 540919, 0    timestamp: 1352298
    <info> time_sync: 24656, 540919, 0    timestamp: 1352299
    <info> time_sync: 656, 540920, 0    timestamp: 1352300
    <info> time_sync: 32657, 540920, 0    timestamp: 1352302
    <info> time_sync: 8647, 540921, 0    timestamp: 1352303
    <info> time_sync: 24647, 540921, 0    timestamp: 1352304
    <info> time_sync: 656, 540922, 0    timestamp: 1352305
    <info> time_sync: 16656, 540922, 0    timestamp: 1352306
    <info> time_sync: 32656, 540922, 0    timestamp: 1352307
    <info> time_sync: 8656, 540923, 0    timestamp: 1352308
    <info> time_sync: 24657, 540923, 0    timestamp: 1352309
    <info> time_sync: 647, 540924, 0    timestamp: 1352310
    <info> time_sync: 16656, 540924, 0    timestamp: 1352311
    <info> app: diff: 40
    <info> time_sync: 37760, 540924, 0    timestamp: 1352312
    <info> time_sync: 8736, 540925, 0    timestamp: 1352313
    <info> time_sync: 24845, 540925, 0    timestamp: 1352314
    <info> time_sync: 792, 540926, 0    timestamp: 1352315
    <info> time_sync: 32644, 540926, 0    timestamp: 1352317
    <info> time_sync: 8650, 540927, 0    timestamp: 1352318
    <info> time_sync: 24642, 540927, 0    timestamp: 1352319
    <info> time_sync: 646, 540928, 0    timestamp: 1352320
    <info> time_sync: 16643, 540928, 0    timestamp: 1352321
    <info> time_sync: 32656, 540928, 0    timestamp: 1352322
    <info> time_sync: 8657, 540929, 0    timestamp: 1352323
    <info> time_sync: 24647, 540929, 0    timestamp: 1352324
    <info> time_sync: 32656, 540932, 0    timestamp: 1352332
    <info> time_sync: 8656, 540933, 0    timestamp: 1352333
    <info> time_sync: 24656, 540933, 0    timestamp: 1352334
    <info> time_sync: 656, 540934, 0    timestamp: 1352335
    <info> time_sync: 16656, 540934, 0    timestamp: 1352336
    <info> time_sync: 32656, 540934, 0    timestamp: 1352337
    <info> time_sync: 8656, 540935, 0    timestamp: 1352338
    <info> time_sync: 24656, 540935, 0    timestamp: 1352339
    <info> time_sync: 656, 540936, 0    timestamp: 1352340
    <info> time_sync: 16656, 540936, 0    timestamp: 1352341
    <info> time_sync: 32656, 540936, 0    timestamp: 1352342
    <info> time_sync: 8656, 540937, 0    timestamp: 1352343
    <info> time_sync: 24656, 540937, 0    timestamp: 1352344
    <info> time_sync: 656, 540938, 0    timestamp: 1352345
    <info> time_sync: 16656, 540938, 0    timestamp: 1352346
    <info> time_sync: 32656, 540938, 0    timestamp: 1352347
    <info> time_sync: 8656, 540939, 0    timestamp: 1352348
    <info> time_sync: 24657, 540939, 0    timestamp: 1352349
    <info> time_sync: 656, 540940, 0    timestamp: 1352350
    <info> time_sync: 16656, 540940, 0    timestamp: 1352351
    <info> app: diff: 40
    <info> time_sync: 37467, 540940, 0    timestamp: 1352352
    <info> time_sync: 8723, 540941, 0    timestamp: 1352353
    <info> time_sync: 24813, 540941, 0    timestamp: 1352354
    <info> time_sync: 760, 540942, 0    timestamp: 1352355
    <info> time_sync: 16808, 540942, 0    timestamp: 1352356
    <info> time_sync: 32644, 540942, 0    timestamp: 1352357
    <info> time_sync: 8656, 540943, 0    timestamp: 1352358
    <info> time_sync: 24657, 540943, 0    timestamp: 1352359
    <info> time_sync: 652, 540944, 0    timestamp: 1352360
    <info> time_sync: 8656, 540947, 0    timestamp: 1352368
    <info> time_sync: 24656, 540947, 0    timestamp: 1352369
    <info> time_sync: 656, 540948, 0    timestamp: 1352370
    <info> time_sync: 16656, 540948, 0    timestamp: 1352371
    <info> time_sync: 32656, 540948, 0    timestamp: 1352372
    <info> time_sync: 8656, 540949, 0    timestamp: 1352373
    <info> time_sync: 24656, 540949, 0    timestamp: 1352374
    <info> time_sync: 656, 540950, 0    timestamp: 1352375
    <info> time_sync: 16656, 540950, 0    timestamp: 1352376
    <info> time_sync: 32656, 540950, 0    timestamp: 1352377
    <info> time_sync: 8656, 540951, 0    timestamp: 1352378
    <info> time_sync: 24656, 540951, 0    timestamp: 1352379
    <info> time_sync: 656, 540952, 0    timestamp: 1352380
    <info> time_sync: 16655, 540952, 0    timestamp: 1352381
    <info> time_sync: 32656, 540952, 0    timestamp: 1352382
    <info> time_sync: 8655, 540953, 0    timestamp: 1352383
    <info> time_sync: 24656, 540953, 0    timestamp: 1352384
    <info> time_sync: 657, 540954, 0    timestamp: 1352385
    <info> time_sync: 16656, 540954, 0    timestamp: 1352386
    <info> time_sync: 32656, 540954, 0    timestamp: 1352387
    <info> time_sync: 8656, 540955, 0    timestamp: 1352388
    <info> time_sync: 24656, 540955, 0    timestamp: 1352389
    <info> time_sync: 657, 540956, 0    timestamp: 1352390
    <info> time_sync: 16657, 540956, 0    timestamp: 1352391
    <info> app: diff: 40
    <error> app: ERROR 0 [NRF_SUCCESS] ...

    --------------------------------------------------------------

    I ran my tests multiple times. It looks like that the offset always occures when the sync_timer_val goes from 40000 to 0. Sometimes I also saw a bit of "jumping" of the sync_timer_val. This is the debug log of the peripheral of another test run:

    [00:07:02.453,063] <info> time_sync: 39724, 3, 174194    timestamp: 435495
    [00:07:02.493,041] <info> time_sync: 39729, 6, 174207    timestamp: 435535
    [00:07:02.533,081] <info> time_sync: 39730, 22, 174207    timestamp: 435575
    [00:07:02.573,120] <info> time_sync: 101, 0, 174246    timestamp: 435615
    [00:07:02.613,098] <info> time_sync: 39747, 2, 174259    timestamp: 435655
    [00:07:02.653,076] <info> time_sync: 39752, 5, 174272    timestamp: 435695
    [00:07:02.693,054] <info> time_sync: 39756, 8, 174285    timestamp: 435735
    [00:07:02.733,093] <info> time_sync: 39757, 24, 174285    timestamp: 435775
    [00:07:02.773,071] <info> time_sync: 39770, 1, 174324    timestamp: 435815
    [00:07:02.813,110] <info> time_sync: 39775, 4, 174337    timestamp: 435855
    [00:07:02.853,088] <info> time_sync: 39779, 7, 174350    timestamp: 435895
    [00:07:02.893,066] <info> time_sync: 39780, 23, 174350    timestamp: 435935
    [00:07:02.933,105] <info> time_sync: 39793, 0, 174389    timestamp: 435975
    [00:07:02.973,083] <info> time_sync: 39798, 3, 174402    timestamp: 436015
    [00:07:03.013,122] <info> time_sync: 39802, 6, 174415    timestamp: 436055
    [00:07:03.053,100] <info> time_sync: 39803, 22, 174415    timestamp: 436095
    [00:07:03.093,139] <info> time_sync: 102, 0, 174454    timestamp: 436135
    [00:07:03.133,117] <info> time_sync: 39820, 2, 174467    timestamp: 436175
    [00:07:03.173,095] <info> time_sync: 39825, 5, 174480    timestamp: 436215
    [00:07:03.213,134] <info> time_sync: 39829, 8, 174493    timestamp: 436255
    [00:07:03.253,112] <info> time_sync: 39830, 24, 174493    timestamp: 436295
    [00:07:03.293,090] <info> time_sync: 39843, 1, 174532    timestamp: 436335
    [00:07:03.333,129] <info> time_sync: 39848, 4, 174545    timestamp: 436375
    [00:07:03.373,107] <info> time_sync: 39853, 7, 174558    timestamp: 436415
    [00:07:03.413,085] <info> time_sync: 39854, 23, 174558    timestamp: 436455
    [00:07:03.453,125] <info> time_sync: 39866, 0, 174597    timestamp: 436495
    [00:07:03.493,103] <info> time_sync: 39871, 3, 174610    timestamp: 436535
    [00:07:03.533,142] <info> time_sync: 39875, 6, 174623    timestamp: 436575
    [00:07:03.573,120] <info> time_sync: 39876, 22, 174623    timestamp: 436615
    [00:07:03.613,159] <info> time_sync: 100, 0, 174662    timestamp: 436655
    [00:07:03.653,137] <info> time_sync: 39894, 2, 174675    timestamp: 436695
    [00:07:03.693,115] <info> time_sync: 39898, 5, 174688    timestamp: 436735
    [00:07:03.733,154] <info> time_sync: 39903, 8, 174701    timestamp: 436775
    [00:07:03.773,132] <info> time_sync: 39904, 24, 174701    timestamp: 436815
    [00:07:03.813,110] <info> time_sync: 39916, 1, 174740    timestamp: 436855
    [00:07:03.853,149] <info> time_sync: 39921, 4, 174753    timestamp: 436895
    [00:07:03.893,127] <info> time_sync: 39926, 7, 174766    timestamp: 436935
    [00:07:03.933,166] <info> time_sync: 39927, 23, 174766    timestamp: 436975
    [00:07:03.973,144] <info> time_sync: 39939, 0, 174805    timestamp: 437015
    [00:07:04.013,122] <info> time_sync: 39944, 3, 174818    timestamp: 437055
    [00:07:04.053,161] <info> time_sync: 39948, 6, 174831    timestamp: 437095
    [00:07:04.093,139] <info> time_sync: 39949, 22, 174831    timestamp: 437135
    [00:07:04.133,178] <info> time_sync: 102, 0, 174870    timestamp: 437175
    [00:07:04.173,156] <info> time_sync: 39967, 2, 174883    timestamp: 437215
    [00:07:04.213,134] <info> time_sync: 39971, 5, 174896    timestamp: 437255
    [00:07:04.253,173] <info> time_sync: 39976, 8, 174909    timestamp: 437295
    [00:07:04.293,151] <info> time_sync: 39977, 24, 174909    timestamp: 437335
    [00:07:04.333,129] <info> time_sync: 39990, 1, 174948    timestamp: 437375
    [00:07:04.373,168] <info> time_sync: 39994, 4, 174961    timestamp: 437415
    [00:07:04.413,146] <info> time_sync: 39999, 7, 174974    timestamp: 437455
    [00:07:04.453,186] <info> time_sync: 0, 23, 174974    timestamp: 437493

    --------------------------------------------------------------

    Finally I want to point something out regarding the priority.

    Either way, since you are calling the timestamp function from a lower priority that SWI3_EGU3_IRQHandler

    This is not fully correct. I would like to call the timestamp function from the same priority than the SWI3_EGU3_IRQHandler (If this is possible?). The timestamp function gets called with priority 6. In order to match this line in your timers_capture() function:

    APP_ERROR_CHECK_BOOL(current_int_priority_get() > TIME_SYNC_EVT_HANDLER_IRQ_PRIORITY);

    I have to set TIME_SYNC_EVT_HANDLER_IRQ_PRIORITY at least to 5. Which could cause an unwanted behaviour. Is it possible to call it from the same priority?

    Another consequence of this APP_ERROR_CHECK_BOOL(...) line is, that I have to use

    #define TIME_SYNC_TX_OFFSET_REALIGN_TIMEOUT 0

    because every other value would cause an error with this function:

    static int32_t calculate_tx_start_offset(void)

    --------------------------------------------------------------

    So I am still having the abrupt offset issue.

    Do you have any other suggestions on how to solve this issue. We highly appreciate your help with our problem. It still looks like that the success of our project depends on your help.

    Thank you very much in advance.

    Best regards,

    Michael

  • Hi Michael,

    So I am still having the abrupt offset issue.

    Do you have any other suggestions on how to solve this issue. We highly appreciate your help with our problem. It still looks like that the success of our project depends on your help.

    Thanks for the update. I have spent time in the office today to set up a better test case to reproduce the issue you see:

    On the receiver side I have a RTC set up to capture a timestamp every X ms, and I look at the relative difference between the current and previous timestamp to determine if this is a sane value. I think this is functionally equivalent of the setup you have?

    I believe I see the issue, and will work on confirming my setup and work on a solution.

    Best regards,

    Audun

  • Hello Audun,

    thank you very much for the reply and the effort you put into this.

    Basically this is a functionally equivalent of my setup. But one thing is different:

    On the receiver side of the sync beacons (peripheral) I have a TIMER (TIMER peripheral) to capture a timestamp every 40ms. Then I check the difference between the current and the previous timestamp, as you already mentioned. If the difference is higher than 41 or lower than 39 I generate an error.

    If you are interested, this is the configuration of the TIMER:

    static const nrfx_timer_t               m_timer = NRFX_TIMER_INSTANCE(1);
    
    void saadc_sampling_event_init(void)
    {
        ret_code_t err_code;
        err_code = nrf_drv_ppi_init();
        APP_ERROR_CHECK(err_code);
        
        nrfx_timer_config_t timer_config = NRFX_TIMER_DEFAULT_CONFIG;
        timer_config.frequency = NRF_TIMER_FREQ_16MHz;
        err_code = nrfx_timer_init(&m_timer, &timer_config, timer_handler);
        APP_ERROR_CHECK(err_code);
    
        /* setup m_timer for compare event */
        uint32_t ticks = nrfx_timer_ms_to_ticks(&m_timer,1);
        nrfx_timer_extended_compare(&m_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
        nrfx_timer_enable(&m_timer);
    
        uint32_t timer_compare_event_addr = nrfx_timer_compare_event_address_get(&m_timer, NRF_TIMER_CC_CHANNEL0);
        uint32_t saadc_sample_event_addr = nrfx_saadc_sample_task_get();
    
        /* setup ppi channel so that timer compare event is triggering sample task in SAADC */
        err_code = nrf_drv_ppi_channel_alloc(&m_ppi_channel);
        APP_ERROR_CHECK(err_code);
        
        err_code = nrf_drv_ppi_channel_assign(m_ppi_channel, timer_compare_event_addr, saadc_sample_event_addr);
        APP_ERROR_CHECK(err_code);
    }    

    I setup a ppi channel so that timer compare event is triggering sample task in SAADC (every 1ms). In the saadc_callback I call my timestamp function every 40th time (every 40ms) .

    I believe I see the issue, and will work on confirming my setup and work on a solution.

    That sounds great. I am looking forward to hearing from you.

    Please let me know, if you need anything more.

    Thank you very much in advance.

    Best regards,

    Michael

  • Hi Michael,

    can you try to replace your timers_capture function again with the one below? This should have no restrictions on what interrupt level it can be called from. It won't have a potentially long delay either.

    With this change I haven't seen the issue again on my side. Will let my test case run over the weekend and see if any issues are triggered.

    I've not looked closely at the TIMER reference code you posted, but will take a closer look at that if the issue persists on your side.

    Best regards,

    Audun

    static void timers_capture(uint32_t * p_sync_timer_val, uint32_t * p_count_timer_val, uint32_t * p_peer_counter)
    {
        static nrf_atomic_flag_t m_timestamp_capture_flag = 0;
    
        nrf_atomic_u32_t peer_counter;
    
        if (nrf_atomic_flag_set_fetch(&m_timestamp_capture_flag) != 0)
        {
            // Not thread-safe
            APP_ERROR_CHECK_BOOL(false);
        }
    
        nrf_ppi_channel_t ppi_chn;
        nrfx_err_t ret = nrfx_ppi_channel_alloc(&ppi_chn);
        APP_ERROR_CHECK_BOOL(ret == NRFX_SUCCESS);
    
        ppi_counter_timer_capture_configure(ppi_chn);
    
        NVIC_DisableIRQ(m_params.egu_irq_type);
    
        bool counter_adjustment_triggered;
    
        // Loop while there is a chance of capturing during timer adjustment,
        // or if timer wraparound happens very close to the same clock cycle as the capture.
        do
        {
            counter_adjustment_triggered = m_params.egu->EVENTS_TRIGGERED[0];
    
            m_params.egu->TASKS_TRIGGER[1] = 1;
    
            if (counter_adjustment_triggered)
            {
                peer_counter = ((sync_pkt_t *) mp_curr_adj_pkt)->counter_val;
            }
            else
            {
                peer_counter = m_master_counter;
            }
        } while (counter_adjustment_triggered != m_params.egu->EVENTS_TRIGGERED[0] ||
                 m_params.high_freq_timer[0]->CC[3] < 2);
    
        NVIC_EnableIRQ(m_params.egu_irq_type);
    
        ppi_counter_timer_capture_disable(ppi_chn);
        nrfx_ppi_channel_free(ppi_chn);
    
        *p_sync_timer_val  = m_params.high_freq_timer[0]->CC[3];
        *p_count_timer_val = (m_params.high_freq_timer[1]->CC[0]);
        *p_peer_counter    = peer_counter;
    
        nrf_atomic_flag_clear(&m_timestamp_capture_flag);
    }

  • Hi again Michael,

    there were some corner cases that triggered during the weekend, and I've made some further refinements to the code now. Can you try the following on your side?

    static void timers_capture(uint32_t * p_sync_timer_val, uint32_t * p_count_timer_val, uint32_t * p_peer_counter)
    {
        static nrf_atomic_flag_t m_timestamp_capture_flag = 0;
    
        nrf_atomic_u32_t peer_counter;
    
        if (nrf_atomic_flag_set_fetch(&m_timestamp_capture_flag) != 0)
        {
            // Not thread-safe
            APP_ERROR_CHECK_BOOL(false);
        }
    
        nrf_ppi_channel_t ppi_chn;
        nrfx_err_t ret = nrfx_ppi_channel_alloc(&ppi_chn);
        APP_ERROR_CHECK_BOOL(ret == NRFX_SUCCESS);
    
        ppi_counter_timer_capture_configure(ppi_chn);
    
        NVIC_DisableIRQ(m_params.egu_irq_type);
    
        bool counter_adjustment_triggered;
    
        // Loop if adjustment procedure happened close to timer capture
        do
        {
            counter_adjustment_triggered = m_params.egu->EVENTS_TRIGGERED[0];
    
            m_params.egu->EVENTS_TRIGGERED[1] = 0;
            m_params.egu->TASKS_TRIGGER[1] = 1;
            while (m_params.egu->EVENTS_TRIGGERED[1] == 0)
            {
                __NOP();
            }
    
            if (m_params.high_freq_timer[1]->CC[0] < 2 || m_params.high_freq_timer[0]->CC[3] < 2)
            {
                /* Capture again if capture happened too close to adjustment or wraparound */
                m_params.egu->EVENTS_TRIGGERED[1] = 0;
                m_params.egu->TASKS_TRIGGER[1] = 1;
                while (m_params.egu->EVENTS_TRIGGERED[1] == 0)
                {
                    __NOP();
                }
            }
    
            if (counter_adjustment_triggered)
            {
                peer_counter = ((sync_pkt_t *) mp_curr_adj_pkt)->counter_val;
            }
            else
            {
                peer_counter = m_master_counter;
            }
        } while (counter_adjustment_triggered != m_params.egu->EVENTS_TRIGGERED[0] ||
                 m_params.high_freq_timer[0]->CC[3] < 2);
    
        NVIC_EnableIRQ(m_params.egu_irq_type);
    
        ppi_counter_timer_capture_disable(ppi_chn);
        nrfx_ppi_channel_free(ppi_chn);
    
        *p_sync_timer_val  = m_params.high_freq_timer[0]->CC[3];
        *p_count_timer_val = (m_params.high_freq_timer[1]->CC[0]);
        *p_peer_counter    = peer_counter;
    
        nrf_atomic_flag_clear(&m_timestamp_capture_flag);
    }

Related