From 80a9357b6f6fff59949677de50d72130639cf862 Mon Sep 17 00:00:00 2001 From: Aleksandr Vyhovanec Date: Tue, 17 May 2016 06:45:00 -0600 Subject: [PATCH] wfi.mac should be copied into the directory with the IAR project. Then set it to "Options -> Debugger -> Setup macro file(s)". This will allow debugging via JTAG when calling the WFI instruction. --- configs/stm3220g-eval/ide/nsh/iar/wfi.mac | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 configs/stm3220g-eval/ide/nsh/iar/wfi.mac diff --git a/configs/stm3220g-eval/ide/nsh/iar/wfi.mac b/configs/stm3220g-eval/ide/nsh/iar/wfi.mac new file mode 100644 index 0000000000..f063baac72 --- /dev/null +++ b/configs/stm3220g-eval/ide/nsh/iar/wfi.mac @@ -0,0 +1,24 @@ +/* + * Debug support for low-power modes + * To enter low-power mode, the instruction WFI or WFE must be executed. + * The MCU implements several low-power modes which can either deactivate the CPU clock + * or reduce the power of the CPU. + * The core does not allow FCLK or HCLK to be turned off during a debug session. As these + * are required for the debugger connection, during a debug, they must remain active. The + * MCU integrates special means to allow the user to debug software in low-power modes. + * For this, the debugger host must first set some debug configuration registers to change the + * low-power mode behavior: + * In Sleep mode, DBG_SLEEP bit of DBGMCU_CR register must be previously set by + * the debugger. This will feed HCLK with the same clock that is provided to FCLK + * (system clock previously configured by the software). + * In Stop mode, the bit DBG_STOP must be previously set by the debugger. This will + * enable the internal RC oscillator clock to feed FCLK and HCLK in STOP mode. + */ + +execUserExecutionStarted() +{ + if (!__driverType("sim")) + { + __writeMemory32(__readMemory32(0xE0042004, "Memory") | 0x3, 0xE0042004, "Memory"); // Set DBG_SLEEP and DBG_STOP in DBGMCU_CR + } +} \ No newline at end of file