MP: Discovery is also syncing the clock upon receiving HEARTBEAT frames #551
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The MP_HEARTBEAT frame did not include the millis field. Add the millis field to the MP_HEARTBEAT frame to enable the clock to properly synchronize. Prior to adding this field the synchronization would be random and typically larger than 40 mSec. With the millis value in the HEARTBEAT frame the clock synchronization drops to less than 2 mSec.
Testing was done by modifying the discovery code to save the millis value when the code transitioned to the RADIO_MP_STANDBY state. In the RADIO_MP_STANDBY if the client had run more than 5 seconds then it would change states to RADIO_DISCOVER_BEGIN. A five minute log was captured and the following clock synchronization offsets were recorded:
759 uSec - from HEARTBEAT frame
431 uSec - from HEARTBEAT frame
405 uSec - from HEARTBEAT frame
240 uSec - from HEARTBEAT frame
258 uSec - from HEARTBEAT frame
79 uSec - from HEARTBEAT frame
145 uSec - from HEARTBEAT frame
663 uSec - from HEARTBEAT frame
131 uSec - from HEARTBEAT frame
370 uSec - from HEARTBEAT frame
410 uSec - from HEARTBEAT frame
438 uSec - from HEARTBEAT frame
344 uSec - from HEARTBEAT frame
564 uSec - from HEARTBEAT frame
668 uSec - from HEARTBEAT frame
The scope was setup to record 10 GSamples at 1 MHz. D0 and D2 are connected to the server and D1 and D3 are connected to the client.
The trigger parameters were:
triggerWidth = 10;
triggerWidthIsMultiplier = true;
triggerEnable = 127;
TRIGGER_TRANSACTION_COMPLETE, //14
TRIGGER_CHANNEL_TIMER_ISR, //24
TRIGGER_RX_SYNC_CLOCKS, //34
TRIGGER_TX_SYNC_CLOCKS, //44
TRIGGER_RX_HEARTBEAT, //54
TRIGGER_TX_HEARTBEAT, //64
TRIGGER_SYNC_CHANNEL_TIMER, //74