Skip to main content
Andrew Hazelton
Associate III
October 11, 2017
Question

Hard Fault with ''STemWin_HelloWorld'' Example.

  • October 11, 2017
  • 7 replies
  • 1376 views
Posted on October 11, 2017 at 04:05

Compiler:           IAR Workbench v8.11.3

Graphics:           STemWin

Hardware:          STM32746G Discovery Board

HAL Version:     V1.8.0

Demo Project:   C:\STM32Cube_FW_F7_V1.8.0\Projects\STM32746G-Discovery\Applications\STemWin\STemWin_HelloWorld

Problem:

I have created a simple project based on the “STemWin_HelloWorld� example for the STM32746G Discovery Board. I have created two screens with a button on each. The button on each screen loads the other screen, and visa-versa. If you switch back and forth the screens a couple of times the program gets stuck in the “void HardFault_Handler(void)� routine.

From the viewing, the System Control Block Registers with the debugger I can see that the following bits are set.

BusFault Status register

BFSR -> BFARVALID

BFSR -> IMPRECISERR

UsageFault Status register

UFSR -> UNALIGNED

UFSR -> UNDEFINSTR

Different combinations of these bits are set each time you reset the MCU. From reading the manual it appears that a bad instruction is causing the fault but I am unable to narrow down as to where. Can anyone please assist in stopping the program going into the “void HardFault_Handler(void)â€� routine?

Please un-zip the attached project into the below directory:

C:\STM32Cube_FW_F7_V1.8.0\Projects\STM32746G-Discovery\Applications\STemWin\

    This topic has been closed for replies.

    7 replies

    Tesla DeLorean
    Guru
    October 11, 2017
    Posted on October 11, 2017 at 04:43

    Try using a reasonable Hard Fault Handler and review the faulting instructions and registers. Disassembly view.

    Is the stack sufficiently large? Are you corrupting structures on the stack? Review your use of local/auto variables.

    If it tries to execute 32-bit ARM code it will fault.

    https://community.st.com/0D50X00009XkfOXSAZ

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Andrew Hazelton
    Associate III
    October 11, 2017
    Posted on October 11, 2017 at 05:23

     ,

     ,

    Thank you Clive One.

    How do I increase the stack size? Is there a header file with a ♯ define to change?

    I can already see the register values from my debugger. But how do I interpret this?

    0690X00000608YZQAY.png
    bbee
    Senior
    October 11, 2017
    Posted on October 11, 2017 at 12:29

    To change the stack size in IAR IDE:

    Project->Options->Linker->Config Tab and Edit Linker configuration file.