Timestamp for massages on CAN BUS - implemented on TC375

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Hi there, 

I wonder if everyone has my same problem or has  resolve it. I implemented on TC375 a CAN communication - I set the can module on TC375 as a receiver one. My aim is to obtain, for every received message, the timestamp of the message itself.

thought to associeted, every time the interrupt routine of received message was triggered, a subroutine which use STM0_TIM0 register, but i have some problems, the number obtained it's not easily understandable.

There are other ways to extract time stamp of messages on CAN bus communication for TC375?

A specific library for example or similar?

0 Likes
1 Solution
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Thank you so much! 

I make a recap in order to verify i really understand:

I initialize the stucture _Ifx_Can_RxMsg, then I do the same with the interrupt 

IfxCan_Node_getDataLengthCode

and in this way i get the time stamp of the arrived message.

I have a question: if i initialize the structure and than every time i call the interrupt of received message i use as and example:

readCanMsg(...);

msgID = rxMsg.messageId;

time_stamp = 

(IfxCan_DataLengthCode)rxBufferElement->R1.B.DLC;

Can I do this, right?

View solution in original post

0 Likes
9 Replies
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

On start of frame reception / transmission the counter value is captured and stored into the timestamp section
of an Rx Buffer / Rx FIFO (RXTS[15:0]) or Tx Event FIFO (TXTS[15:0]) element.

You can check the RX Buffer for timestamp. Do you have any question on this?

0 Likes
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Hi!

thank you so much for the answer. So yes, I have some question about:

I initialize Rx Buffer (or Tx Buffer) during the configuration of MCAN, my question is which command can I use to log into Buffers?

I try to explain myself better:

There is a kind of structure in which I can extract an attribute?

or do I need to use more specific command to log into?

thank you so much for patience 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Please check below struct for R1.

dw_0-1678694898131.png

 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored
IFX_INLINE uint32 IfxCan_Node_getDataLengthCode(Ifx_CAN_RXMSG *rxBufferElement)
{
    return (IfxCan_DataLengthCode)rxBufferElement->R1.B.DLC;
}

Above call is for your reference. You should modify as your request.

0 Likes
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Thank you so much! 

I make a recap in order to verify i really understand:

I initialize the stucture _Ifx_Can_RxMsg, then I do the same with the interrupt 

IfxCan_Node_getDataLengthCode

and in this way i get the time stamp of the arrived message.

I have a question: if i initialize the structure and than every time i call the interrupt of received message i use as and example:

readCanMsg(...);

msgID = rxMsg.messageId;

time_stamp = 

(IfxCan_DataLengthCode)rxBufferElement->R1.B.DLC;

Can I do this, right?

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Hi Sara, Yes you can do this, please note that DLC is not timestamp, you should modify the code.

0 Likes
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Oh, sorry, how silly!

So maybe I didn't get which available variable the time information was stored? 

Referring to my "pseudo code" : time_stamp will be equal to what?

I can't get it 

thank you so much for your patience

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored
typedef struct _Ifx_CAN_R1_Bits
{
    Ifx_UReg_32Bit RXTS:16;           /**< \brief [15:0] Rx Timestamp (rwh) */
    Ifx_UReg_32Bit DLC:4;             /**< \brief [19:16] Data Length Code (rwh) */
    Ifx_UReg_32Bit BRS:1;             /**< \brief [20:20] Bit Rate Switch (rwh) */
    Ifx_UReg_32Bit FDF:1;             /**< \brief [21:21] Frame Data Format (rwh) */
    Ifx_UReg_32Bit reserved_22:2;     /**< \brief [23:22] \internal Reserved */
    Ifx_UReg_32Bit FIDX:7;            /**< \brief [30:24] Filter Index (rwh) */
    Ifx_UReg_32Bit ANMF:1;            /**< \brief [31:31] Accepted Non-matching Frame (rwh) */
} Ifx_CAN_R1_Bits;
Sara_V
Level 2
Level 2
First like received First like given First solution authored

Really thank you! 

Your replay will be extraordinary useful!

0 Likes