Programmable 6-channel router and data logger for CAN and CAN FD with I/O and optional Ethernet interface
-
Dominik M.
- Posts: 14
- Joined: Mon 27. Jan 2020, 09:58
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!
-
P.Steil
- Hardware Development

- Posts: 32
- Joined: Fri 14. Jan 2011, 10:27
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
--------------------------------------------
-
Foxtrott
- Posts: 6
- Joined: Mon 28. Sep 2015, 05:24
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));
-
PEAK-Support
- Sales & Support

- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
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
-------------------------------