MCU restarting when controlling a motor

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

MCU restarting when controlling a motor

1,066 Views
elb1
Contributor III

Hello, i am using s32k142 microcontroller, and when i am controlling a motor (pwm, direction) the applicxation will be restarted all the time, and when i have seen the RCM register to know the reason for reset, LOCKUP bit is set, but what can be the cause for this 
Thank you in advance.

0 Kudos
10 Replies

924 Views
elb1
Contributor III

Hello Daniel, 
Now it goes to one of the handlers, and it is actually going to "HardFault_Handler", but there is no much information about it in the link you sent me, do you have any idea what "HardFault_Handler" means, or what can be the problem ?
Thank you

0 Kudos

906 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @elb1,

This is explained in the document, and the example handles hard faults too:

https://community.nxp.com/t5/S32K-Knowledge-Base/Fault-handling-on-S32K14x/ta-p/1114447

 

BR, Daniel

0 Kudos

1,044 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello @elb1,

When the core detects a fault exception, it fetches the HardFault_Hander().

The exception is then escalated to Core Lockup if the core detects another exception during the fetching.

Therefore I would say there is no HardFault_Hander() in the project.

Refer to this document/example, you should be able to find the exception that causes the fault.

https://community.nxp.com/t5/S32K-Knowledge-Base/Fault-handling-on-S32K14x/ta-p/1114447

 

Regards,

Daniel

0 Kudos

1,038 Views
elb1
Contributor III

Hello Daniel, Thank you for your response.
I have added those fault_exception files and it worked fine the microcontroller is not reset and also the control of the motor is working perfectly.
But the problem is that i didn't do anything except adding handlers, so is the problem still there ? or i don't know, i have also put break points in all those handlers but it didn't went to anyone of them

Thank you

0 Kudos

1,033 Views
elb1
Contributor III

Hello, more updates:
it was working only when i have put application only (in debug mode), but when flashed it with bootloader i got again the same behavior, the mcu is restarting and the reason again is LOCKUP, it also didn't stop in any of the handlers, it will be stopped somewhere in
No source available for "0x7bcce0e6" 

0 Kudos

1,005 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @elb1,

ARM documentation states:

"The processor enters a lockup state if a fault occurs when executing the NMI or HardFault handlers."

https://developer.arm.com/documentation/dui0646/c/The-Cortex-M7-Processor/Fault-handling/Lockup?lang...

It could be because the HardFault vector is not implemented, therefore, I recommended adding it to the project.

Regarding the bootloader, please make sure the VTOR address is correctly changed to the vector table of the application. And read the HardFault vector in the memory view to ensure it has the pointer to the handler.

 

Regards,

Daniel

 

0 Kudos

999 Views
elb1
Contributor III

Hello Daniel, thank you for your response,
The thing is even when i divide for example by zero, to see if one of the handlers will be triggered but nothing, i think i am not testing as i should. I also tested with example project that you have provided you take a look at my response, i have put a comment there. 

https://community.nxp.com/t5/S32K-Knowledge-Base/Fault-handling-on-S32K14x/ta-p/1114447 

Thank you so much, i appreciate your help

0 Kudos

967 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @elb1,

I just replied to your comment there.

Can you test the division by 0 in a new empty project?

Don't forget to enable the division by 0 trap.

 

Can you attach your project here so that I can test it?

 

BR, Daniel

0 Kudos

961 Views
elb1
Contributor III

Hi, yes i have enabled the division by 0 trap
I  actually have tested in hello_world project, and it is going to the "UsageFault_Handler".
It's really strange in my project it doesn't, do you have any idea why?
Ps.I am using an RTOS operating system in my project, but even if i didn't started nor initializing any task, it still doesn't go to the handler.
Thank you

0 Kudos

946 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Are the handlers define in the startup_S32K142.S file

Have you checked the vector table in the flash?

Does it point to the handlers?

Can you share the project?

 

Regards,

Daniel

0 Kudos