CAN message Rx timestamp source

Programmable 6-channel router and data logger for CAN and CAN FD with I/O and optional Ethernet interface
Post Reply
Dominik M.
Posts: 14
Joined: Mon 27. Jan 2020, 09:58

CAN message Rx timestamp source

Post by Dominik M. » Mon 9. May 2022, 14:26

Hello PEAK-Systems team,

I would appreciate if you could describe the time and encoding format of the time array / timestamp, which you are using in your examples (can.h) in the RX CAN message struct:

Code: Select all

//! @brief
//! struct for a CAN receive message.
typedef struct {
uint16_t  size;					//!< size of the whole struct
uint16_t  bufftype:12;				//!< type of the BUFFER (CAN_BUFFER_RX_MSG)
uint16_t  hBus:4;

uint32_t  time[2];				//!< timestamp of message <<<<<<<<<<<---- Which format is used? Is this a hardware timer, RTC, etc.???

uint32_t  tag[2];				//!< a tag field for user e.g. object pointer
uint8_t   res1:4;				//!< reserved
uint8_t   dlc:4;					//!< data length code of message
uint8_t   res2;					//!< reserved
uint16_t  msgtype;				//!< type of message, bitfield, see CAN_MSGTYPE_...
uint32_t  id;					//!< identifier of message
union {
	uint8_t   data8[64];			//!< data of message (byte based)
	uint16_t  data16[32];		//!< data of message (half word based)
	uint32_t  data32[16];		//!< data of message (word based)
};
} CANRxMsg_t;
Are these absolute or relative time stamps (relative to what event/source, to device start or RTC, etc.)?
Or are these Systemticks (--> I'm looking for a RX value in Micro- or Milliseconds, which would require some conversions from systicks)?

Thank you!

User avatar
P.Steil
Hardware Development
Hardware Development
Posts: 32
Joined: Fri 14. Jan 2011, 10:27

Re: CAN message Rx timestamp source

Post by P.Steil » Tue 10. May 2022, 11:31

Hello,

the Router starts from power-up and the internal CAN bootloader initializes the hardware and starts the timestamp system for CAN and
the timer from CPU so they run in parallel. Timestamps for CAN come from CAN controller in hardware as microseconds using 64 bits.
So it is an absolute time in micros (since module start but ignoring initialization time).

Regards
--------------------------------------------
PEAK-System HW development Team
support@peak-system.com
phone: +49-6151-8173-20
fax: +49-6151-8173-29
--------------------------------------------

Dominik M.
Posts: 14
Joined: Mon 27. Jan 2020, 09:58

Re: CAN message Rx timestamp source

Post by Dominik M. » Wed 11. May 2022, 09:37

Great thanks a lot!

Foxtrott
Posts: 6
Joined: Mon 28. Sep 2015, 05:24

Re: CAN message Rx timestamp source

Post by Foxtrott » Tue 20. Dec 2022, 06:47

I have a follow-up question regarding this question since I'm also interested in using the hardware timestamp instead of the internal
clock for some calculations.

Is my understanding correct in that the timestamp in microseconds shall be used like this for example:

uint64_t timestamp = (RxMsg.time[0] | (RxMsg.time[1] << 32));

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: CAN message Rx timestamp source

Post by PEAK-Support » Tue 20. Dec 2022, 13:51

Exact. It is a 64 Bit Value that store the time since startup in microseconds.

you could also change the definition to a union:

Code: Select all

union {
        uint32_t  time[2];
	uint64_t  complete_time;	
};
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply