FlexCAN Timestamp support

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FlexCAN Timestamp support

Jump to solution
1,557 Views
anakha
Contributor III

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)
105000
2010600
5025000
10050000
20034470 ( + 65535(overflow) = 100000)
100041200 
200017000
1573 (this fluctuate between 125 and 1000)

 

The baudrate is 500 kbps and FlexCAN runs at 80 Mhz. 

 

  • How can 500 is approximately refers to 1ms?
  • 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?
  • How can I activate HR timestamp as seen at below? I am using RTD 3.0.0 with S32DS 3.5

erinc_0-1720176272844.png

  • Is there a way to change CTRL2?

thanks in advance.

 

0 Kudos
Reply
1 Solution
1,491 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@erinc

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:

Senlent_0-1720519877698.png

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

 

View solution in original post

0 Kudos
Reply
2 Replies
1,492 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@erinc

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:

Senlent_0-1720519877698.png

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

 

0 Kudos
Reply
1,505 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@erinc

I am working on your question.

It will take some time because there are fewer questions about FlexCAN Timestamp.

I need some time to do some testing.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1900154%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFlexCAN%20Timestamp%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1900154%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20try%20to%20calculate%20CAN%20Rx%20message%20period%20by%20using%20timestamp%20but%20it%20is%2016%20bit%20and%20overflow%20for%20higher%20periods.%26nbsp%3B%3C%2FP%3E%3CP%3Efor%20testing%2C%20I%20am%20sending%20single%20CAN%20message%20for%20100%20times%20(to%20check%20fluctuation).%3C%2FP%3E%3CP%3Ethe%20measurements%20are%20like%20below%3A%3C%2FP%3E%3CTABLE%20border%3D%221%22%20width%3D%22100%25%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3ERx%20Period%20(ms)%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3EMeasured%20timestamp%20(average)%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E10%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E5000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E20%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E10600%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E50%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E25000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E100%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E50000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E200%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E34470%20(%20%2B%2065535(overflow)%20%3D%20100000)%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E1000%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E41200%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2250%25%22%3E2000%3C%2FTD%3E%3CTD%20width%3D%2250%25%22%3E17000%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E1%3C%2FTD%3E%3CTD%3E573%20(this%20fluctuate%20between%20125%20and%201000)%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CBR%20%2F%3E%3CP%3EThe%20baudrate%20is%20500%20kbps%20and%20FlexCAN%20runs%20at%2080%20Mhz.%26nbsp%3B%3C%2FP%3E%3CBR%20%2F%3E%3CUL%3E%3CLI%3EHow%20can%20500%20is%20approximately%20refers%20to%201ms%3F%3C%2FLI%3E%3CLI%3EIt%20seems%20there%20is%20a%20correlation%20but%20timestamp%20is%2016bit%20and%20only%20counts%20to%2065535.%20So%2C%20it%20overflows%20at%20200ms%20for%20example.%20How%20can%20I%20understand%20if%20it%20overflows%20and%20how%20many%20times%3F%3C%2FLI%3E%3CLI%3EHow%20can%20I%20activate%20HR%20timestamp%20as%20seen%20at%20below%3F%20I%20am%20using%20RTD%203.0.0%20with%20S32DS%203.5%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22erinc_0-1720176272844.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22erinc_0-1720176272844.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F287284i81C775EAAA9DEAAE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22erinc_0-1720176272844.png%22%20alt%3D%22erinc_0-1720176272844.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3EIs%20there%20a%20way%20to%20change%20CTRL2%3F%3C%2FLI%3E%3C%2FUL%3E%3CP%3Ethanks%20in%20advance.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1904149%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FlexCAN%20Timestamp%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1904149%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40erinc%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EHi%40erinc%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EQ1.How%20can%20500%20is%20approximately%20refers%20to%201ms%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%20think%20you%20have%20misunderstood.%20This%20timestamp%20should%20be%20the%20interval%20between%20the%20start%20or%20end%20of%20each%20frame%2C%20not%20the%20time%20it%20takes%20for%20a%20frame%20to%20be%20transmitted.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSTRONG%3EQ2.It%20seems%20there%20is%20a%20correlation%20but%20timestamp%20is%2016bit%20and%20only%20counts%20to%2065535.%20So%2C%20it%20overflows%20at%20200ms%20for%20example.%20How%20can%20I%20understand%20if%20it%20overflows%20and%20how%20many%20times%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYes%2C%20the%20default%20is%20the%20Free%20running%2016-bit%20timer%2C%20which%20has%20no%20overflow%20flag(i%20didn't%20see)%2C%20but%20you%20can%20set%20CRTL1%5BTSYN%5D%20%3D%201%2C%20so%20that%20the%20timer%20will%20automatically%20reset%20after%20receivied%20Frame.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSTRONG%3EQ3.How%20can%20I%20activate%20HR%20timestamp%20as%20seen%20at%20below%3F%20I%20am%20using%20RTD%203.0.0%20with%20S32DS%203.5%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3Ea.You%20need%20to%20enable%20the%20following%20options%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_0-1720519877698.png%22%20style%3D%22width%3A%20549px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_0-1720519877698.png%22%20style%3D%22width%3A%20549px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F287762iA10FEC771F6AD403%2Fimage-dimensions%2F549x192%3Fv%3Dv2%22%20width%3D%22549%22%20height%3D%22192%22%20role%3D%22button%22%20title%3D%22Senlent_0-1720519877698.png%22%20alt%3D%22Senlent_0-1720519877698.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Eb.%3C%2FSTRONG%3EYou%20need%20to%20configure%20Stm%20for%20HR%20timestamp.(ps%2C%3Ayou%20can%20refer%20to%20%22Stm_Gpt_Example_S32k344%22)%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3Ec.%3C%2FSTRONG%3ERead%20HR%20timestamp%2C%20for%20example%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3Etemp%20%3D%20(uint32)IP_CAN_0-%26gt%3BHR_TIME_STAMP%5Bmb_idx%5D%3B%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAlso%2CYou%20can%20enable%20the%20interrupt%20of%20Stm%20and%20record%20the%20number%20of%20overflows%20of%20Stm%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1903656%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20FlexCAN%20Timestamp%20support%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1903656%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40erinc%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40erinc%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EI%20am%20working%20on%20your%20question.%3C%2FP%3E%0A%3CP%3EIt%20will%20take%20some%20time%20because%20there%20are%20fewer%20questions%20about%20FlexCAN%20Timestamp.%3C%2FP%3E%0A%3CP%3EI%20need%20some%20time%20to%20do%20some%20testing.%3C%2FP%3E%3C%2FLINGO-BODY%3E