2016-11-06 07:34 AM
Hello Experts,
I am using stm32L152VBTxA, STM32CubeMX, ST-Link/V2 and System Workbench for STM32.The Issue that I am facing is whenever I am writing a simple LED blinking code and running it using ST-Link/V2 debugger it runs fine but when I am adding more code to it (u8glib) then it either get stuck in Infinite Loop Default_Handler or Hard Fault occurs during clock initialization when I run it but when I step through the code Clock Initialization goes through but later the code goes to infinite loop Default Handler when I try to access GPIO.Please provide some insight on how should I debug this issue or what I am doing wrong? #!stm322016-11-06 12:03 PM
I've gone over Hard Faults here a lot.. Review the advice given before, because it will be applicable here. Ending up in the default handler suggests you're enabling interrupts you aren't handling. Don't do that. If you are using .CPP/C++ remember it mangles function names, and the Vector Table won't link properly.
Is the stack large enough? Is the compiler building for the right target? ie RAM size Use something more effective than a while(1) loop to diagnose where the fault is, or dig into the stacked state. Review the Cortex Technical Reference Manual, or books by Joseph Yiu. Make sure Flash wait states are adequate, consider just letting the system run from the default clock, and not changing it up.