2017-03-30 08:19 AM
Hello, I have a STM32F334 on which I use the HRTIM1 in a SEPIC converter.
The PWM section works the way I want it to, but now I want the system to stop in case of a Hardfault. But for some reason I can't get this to work.
I have set the LOCKUP_LOCK bit in the SYSCFG_CFGR2 register, (as per 10.1.7, page 169 in RM0364)
I have set the Fault state of the particular output to inactive.
I have enabled Fault 1 in Timer Fault Register, on the external input, and confirmed that this works.
After that I performed a division by zero, to force a hardfault, and this did indeed trigger the hardfault exception. But the PWM itself stays active.
So I wonder what is going wrong:
I hope someone can help,
Peter
2017-03-30 03:09 PM
I don't use the 'F3xx but I believe that the problem is that you did not cause a Lockup, nor even a Hard Fault. Division by zero causes a Usage Fault. I believe you don't have implemented separate handlers for the individual Faults. You can also examine the fault status registers (SCB_CFSR and SCB_HFSR) to find out what is the fault reason and what fault is it currently.
Hard Fault is a result of fault escalation, i.e. when one of the 'regular' fault occurs and then another fault occurs while executing the exception handler (there are a few reasons to enter Hard Fault directly, too). Lockup is another (and final) level of escalation, when the processor executes an infinite loop from 0xFFFFFFFE (or 0xFFFFFFFF). You should read ARM® v7-M Architecture Reference Manual, mainly B1.5.15 Unrecoverable exception cases .
Note, that debugger *may* bring out processor from lockup.
JW
2017-03-31 04:31 AM
Thanks for your reply,
I'm still a bit confused though, because I definitely see a the HardFault_Handler invoked, and not the UsageFault_Handler.
But I can understand (and even appreciate) that the divide by zero is not enough to cause lockup. So for now I'll just assume that it's going to work fine.
But if anyone knows of a simple way to enforce a Lockup, that would be hightly appreciated.
Peter