Correct, this function measures the timer offset to the tile where Ethernet MAC is running. It's 0 if it is the local tile.
The implementation is simply for the MAC side to sample its timer and return the value. You can see this in ethernet_rx_server.xc where the ETHERNET_RX_TILE_TIMER_OFFSET_REQ command is handled.
Timer offset between two L16 devices will depend on the order and timing of their power up.
hi,
i guess, the timer values can be different even if two tiles are built on the same chip.
The chip with two tiles, uses one PLL block wich is reachable from the one switch subsystem. (one pswitch control register we have) but different tiles can start the boot procedure on different clock pulse.
The easiest situation if software reset occures. Becasue of the software reset is relating to only one tile. I dont know if there are other exact reason, but probably could be... (I.e. different codes running if one is booted from flash or xlink. I dont know if the brown out logic is doubled or not, etc... But nevermind... )
The two tile's timer registers values are not the same theoretically, at all.
Rather the delta(timer) values of the same chip are the same, because these are running on the same (I hope) clock. Which is good information for us...
So , two tiles must calculate a common/general time value if it is necessary for the application.
And if two tiles are on the same chip, it is only a mathematical addition, but if these are on a xlink bw defferent devices , they must syncronize its clocks periodically because of the xtal clock drift can be a problem in long runtime ..
In situation a) the problem is not difficult, we have to send a channel message between local tiles once (or rearly). Assume we have a master and a slave tile, the master could use local timer value, the slave will calculate its own, rather than simple read the register. It needs to add the drift of the remote time - message time. Message sending time depends on switch subsystem, we hope it is a constant value... Or somehow we can measure it.
In situation b) there are two problems. The message arrival time can be a variable . And the two different hw clock/pll could add a jitter. (theoretically) This two variable needs to measure by tiles runtime and periodically.
The basic idea is the syncronization have more than one steps. We sends message between tiles, we have a book keeping about the other tiles. The message contains not only the remote time, but we have to send back the arrival timestamp too. It helps on calculation of the message transmitting time (drift bw the sender and arrival). The different clock rates and the message arrival time together can be calculated. (no need to implement a division to your mathematical form) So after that, all of the information is ready for calculating a common time value, which is accessable by the application.
The application still able to use local timestamp, and hw support for it, but it have to calculate by a fn call, which add the actual drift to the global time to get the local time value...
There is some protocol, but I did not tested/seen yet. Practically it would be nice if we have a simple library for this above tasks. :) I think that app notes have to have some soloution for this, which are demonstrates remote audio streams...
In my application, both chips are running off the same 25 MHz clock so there should be no drift between the two parts.
So it is simply a matter of reading the timers off both tiles and getting the difference, allowing for the instruction latency of doing this.
In the avb ptp code, the instruction latency is estimated to be 3 but I have measured it to be in the 10 to 12 range so I am using 11. The only unknown is the latency in setting up the routing between two tiles as I did the latency measurement on a single tile.
If anyone knows what the difference in latency is between sending a packet between two channels ends on a single compared with sending a packet between two channels ends on different tiles (using the router and xlinks), I would appreciate knowing that.