Skip to main content
alok472
Associate
May 18, 2012
Question

WFI in run mode causing Hard Fault

  • May 18, 2012
  • 3 replies
  • 1172 views
Posted on May 18, 2012 at 04:03

hi all,

I want to save power in run mode of mcu (STM32L151)

My timer is running and giving periodic interrupts. My plan is to go to sleep mode when all main loop work is done and then wake up when timer interrupt comes.

strangely, when WFI is called, the mcu goes into hard fault. It does not happen always but quite frequenctly. I see the hardfault when my debugger (Jlink in SWD mode) is connected.

Can this hardfault be because of debugger ?

i have used Sleep mode in other conditions, i dont see any issue...only when doing in main loop...Hardfault comes.Has anyone used entry into SLEEP mode in while(1) loop ?

Thanks for you help 

    This topic has been closed for replies.

    3 replies

    John F.
    Associate III
    May 18, 2012
    Posted on May 18, 2012 at 13:10

    Have you tried     DBGMCU_Config(DBGMCU_SLEEP, ENABLE);    //Keep debugger connection during SLEEP mode?

    DBGMCU_Config() has a long list of possible arguments - check the library documentation.

    alok472
    alok472Author
    Associate
    May 18, 2012
    Posted on May 18, 2012 at 13:38

    Hi John ..yes, i have enabled the DBGMCU_Config(DBGMCU_SLEEP, ENABLE); 

    Also the RCC for PWR is enabled

    RCC_APB1PeriphClockCmd (RCC_APB1Periph_PWR, ENABLE); 

    John F.
    Associate III
    May 21, 2012
    Posted on May 21, 2012 at 09:37

    You may already know Joseph Yiu's hard fault handler. More info at

    http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/

    Maybe that will help you track down the problem?