imx8mp flexcan hardware timestamp

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

imx8mp flexcan hardware timestamp

191 次查看
AngelF
Contributor III

Hello,

We have our own design based on imx8mp and kernel 6.6.23 from NXP.

We are using both flexcan interfaces and we would like to read hardware timestamp from driver. We are using candump but always read 0

candump -H -L
(0000000000.000000) canfd1 776#94CD03004FC7E1

Do you know how we can enable this feature?

Best regards and thank you

Angel

0 项奖励
回复
3 回复数

171 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

 

The i.MX 8M Plus FlexCAN has a hardware timestamp feature that  uses a free-running 16-bit timer, which increments with each bit interval based on the CAN baud rate and resets on the reception of each CAN frame by default. To get a more accurate timestamp and overcome limitations, you must enable High-Resolution (HR) Timestamp in the FlexCAN Control Register 1. This requires a separate, external timer source, often a System Timer (STM), which you configure to provide a high-resolution time base. 
How it works
 
  • Default 16-bit timer: The FlexCAN module has a built-in 16-bit timer that counts the bit intervals on the CAN bus.
    • This timer wraps around (overflows) after 65535 clock ticks.
    • The time it takes to overflow depends on the CAN bus speed.
    • You can set CRTL1[TSYN] to '1' to automatically reset the timer upon receiving a frame, which is useful for maintaining message order but still subject to the 16-bit limit.
    • High-Resolution (HR) timestamp: To achieve higher precision, you enable the HR timestamp feature by setting the relevant bit in the FlexCAN control register.
      • This disables the internal 16-bit timer for timestamping.
      • It enables the use of an external timer source, such as an STM, for timestamping.
      • You can then read the HR timestamp value from a dedicated register. 
How to enable HR Timestamp
 
  1. Configure the External Timer (STM): Set up the STM to provide a high-resolution time base.
  2. Enable HR Timestamp in FlexCAN: In the FlexCAN controller, enable the HR timestamp feature.
  3. Read the timestamp: Read the HR_TIME_STAMP register to get the high-resolution timestamp

Regards

0 项奖励
回复

145 次查看
kef2
Senior Contributor V
  • Default 16-bit timer: The FlexCAN module has a built-in 16-bit timer that counts the bit intervals on the CAN bus.

And has a nasty feature that every time CAN clock synchronization takes place, this 16-bit timer clock period is affected a bit. Not all of this 16-bit timer periods are equal to bit time. So if you try to use some other on-SoC timer (with clock derived from the same clock parent as CAN clock) to count 16-bit timer overflows to extend the width of timestamp clock, you will need to somehow track the drift of timestamp clock due to CAN receive traffic.

0 项奖励
回复

149 次查看
AngelF
Contributor III

Hello,

Thank you for your response.
We are aware that the HW Flexcan controller in the imx8mp supports this hardware timestamp feature.
Could you please confirm whether the Linux driver provided by NXP in kernel 6.6.23 also supports this feature?

Best regards and thank you

Angel

0 项奖励
回复