S32k3 Hard Fault when using LCU

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

S32k3 Hard Fault when using LCU

Jump to solution
893 Views
AlexCloutier
Contributor I

Hello,

I am trying to use the LCU peripheral on a S32k312 MCU. 

I am using Matlab R2022a, EB Tresos version 29.0.0, NXP MBDToolbox S32k3xx version 1.4.0 and NXP support package S32k3xx version 1.4.0.

I am currently working on an evaluation board (S32k312EVB-Q172) with a slightly modified version of a DIO example provided with the Matlab toolbox (s32k3xx_dio_ebt). The Simulink model has not been modified, but the EB Tresos configuration has to achieve the following function:

Use PTA19 as input -> Route to LCU_0 LCO through TRGMUX IN 13 -> invert the input to output 0 -> route to PTB21 through TRGMUX out 12.

The problem I have is that the MCU ends up in a hard fault handler during initialization of the LCU (see stack trace in attachment when I try to debug the Matlab generated code using S32DS). 

Can anyone point out what I am missing to use the LCU peripheral? I am assuming my configuration is either wrong, or there is something that I am forgetting to configure, but I can't find the problem.

I have attached the whole Matlab folder.

Thank you for your help,

Alex Cloutier

0 Kudos
1 Solution
802 Views
georgevictor
NXP Employee
NXP Employee

Hi, @AlexCloutier,

Thank you for using our S32K3xx toolbox on your projects.

I have looked over your application's configuration project. In the first place, you should check the Mcu and Platform components to configure LCU-related settings.

In Mcu, based on your hardware LCU instance configured in Mcl, enable the peripheral clock:

georgevictor_2-1693895154774.png

In the Platform component, you can find the interrupt section related to the hardware LCU instances. 

georgevictor_3-1693895209991.png

Secondly, the MBDT for S32K3xx generates code based on RTD (Real Time Drivers) MCAL components.  For more details about configuring a specific component, you could check the RTD documentation that is found inside the RTD folder in our toolbox root. 

georgevictor_1-1693894787393.png

Based on my suggestions and the information found in the RTD documentation, please update the configuration project and see if the issue has been solved.

 

Best regards,

Victor

 

View solution in original post

0 Kudos
2 Replies
721 Views
AlexCloutier
Contributor I

Hello Victor,

 

Indeed, the hard fault was caused by the LCU clock not being enabled. Thank you for pointing it out. 

The last missing piece of the puzzle was using the Mcl_SetLcuSyncOutputEnable() function in Matlab to enable the correct outputs.

 

Also, thank you for providing the location of the documentation for the MCAL drivers. I had already found some RTD user manual, but it's the first time I am seeing all of them in the same place, as well as Integration manuals. I'm certain they will prove pretty useful.

 

Best regards, 

Alex Cloutier

0 Kudos
803 Views
georgevictor
NXP Employee
NXP Employee

Hi, @AlexCloutier,

Thank you for using our S32K3xx toolbox on your projects.

I have looked over your application's configuration project. In the first place, you should check the Mcu and Platform components to configure LCU-related settings.

In Mcu, based on your hardware LCU instance configured in Mcl, enable the peripheral clock:

georgevictor_2-1693895154774.png

In the Platform component, you can find the interrupt section related to the hardware LCU instances. 

georgevictor_3-1693895209991.png

Secondly, the MBDT for S32K3xx generates code based on RTD (Real Time Drivers) MCAL components.  For more details about configuring a specific component, you could check the RTD documentation that is found inside the RTD folder in our toolbox root. 

georgevictor_1-1693894787393.png

Based on my suggestions and the information found in the RTD documentation, please update the configuration project and see if the issue has been solved.

 

Best regards,

Victor

 

0 Kudos