736
Chapter 19
CAN Controller (CAN)
Preliminary User’s Manual U17566EE1V2UM00
19.15 Time Stamp Function
CAN is an asynchronous, serial protocol. All nodes connected to the CAN bus
have a local, autonomous clock. As a consequence, the clocks of the nodes
have no relation (i.e., the clocks are asynchronous and may even have
different frequencies).
In some applications, however, a common time base over the network
(= global time base) is needed. In order to build up a global time base, a time
stamp function is used. The essential mechanism of a time stamp function is
the capture of timer values triggered by signals on the CAN bus.
19.15.1
Time stamp function
The CAN Controller supports the capturing of timer values triggered by
successful reception of a data frame. An on-chip 16-bit capture timer unit in a
microcontroller system is used in addition to the CAN Controller. The 16-bit
capture timer unit captures the timer value according to a trigger signal
(TSOUT) for capturing that is output when a data frame is received from the
CAN Controller. The CPU can retrieve the time of occurrence of the capture
event, i.e., the time stamp of the message received from the CAN bus, by
reading the captured value. The TSOUT signal can be selected from the
following two event sources and is specified by the CnTS.TSSEL bit.
• SOF event (start of frame)
(TSSEL bit = 0)
• EOF event (last bit of end of frame)
(TSSEL bit = 1)
The TSOUT signal is enabled by setting the CnTS.TSEN bit to 1.
Figure 19-33
Timing diagram of capture signal TSOUT
The TSOUT signal toggles its level upon occurrence of the selected event
during data frame reception (in
Figure 19-33
, the SOF is used as the trigger
event source). To capture a timer value by using the TSOUT signal, the capture
timer unit must detect the capture signal at both the rising edge and falling
edge.
This time stamp function is controlled by the CnTS.TSLOCK bit. When the
TSLOCK bit is cleared to 0, the TSOUT signal toggles upon occurrence of the
selected event. If the TSLOCK bit is set to 1, the TSOUT signal toggles upon
occurrence of the selected event, but the toggle is stopped as the TSEN bit is
automatically cleared to 0 when a data frame is received and stored in
message buffer 0. This suppresses the subsequent toggle occurrence by the
TSOUT signal, so that the time stamp value toggled last (= captured last) can
be saved as the time stamp value of the time at which the data frame was
received in message buffer 0.
t
TSOUT
SOF
SOF
SOF
SOF
electronic components distributor