4.5.3 Event Capture

The event capture unit can simultaneously monitor up to 4 sources and capture the wallclock time at which the configured event occurs. Each event has its own configuration register. To enable efficient use of SPI bandwidth, all resulting status and timestamps are available in a group of sequentially accessed registers. This allows for use of the autoincrement feature to burst read all of the required registers.

The Event Capture 0 Control Register (EC0CTRL) determines the input source for the event, the desired signal edge and the maximum number of timestamps that can be stored before overflow; these parameters can only be changed while the time stamper is disabled. This register is used to start and stop the time stamper, as can also be used to reset a time stamper without completely stopping it. The other capture units have their own control registers (EC1CTRL, EC2CTRL and EC3CTRL).

The common registers indicate the status of all of the event capture units. A read of the Event Capture Read Status Register (ECRDSTS) will report the number of valid timestamps stored and any overflow conditions; but it will also update all of the event capture registers that follow. These following registers will hold their values until the next time ECRDSTS is read. This enables a consistent view of the timestamps across many SPI clock cycles. All time stampers will continue to capture new time stamps as long as there is storage available even though these interface registers are not updated.

After the ECRDSTS, the next register is Event Capture Total Counts Register (ECTOT). This contains an 8‑bit running count of the number of captured timestamps. These values roll over from 255 to 0.

The next three registers, Event Capture Clock Seconds High (ECCLKSH), Event Capture Clock Seconds Low (ECCLKSL), and Event Capture Clock Nanoseconds (ECLKNS), together contain the clock time stored in the MAC Timestamp Unit. In a IEEE 802.1AS, or similar, synchronized system, this clock will be synchronized to the network clock. The value is captured at the time ECRDSTS is read, and is stored with 48 bits for seconds and 30 bits for nanoseconds. This value can be combined with the captured time stamps below to determine the exact network time for any particular time stamp.

There are 16 total timestamp storage registers available; an active event capture unit shall use at least one, and the total configured by use for all four units shall not exceed 16. For event capture unit n, these are configured using the MAX field of the Event Capture n Control (ECnCTRL) register. The registers occupied by event capture unit 0, if used, will start with ECRDTS0, then those used by unit 1 and so on. Figure 4-7 illustrates an example where event capture unit 0 is configured to use two registers, while unit 1 will use 10 registers and unit 3 will use three registers. Unit 2 has no registers and therefore shall never be enabled. To avoid loss of data in this shared resource, the MAX field of any ECnCTRL register should only be changed if all time stampers are disabled.

Figure 4-7. Allocation of Event Capture Read Timestamp Registers

When reading out this memory space, the MAX field of ECnCTRL contains the number of registers used for event capture unit n, while the ECnCT field of ECRDSTS contains the actual number of valid time stamps currently stored for that unit. If a given event capture unit has more than one read register in use, the oldest timestamp will be at the lowest address. Any registers that do not contain valid timestamps will contain the value 0xFFFF_FFFF. An example is shown in Figure 4-8, where unit 0 has a maximum of two timestamps, unit 2 has a maximum of four timestamps and unit 3 can have up to three timestamps. When ECRDSTS was read, it indicated a count of 1 timestamp for unit 0, so ECRDTS0 contains a timestamp and ECRDTS1 contains 0xFFFF_FFFF. There are 2 timestamps from unit 2, so the oldest is in ECRDTS2 and the newer one is in ECRDTS3, with 2 invalid registers following. There are 3 timestamps from unit 3, which use register ECRDTS6‑8, with the oldest in ECRDTS8. If one more timestamp is captured before EDRDTS6 is read, there will be an overflow condition and the new timestamp will not be saved.

Figure 4-8. Reading Timestamps from TImestamp Registers

When capture unit 0 captures a timestamp and has data available, the Event Capture 0 Data Available (EC0DA) bit in the Synchronization Event Status Register (SEVSTS), will be set. Should unit 0 be unable to save a timestamp due to an overflow, it will set the Event Capture 0 Overflow (EC0OF) bit in SEVSTS. There are Event Capture Data Available and Overflow bits for each of the other capture units also located in the SEVSTS register.