timestamp

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

timestamp

跳至解决方案
791 次查看
jury
Contributor I

Hi,

I want to implement clock synchronization on the CAN bus.

How to get the ns-level timestamp on S32K148? Is there any reference demo and documentation?

Thank you in advance
jury

0 项奖励
1 解答
745 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

timestamp is part of MB's word0

PetrS_0-1690445124573.png

so simply read it from there. Below code is for RX MB

PetrS_0-1690445248715.png

BR, Petr

在原帖中查看解决方案

0 项奖励
6 回复数
778 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

this is most probably not possible. Read chapters 55.5.2.4 Free Running Timer (TIMER) and 55.3.10.6 Time stamp of the device RM.

The value of the free running timer is sampled at the beginning of the Identifier field on the CAN bus, and is stored at the end of move-in in the TIME STAMP field, providing network behavior with respect to time.
When CTRL2[TIMER_SRC] is asserted, the free running timer is continuously clocked by an external time tick, On S32K148 LPIT channel 0 trigger output acts as external time tick source for FlexCAN0. FlexCAN1/2 does not support external time tick.
When CTRL2[TIMER_SRC] is negated, the free running timer is clocked by the FlexCAN bit-clock, which defines the baud rate on the CAN bus. During a message transmission/reception, it increments by one for each bit that is received or transmitted. When there is no message on the bus, it counts using the previously programmed baud rate.

BR, Petr

0 项奖励
767 次查看
jury
Contributor I
Thank you for your reply!

Where can I see the document you mentioned? Chapters 55.5.2.4 Free Running Timer (TIMER) and 55.3.10.6 Time stamp of the device RM.

I've seen flexcan's documentation mention that each message buffer has two bytes dedicated to storing timestamps. Maybe I should read it out and see. (flexcan0)
0 项奖励
759 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

 it is device Reference Manual; https://www.nxp.com/webapp/Download?colCode=S32K1XXRM
In rev 13  it is chapters 55.5.9.6 and 55.4.2.4

BR, Petr

0 项奖励
755 次查看
jury
Contributor I
thank you petr,
I read the section you said and also looked at the flexcan code, which has such a macro definition
#define CAN_CS_TIME_STAMP_MASK 0xFFFFu
#define CAN_CS_TIME_STAMP_SHIFT 0
#define CAN_CS_TIME_STAMP_WIDTH 16

How do I get this timestamp? Can you give me a code to refer to?
0 项奖励
746 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

timestamp is part of MB's word0

PetrS_0-1690445124573.png

so simply read it from there. Below code is for RX MB

PetrS_0-1690445248715.png

BR, Petr

0 项奖励
728 次查看
jury
Contributor I

Thank you for your patient reply. I have solved the problem.

Jury.

0 项奖励