2012-05-17 07:03 PM
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 help2012-05-18 04:10 AM
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.2012-05-18 04:38 AM
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);2012-05-21 12:37 AM
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?