38.10 Timestamping

The CAN FD Protocol module contains a Time Base Counter (TBC). The TBC is a 32-bit free-running counter that increments on multiples of SYSCLK and rolls over to zero when:
  • TBCPRE[9:0] bits (CxTSCON[9:0]) are used to configure the prescaler for the TBC.
  • Setting TBCEN (CxTSCON[16]) enables the TBC.
  • Clearing TBCEN disables, stops and resets the TBC.
  • The TBC has to be disabled before writing to C1TBC by clearing TBCEN.
  • TEFTSEN (CxTEFCON[5]) has to be set to timestamp messages in the TEF.
  • RXTSEN (CxFIFOCONy[5]) has to be set to timestamp messages in the individual RX FIFO.
  • The application can read C1TBC at any time. Similar to any multibyte counter, the application has to consider that the counter increments and might roll over while reading different bytes of the counter.

All timestamps are 32 bits, allowing timestamps to be used for system time synchronization with high resolution.

A rollover of the TBC will generate an interrupt if TBCIE is set.

Messages can be timestamped either at the beginning of a frame or at the end, depending on the TSEOF bit (C1TSCON[17]). When TSEOF = 0, TSRES (C1TSCON[18]) specifies if FD frames are timestamped at SOF or the “reserved bit”. Table 38-12 specifies the reference points when the timestamping occurs. At the reference point, the value of the TBC (C1TBC) is captured and stored into the message object:
  • Receive Message Object: The TBC value is stored in the RXMSGTSx bits (see Table 38-10).
  • TEF Object: The TBC value is stored in the TXMSGTSx bits (see Table 38-8).
Table 38-12. Reference Point
Frame CAN 2.0 CAN FD
Start of TX Sample point of SOF Sample point of SOF or the bit after FDF
Start of RX Sample point of SOF Sample point of SOF or the bit after FDF
Valid TX No error till end of EOF No error till end of EOF
Valid RX No error till the last, but one bit of EOF No error till the last, but one bit of EOF