Page 1 of 1

CAN message Rx timestamp source

Posted: Mon 9. May 2022, 14:26
by Dominik M.
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!

Re: CAN message Rx timestamp source

Posted: Tue 10. May 2022, 11:31
by P.Steil
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

Re: CAN message Rx timestamp source

Posted: Wed 11. May 2022, 09:37
by Dominik M.
Great thanks a lot!

Re: CAN message Rx timestamp source

Posted: Tue 20. Dec 2022, 06:47
by Foxtrott
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));

Re: CAN message Rx timestamp source

Posted: Tue 20. Dec 2022, 13:51
by PEAK-Support
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;	
};