Question Regarding LIN Baud Rate Deviation on S32K312

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

Question Regarding LIN Baud Rate Deviation on S32K312

1,653 Views
dongxun
Contributor III

Dear NXP Support Team,    

  I am a developer working with the S32K312 MCU and have a question regarding LIN communication configuration.     When configuring the LIN driver using EB Tresos 28.2 and RTD 4.4.2 for the S32K312, I set the baud rate to 19200 bps. However, during communication testing, CANoe displays the master's actual baud rate as approximately 19530 bps. dongxun_0-1765787307854.png

This represents a deviation of about 1.7% from the configured value, which exceeds the LIN 2.1 specification requirement of less than 0.5% deviation between actual and nominal baud rates.

dongxun_1-1765787331807.png

understand that the actual LPUART baud rate is calculated based on SBR and OSR values. dongxun_2-1765787353268.png

 

dongxun_3-1765787366925.png

 

With my current clock configuration of 30MHz, some calculation deviation is expected. My specific questions are:

  1. Are there recommended methods to minimize this deviation and better align the actual baud rate with the configured value?
  2. Is adjusting the clock frequency the only available solution, or are there other configuration approaches I could consider?

I would greatly appreciate your expert advice on this matter. Thank you for your time and support. Best regards, dongxun

Tags (1)
0 Kudos
Reply
3 Replies

1,623 Views
danielmartynek
NXP TechSupport
NXP TechSupport

HI @dongxun,

You should achieve 19181.6 bps with the following configuration:

OSR: 16
SBR: 92

30MHz / (92 + 17) = 19181.6 bps

Which RTD version are you using? You mentioned the AUTOSAR version, but not the RTD version.
It appears that the generated values for OSR and SBR are incorrect.
Could you confirm whether the LPUART clock reference in the MCU driver is really set to 30 MHz?

 

Regards,

Daniel

0 Kudos
Reply

1,607 Views
dongxun
Contributor III

Hi Daniel,  

    I am using RTD version SW32K3_RTD_4.4_2.0.2_D2211. I am aware that this is a relatively old version, but given the current project progress, switching to a new version is not an easy task.   I have rechecked the clock-related configurations in MCAL. As shown in the attached image, the reason for selecting the above clock configuration is as follows: according to the reference manual, all LPUART instances except LPUART0 should use ALPS_SLOW_CLK. Additionally, my Core_CLOCK is 120 MHz. Following Option B in the chip manual, I configured AIPS_PLAT_CLK and AIPS_SLOW_CLK to 60 MHz and 30 MHz, respectively. Then, LIN references AIPS_SLOW_CLK, which is 30 MHz. I believe this configuration should be correct. However, the current phenomenon indicates that the actual clock frequency is apparently higher than 30 MHz, leading to a higher calculated baud rate.

dongxun_0-1765846296291.png

 

dongxun_1-1765846316145.png

 

Attached are my configuration files for your reference.

Tags (1)
0 Kudos
Reply

1,560 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @dongxun,

The clock signal can be monitored on the CLKOUT pin.
This is the most reliable method to verify that the clock is configured correctly.

Have you tried updating the generated file with the following values?

OSR: 16
SBR: 92

After initializing the LPUART, check the actual register settings and measure the baud rate again.

 

Regards,

Daniel

 

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2262453%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EQuestion%20Regarding%20LIN%20Baud%20Rate%20Deviation%20on%20S32K312%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2262453%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDear%20NXP%20Support%20Team%2C%20%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20I%20am%20a%20developer%20working%20with%20the%20S32K312%20MCU%20and%20have%20a%20question%20regarding%20LIN%20communication%20configuration.%20%26nbsp%3B%20%26nbsp%3B%20When%20configuring%20the%20LIN%20driver%20using%20EB%20Tresos%2028.2%20and%20RTD%204.4.2%20for%20the%20S32K312%2C%20I%20set%20the%20baud%20rate%20to%2019200%20bps.%20However%2C%20during%20communication%20testing%2C%20CANoe%20displays%20the%20master's%20actual%20baud%20rate%20as%20approximately%2019530%20bps.%20%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_0-1765787307854.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_0-1765787307854.png%22%20style%3D%22width%3A%20240px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F369932i37CC8276C72E66FE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_0-1765787307854.png%22%20alt%3D%22dongxun_0-1765787307854.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThis%20represents%20a%20deviation%20of%20about%201.7%25%20from%20the%20configured%20value%2C%20which%20exceeds%20the%20LIN%202.1%20specification%20requirement%20of%20less%20than%200.5%25%20deviation%20between%20actual%20and%20nominal%20baud%20rates.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_1-1765787331807.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_1-1765787331807.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F369933iAF24521ECFAD8886%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_1-1765787331807.png%22%20alt%3D%22dongxun_1-1765787331807.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%26nbsp%3B%3CSPAN%3Eunderstand%20that%20the%20actual%20LPUART%20baud%20rate%20is%20calculated%20based%20on%20SBR%20and%20OSR%20values.%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_2-1765787353268.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_2-1765787353268.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F369934iA84B89DFE4695AE4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_2-1765787353268.png%22%20alt%3D%22dongxun_2-1765787353268.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_3-1765787366925.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_3-1765787366925.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F369935i430A2D764C96F669%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_3-1765787366925.png%22%20alt%3D%22dongxun_3-1765787366925.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EWith%20my%20current%20clock%20configuration%20of%2030MHz%2C%20some%20calculation%20deviation%20is%20expected.%20My%20specific%20questions%20are%3A%3C%2FP%3E%3COL%3E%3CLI%3EAre%20there%20recommended%20methods%20to%20minimize%20this%20deviation%20and%20better%20align%20the%20actual%20baud%20rate%20with%20the%20configured%20value%3F%3C%2FLI%3E%3CLI%3EIs%20adjusting%20the%20clock%20frequency%20the%20only%20available%20solution%2C%20or%20are%20there%20other%20configuration%20approaches%20I%20could%20consider%3F%3C%2FLI%3E%3C%2FOL%3E%3CP%3EI%20would%20greatly%20appreciate%20your%20expert%20advice%20on%20this%20matter.%20Thank%20you%20for%20your%20time%20and%20support.%20Best%20regards%2C%20dongxun%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2263492%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Question%20Regarding%20LIN%20Baud%20Rate%20Deviation%20on%20S32K312%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263492%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247897%22%20target%3D%22_blank%22%3E%40dongxun%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThe%20clock%20signal%20can%20be%20monitored%20on%20the%20CLKOUT%20pin.%3CBR%20%2F%3EThis%20is%20the%20most%20reliable%20method%20to%20verify%20that%20the%20clock%20is%20configured%20correctly.%3C%2FP%3E%0A%3CP%3EHave%20you%20tried%20updating%20the%20generated%20file%20with%20the%20following%20values%3F%3C%2FP%3E%0A%3CP%3EOSR%3A%2016%3CBR%20%2F%3ESBR%3A%2092%3C%2FP%3E%0A%3CP%3EAfter%20initializing%20the%20LPUART%2C%20check%20the%20actual%20register%20settings%20and%20measure%20the%20baud%20rate%20again.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2263135%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Question%20Regarding%20LIN%20Baud%20Rate%20Deviation%20on%20S32K312%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263135%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20Daniel%2C%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%20I%20am%20using%20RTD%20version%20SW32K3_RTD_4.4_2.0.2_D2211.%20I%20am%20aware%20that%20this%20is%20a%20relatively%20old%20version%2C%20but%20given%20the%20current%20project%20progress%2C%20switching%20to%20a%20new%20version%20is%20not%20an%20easy%20task.%20%26nbsp%3B%20I%20have%20rechecked%20the%20clock-related%20configurations%20in%20MCAL.%20As%20shown%20in%20the%20attached%20image%2C%20the%20reason%20for%20selecting%20the%20above%20clock%20configuration%20is%20as%20follows%3A%20according%20to%20the%20reference%20manual%2C%20all%20LPUART%20instances%20except%20LPUART0%20should%20use%20ALPS_SLOW_CLK.%20Additionally%2C%20my%20Core_CLOCK%20is%20120%20MHz.%20Following%20Option%20B%20in%20the%20chip%20manual%2C%20I%20configured%20AIPS_PLAT_CLK%20and%20AIPS_SLOW_CLK%20to%2060%20MHz%20and%2030%20MHz%2C%20respectively.%20Then%2C%20LIN%20references%20AIPS_SLOW_CLK%2C%20which%20is%2030%20MHz.%20I%20believe%20this%20configuration%20should%20be%20correct.%20However%2C%20the%20current%20phenomenon%20indicates%20that%20the%20actual%20clock%20frequency%20is%20apparently%20higher%20than%2030%20MHz%2C%20leading%20to%20a%20higher%20calculated%20baud%20rate.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_0-1765846296291.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_0-1765846296291.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F370100i2DAFF15C12907211%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_0-1765846296291.png%22%20alt%3D%22dongxun_0-1765846296291.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22dongxun_1-1765846316145.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22dongxun_1-1765846316145.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F370101iB1C6D672CA7344AF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22dongxun_1-1765846316145.png%22%20alt%3D%22dongxun_1-1765846316145.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EAttached%20are%20my%20configuration%20files%20for%20your%20reference.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2262905%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Question%20Regarding%20LIN%20Baud%20Rate%20Deviation%20on%20S32K312%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2262905%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHI%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F247897%22%20target%3D%22_blank%22%3E%40dongxun%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EYou%20should%20achieve%2019181.6%E2%80%AFbps%20with%20the%20following%20configuration%3A%3C%2FP%3E%0A%3CP%3EOSR%3A%2016%3CBR%20%2F%3ESBR%3A%2092%3C%2FP%3E%0A%3CP%3E30MHz%20%2F%20(92%20%2B%2017)%20%3D%26nbsp%3B19181.6%26nbsp%3Bbps%3C%2FP%3E%0A%3CP%3EWhich%20RTD%20version%20are%20you%20using%3F%20You%20mentioned%20the%20AUTOSAR%20version%2C%20but%20not%20the%20RTD%20version.%3CBR%20%2F%3EIt%20appears%20that%20the%20generated%20values%20for%20OSR%20and%20SBR%20are%20incorrect.%3CBR%20%2F%3ECould%20you%20confirm%20whether%20the%20LPUART%20clock%20reference%20in%20the%20MCU%20driver%20is%20really%20set%20to%2030%E2%80%AFMHz%3F%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3EDaniel%3C%2FP%3E%3C%2FLINGO-BODY%3E