nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Time synchronization with alternating masters

Dear members,

with success I implemented the time synchronization example from the nRF5 SDK guide.
This example works perfect for a single master, but what if the master changes?
When I check my scope it will show that the new master starts sending the sync beacons, but the slave (previous master) is not receiving and stays low.
Would there be a solution to put a master in receiver mode after stopping the sync beacons?

I am using four nRF52840-DKs with Segger Studio, SDK 17 and a S140 softdevice (used for a custom BLE service)

  • Hello Audun,

    Thank you for your reply!

    I did the diff on my side it all compiles ok. But I think I did something wrong, since I am not able to switch masters. All the steps as described work fine, except for the last step (step 6) since only the new master starts to toggle, the new slave does not toggle its GPIO. 

    Can you tell me the reason why you added "m_master_counter_diff" and where to declare this variable?

    regards Egbert

  • No problem!
    I think I was looking at a different branch than you.

    In the master branch, the equivalent of "m_master_counter_diff" is "m_master_counter". These variables keeps track of the transmitter/master counter value. This is normally 0 on the transmitter side, except for when a device used to be a receiver and switches to be a transmitter.

    If this value is not the same on transmitter and receiver, and you set a trigger using ts_set_trigger(), the triggering time might be in the past, or far in the future.

    When changing from receiver to transmitter mode, you can either reset the m_master_counter variable (which would cause a potentially large leap in the timing), or take it into account here as a transmitter:
    https://github.com/nordic-auko/nRF5-ble-timesync-demo/blob/master/nRF5_SDK_16.0.0_98a08e2/examples/common/time_sync.c#L544
    You can try to reset the variable first and see if this works?

    Best regards,

    Audun

  • Hello Audun,

    With the version you referred to in the previous post the switching works great. I will try to implement this in my own source and see if I can switch the master also. Thanks so far for your help and the explanation!

    regards,

    Egbert

Related