Read the current time
The White Rabbit PTP Core includes a PPS generating device at address 0x20300. That device has these registers:
PACKED struct PPSG_WB {
/* [0x0]: REG Control Register */
uint32_t CR;
/* [0x4]: REG Nanosecond counter register */
uint32_t CNTR_NSEC;
/* [0x8]: REG UTC Counter register (least-significant part) */
uint32_t CNTR_UTCLO;
/* [0xc]: REG UTC Counter register (most-significant part) */
uint32_t CNTR_UTCHI;
/* [0x10]: REG Nanosecond adjustment register */
uint32_t ADJ_NSEC;
/* [0x14]: REG UTC Adjustment register (least-significant part) */
uint32_t ADJ_UTCLO;
/* [0x18]: REG UTC Adjustment register (most-significant part) */
uint32_t ADJ_UTCHI;
/* [0x1c]: REG External sync control register */
uint32_t ESCR;
};
The current time is found in CNTR_UTCHI, CNTR_UTCLO, and CNTR_NSEC. Be warned that CNTR_NSEC actually counts in 8ns units despite its name. The current time is thus CNTR_UTCHI*2^32 + CNTR_UTCLO seconds since 1970 and CNTR_NSEC*8 nanoseconds.
To access the device, you will need to know it's Etherbone address:
- SCU accessed from the ComExpress board (read how to Setup-an-SCU-Bootstick), the address is dev/pcie_wb0.
- SPEC accessed from a host system (read how to Configure-a-SPEC-host), the address is dev/spec_wb0.
- VETAR accessed from a hot system TO BE DONE.
For a FEC accessed from the data master, you form the address as udp/IP where IP is the BOOTP address assigned when you Configure-a-Data-Master.
A shell script is available (see Building-from-Sources) to simplify reading the date:
terpstra@belapc060:~/gsi-timing-starter-kit$ ./scripts/get-time.sh udp/10.0.0.1
4927.219493104 = 1970-01-01 02:22:07.219493104