S32K344 Hanging issue

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

S32K344 Hanging issue

711 Views
vinaykl
Contributor III

MCU: S32K344
OS: FreeRTOS
S32 Design Studio: 3.4.3

Issue: MCU Hang Due to I2C Write Blocking (No Timeout)

Hi Team,

We are using a custom board based on the S32K344 MCU. We are facing an issue where the MCU hangs during runtime under certain I2C error conditions.

We have an IMU slave device connected via the I2C interface. Occasionally, when:

  • The IMU is not powered, or
  • An I2C write operation fails (e.g., no ACK / bus stuck),

the I2C write API does not return or enter a timeout state. As a result, the FreeRTOS task performing the I2C transaction gets stuck indefinitely, which eventually causes the application to hang.

Observations:

  • The issue occurs when the slave does not respond or the bus is held low.
  • The I2C driver appears to block waiting for a transfer completion.
  • No timeout or recovery mechanism is triggered at the RTOS or driver level.

Request for Support:

  1. How can we add or enforce a timeout for I2C transactions on S32K344?
  2. Is there a recommended way to recover a stuck I2C bus (SDA/SCL held low)?
  3. What is the best practice for using I2C safely under FreeRTOS on S32K3 devices?
  4. Are there driver configurations or examples from NXP that handle this scenario robustly?

Any guidance or references would be greatly appreciated.

Thanks & Regards,
Vinay

Tags (1)
0 Kudos
Reply
1 Reply

638 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @vinaykl,

 

You have a very old RTD.

Is there a reason for it?

There have been many bugs fixed between RTD 2.0.0 and current RTD 7.0.0.

 

I assume you use the blocking APIs of the I2C driver.

Use the Async transfer API along with GetStatus() and timeout instead.

danielmartynek_0-1770627240529.png

 

If the Slave device keeps holding SDA low, it can be recovered, refer to I2C user manual:

Section 3.1.16 Bus clear

https://www.nxp.com/docs/en/user-guide/UM10204.pdf

 

The RTD drivers do not have APIs for the recovery.

An example is in this AN4803

I2C restore function definition 

https://www.nxp.com/docs/en/application-note/AN4803.pdf

 

Regards,

Daniel

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2304668%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K344%20Hanging%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2304668%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSTRONG%3EMCU%3A%3C%2FSTRONG%3E%20S32K344%3CBR%20%2F%3E%3CSTRONG%3EOS%3A%3C%2FSTRONG%3E%20FreeRTOS%3CBR%20%2F%3E%3CSTRONG%3ES32%20Design%20Studio%3A%3C%2FSTRONG%3E%203.4.3%3C%2FP%3E%3CH3%20id%3D%22toc-hId-2026436660%22%20id%3D%22toc-hId-2026462667%22%20id%3D%22toc-hId-2026462667%22%3EIssue%3A%20MCU%20Hang%20Due%20to%20I2C%20Write%20Blocking%20(No%20Timeout)%3C%2FH3%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3EWe%20are%20using%20a%20%3CSTRONG%3Ecustom%20board%20based%20on%20the%20S32K344%20MCU%3C%2FSTRONG%3E.%20We%20are%20facing%20an%20issue%20where%20the%20%3CSTRONG%3EMCU%20hangs%20during%20runtime%3C%2FSTRONG%3E%20under%20certain%20I2C%20error%20conditions.%3C%2FP%3E%3CP%3EWe%20have%20an%20%3CSTRONG%3EIMU%20slave%20device%20connected%20via%20the%20I2C%20interface%3C%2FSTRONG%3E.%20Occasionally%2C%20when%3A%3C%2FP%3E%3CUL%3E%3CLI%3EThe%20IMU%20is%20%3CSTRONG%3Enot%20powered%3C%2FSTRONG%3E%2C%20or%3C%2FLI%3E%3CLI%3EAn%20%3CSTRONG%3EI2C%20write%20operation%20fails%3C%2FSTRONG%3E%20(e.g.%2C%20no%20ACK%20%2F%20bus%20stuck)%2C%3C%2FLI%3E%3C%2FUL%3E%3CP%3Ethe%20I2C%20write%20API%20%3CSTRONG%3Edoes%20not%20return%20or%20enter%20a%20timeout%20state%3C%2FSTRONG%3E.%20As%20a%20result%2C%20the%20%3CSTRONG%3EFreeRTOS%20task%20performing%20the%20I2C%20transaction%20gets%20stuck%20indefinitely%3C%2FSTRONG%3E%2C%20which%20eventually%20causes%20the%20application%20to%20hang.%3C%2FP%3E%3CH3%20id%3D%22toc-hId-218982197%22%20id%3D%22toc-hId-219008204%22%20id%3D%22toc-hId-219008204%22%3EObservations%3A%3C%2FH3%3E%3CUL%3E%3CLI%3EThe%20issue%20occurs%20when%20the%20slave%20does%20not%20respond%20or%20the%20bus%20is%20held%20low.%3C%2FLI%3E%3CLI%3EThe%20I2C%20driver%20appears%20to%20block%20waiting%20for%20a%20transfer%20completion.%3C%2FLI%3E%3CLI%3ENo%20timeout%20or%20recovery%20mechanism%20is%20triggered%20at%20the%20RTOS%20or%20driver%20level.%3C%2FLI%3E%3C%2FUL%3E%3CH3%20id%3D%22toc-hId--1588472266%22%20id%3D%22toc-hId--1588446259%22%20id%3D%22toc-hId--1588446259%22%3ERequest%20for%20Support%3A%3C%2FH3%3E%3COL%3E%3CLI%3EHow%20can%20we%20%3CSTRONG%3Eadd%20or%20enforce%20a%20timeout%3C%2FSTRONG%3E%20for%20I2C%20transactions%20on%20S32K344%3F%3C%2FLI%3E%3CLI%3EIs%20there%20a%20recommended%20way%20to%20%3CSTRONG%3Erecover%20a%20stuck%20I2C%20bus%3C%2FSTRONG%3E%20(SDA%2FSCL%20held%20low)%3F%3C%2FLI%3E%3CLI%3EWhat%20is%20the%20%3CSTRONG%3Ebest%20practice%20for%20using%20I2C%20safely%20under%20FreeRTOS%3C%2FSTRONG%3E%20on%20S32K3%20devices%3F%3C%2FLI%3E%3CLI%3EAre%20there%20%3CSTRONG%3Edriver%20configurations%20or%20examples%3C%2FSTRONG%3E%20from%20NXP%20that%20handle%20this%20scenario%20robustly%3F%3C%2FLI%3E%3C%2FOL%3E%3CP%3EAny%20guidance%20or%20references%20would%20be%20greatly%20appreciated.%3C%2FP%3E%3CP%3EThanks%20%26amp%3B%20Regards%2C%3CBR%20%2F%3EVinay%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2314475%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K344%20Hanging%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2314475%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%2F201565%22%20target%3D%22_blank%22%3E%40vinaykl%3C%2FA%3E%2C%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EYou%20have%20a%20very%20old%20RTD.%3C%2FP%3E%0A%3CP%3EIs%20there%20a%20reason%20for%20it%3F%3C%2FP%3E%0A%3CP%3EThere%20have%20been%20many%20bugs%20fixed%20between%20RTD%202.0.0%20and%20current%20RTD%207.0.0.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EI%20assume%20you%20use%20the%20blocking%20APIs%20of%20the%20I2C%20driver.%3C%2FP%3E%0A%3CP%3EUse%20the%20Async%20transfer%20API%20along%20with%20GetStatus()%20and%20timeout%20instead.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_0-1770627240529.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_0-1770627240529.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F376059i537AB99EE45C2C86%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22danielmartynek_0-1770627240529.png%22%20alt%3D%22danielmartynek_0-1770627240529.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3EIf%20the%20Slave%20device%20keeps%20holding%20SDA%20low%2C%20it%20can%20be%20recovered%2C%20refer%20to%20I2C%20user%20manual%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3ESection%203.1.16%20Bus%20clear%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CA%20class%3D%22cuf-url%20forceOutputURL%22%20title%3D%22%22%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FUM10204.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%20data-value%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FUM10204.pdf%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fuser-guide%2FUM10204.pdf%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3EThe%20RTD%20drivers%20do%20not%20have%20APIs%20for%20the%20recovery.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3EAn%20example%20is%20in%20this%20AN4803%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22uiOutputText%22%3EI2C%20restore%20function%20definition%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CA%20class%3D%22cuf-url%20forceOutputURL%22%20title%3D%22%22%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN4803.pdf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%20data-value%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN4803.pdf%22%3Ehttps%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN4803.pdf%3C%2FA%3E%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