Exception handler examples

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I have noticed the "startup_XMC4500.s" file contains Exception Handler definitions that can be overridden by the users own exception handlers.

During code development my code has occasionally jumped to one of the default exception handlers.

I would like to flag exception events and then if safe to do so continue with normal code execution.

Are there any example exception handlers available ?

Any advice would be greatly appreciated.

Best regards
Aaron
0 Likes
10 Replies
Not applicable
Hi Aaron,

I think the 1st thing you need to do is to check why your code occasionally jumped to default exception handler?
Some of the default exception interrupts happen when there are faults in either bus or memory or etc. The processor enters a lockup state if a fault occurs when executing the NMI or HardFault handlers. When the processor is in lockup state it does not execute any instructions.

Best regards,
Zain
0 Likes
Not applicable
Hi Zain,

Thanks for your fast reply. I agree about checking why an exception occurs first. Unfortunately they occur very rarely (e.g. once a day) so getting to the root cause is going to take some time.

The exception I have is generated by the USBVC001 app which is not the most stable and I have little control over it. I really don't need a comms error causing the processor to hang. Maybe I can disable the exception ?

Because my application controls mechanical actuators, having the processor lock up can cause damage. Maybe I need to look into a watchdog too.

Thanks as usual.

Best regards
Aaron
0 Likes
Not applicable
Hi Aaron,

Could you pls provide some more details on the exception occurrence? For example, does it happen in debug mode? If not, how do you know it happens? If it is really a issue from USBVC001 App, we would like to feedback to the responsible person. Thanks.

Best regards,
Sophia
0 Likes
Not applicable
Hi Sophia,

Yes it happens in Debug mode when running under DAVE / Tasking. My code jumps to the line "Insert_ExceptionHandler USB0_0_IRQHandler" in the file "startup_XMC4500.s".

Do you need any other info ?

Best regards
Aaron
0 Likes
Not applicable
Hi Aaron,

This "ExceptionHandler USB0_0_IRQHandler" is referring to "void USB0_0_IRQHandler()" defined in usbcore001.c. It is correct behaviour. You should not worry:)

Best regards,
Sophia
0 Likes
Not applicable
Hi Sophia,

Thank you for the information.

Best regards
Aaron
0 Likes
Not applicable
Hello,

Sometimes a HardFault_Handler occurs when reloading a txt-file from my webpage from the XMC-webserver. The following output is delivered from the Disassembly window.
Can anyone explain how to search the reason of the fault?

Insert_ExceptionHandler HardFault_Handler
0x080002de 00 b5 push {lr}
0x080002e0 81 b0 sub sp, #0x4
0x080002e2 80 47 blx r0
0x080002e4 01 b0 add sp, #0x4
0x080002e6 00 bd pop {pc}


Thanks in advance.
0 Likes
Not applicable
Hi Martin,

Would you be able to provide more details? For example, is it an example project? what kind of Apps used? when it happens? is it in debug mode? etc.

Best regards,
Sophia
0 Likes
Not applicable
Hello Sophia,
thanks for your quick response.
My project consists of the Apps displayed in the attached image. I started a new project and added and configured all these apps manually.
476.attach

The error happens in debug mode but also in the "free run". XMC stopps working often (but not in every case) if I try to refresh a txt-file from the website. Maybe the generation of this txt-file is still in progress as I try to refresh it?! I write some dynamic variables via fprintf into that txt-file.

If you need any other information, don't hesitate to ask.

Thanks, Martin.
0 Likes
Not applicable
Hi Martin,

Would you mind to share your project so that I can forward it to someone who may be able to help to do analysis?

Best regards,
Sophia
0 Likes