Hi,
I try to calculate CAN Rx message period by using timestamp but it is 16 bit and overflow for higher periods.
for testing, I am sending single CAN message for 100 times (to check fluctuation).
the measurements are like below:
Rx Period (ms) | Measured timestamp (average) |
10 | 5000 |
20 | 10600 |
50 | 25000 |
100 | 50000 |
200 | 34470 ( + 65535(overflow) = 100000) |
1000 | 41200 |
2000 | 17000 |
1 | 573 (this fluctuate between 125 and 1000) |
The baudrate is 500 kbps and FlexCAN runs at 80 Mhz.
thanks in advance.
已解决! 转到解答。
Q1.How can 500 is approximately refers to 1ms?
I think you have misunderstood. This timestamp should be the interval between the start or end of each frame, not the time it takes for a frame to be transmitted.
Q2.It seems there is a correlation but timestamp is 16bit and only counts to 65535. So, it overflows at 200ms for example. How can I understand if it overflows and how many times?
Yes, the default is the Free running 16-bit timer, which has no overflow flag(i didn't see), but you can set CRTL1[TSYN] = 1, so that the timer will automatically reset after receivied Frame.
Q3.How can I activate HR timestamp as seen at below? I am using RTD 3.0.0 with S32DS 3.5
a.You need to enable the following options:
b.You need to configure Stm for HR timestamp.(ps,:you can refer to "Stm_Gpt_Example_S32k344")
c.Read HR timestamp, for example:
temp = (uint32)IP_CAN_0->HR_TIME_STAMP[mb_idx];
Also,You can enable the interrupt of Stm and record the number of overflows of Stm
Q1.How can 500 is approximately refers to 1ms?
I think you have misunderstood. This timestamp should be the interval between the start or end of each frame, not the time it takes for a frame to be transmitted.
Q2.It seems there is a correlation but timestamp is 16bit and only counts to 65535. So, it overflows at 200ms for example. How can I understand if it overflows and how many times?
Yes, the default is the Free running 16-bit timer, which has no overflow flag(i didn't see), but you can set CRTL1[TSYN] = 1, so that the timer will automatically reset after receivied Frame.
Q3.How can I activate HR timestamp as seen at below? I am using RTD 3.0.0 with S32DS 3.5
a.You need to enable the following options:
b.You need to configure Stm for HR timestamp.(ps,:you can refer to "Stm_Gpt_Example_S32k344")
c.Read HR timestamp, for example:
temp = (uint32)IP_CAN_0->HR_TIME_STAMP[mb_idx];
Also,You can enable the interrupt of Stm and record the number of overflows of Stm