RA4M1 CAN timestamp register overflow management

Hello all,

I would like to ask if there is a way to tell when the timestamp register of the CAN0 overflows.

I couldn't find any bit that would tell me that there was an overflow and so if the CAN timestamp timer overflows it can cause problems.

Here is my example for my case:

I open the CAN for communication (if I understand correctly the timer starts at this time). This is ok as the absolute value since the start would be perfect for timestamping the data.

Then there are CAN msg-es incoming which all receive their timestamps when they are arriveing. This is good as it is hardware close so it is as accurate as it can get.

When the overflow happens to my knowledge there is nothing that would indicate that, so I can't make a correction when it happens. This is where my problems begin.

If I would try to compare the timestamps value (see if the next one is lower than the one before) I would be able to tell if the overflow happend (or not).

This would be a way to handle the problem however here is also a possibility that it does not get detected if the timestamp timer reaches a higher number than the previous frames timestamp.

(lets say there was a message received at 32000 and then the next message comes after 66000 cycles of the timer which means the timestamp of the 2nd message now shows 32 465. The overflow happened but it didn't get detected and so I cant handle it.)

Is there a way to handle the timestamp timer in a way so that I can tell if the overflow happened and I need to manage that?

Or is there a "suggested" way on how the CAN communication should be handled in cases like mine where the time frame of when messages need to be received is larger than the timers time frame?

Thanks for the help and best regards!

  • Hello,

    You are right, there is no mechanism to notify the system when the time stamp counter overflows. 

    However the counter is not running in all modes, but only in operating mode. The time stamp counter stops in CAN sleep mode and CAN halt mode, and is initialized in CAN reset mode.

    To get notified you can implement another timer that can notify the system. An idea would be to create a free-running AGT or GPT 16-bit counter which will generate interrupts on each overflow.

    Alternatively, the time stamp counter can also be manually reset with TSRC bit of Control Register so you can reset it on certain time interval to keep track of the events.

    I hope it helps somehow.


  • Hi,

    Thank you for your reply!

    The thing is that we need an always running timer from the moment CAN is opened because we want to see the time between the messages arriving and the arriveal of the messages can be non-consistent and longer then the time the CAN timer can cover.

    We took the use another GPT approach on the issue, but I hoped that I overlooked something and there was a way to use just the built in CAN timer for this task.

    Best regards.