cancel
Showing results for 
Search instead for 
Did you mean: 

WFI() issue using Nucleo STM32G031K8 and uVision.

DRH
Associate III

Hi together,

I’m trying to start a new project using STM32G031. The final decision of the MCU isn’t made yet and therefore I’m currently testing the possibilities with the Nucleo STM32G031K8 board. I’m using the onboards USB debug interface. 

I start a new Keil uVision project and everything work as expected until I add WFI() at the end of my main loop. After adding it, I start a debug session and everything is fine. But after leaving this first debug session and trying to start it second one again, I got the error message “Invalid ROM table�?.

From that point it’s not possible to debug or even flash the MCU using uVision. I have to copy a hex file (strange that it’s the same source) using the storage bootloader and after that it’s possible to start a new debug session. Unfortunately with the same result, that after leaving it and trying to debug again, I got this error message.

I’m checked all ideas and tips I found here, check different “Connect and Reset Options�? because this looks to solve the “Invalid ROM table�? error for some other users, but had no success.

All programs and interfaces are updated to the current version. Currently I’m reading about DBGMCU_CR register options but I’m not using standby or stop mode so I don’t think this will change the situation. At the moment, this register is in init state.

A second strange thing is, that the same situation occurs if I use an example software provided by ST. If I use

STM32Cube_FW_G0_V1.4.0\Projects\NUCLEO-G031K8\Examples_LL\PWR\PWR_EnterStandbyMode

and delete “ LL_LPM_EnableDeepSleep();�? in line 273, I got the same result.

Maybe there is a clock or interrupt issue. Currently I’m using HSI.

Does anybody have an idea or hint where to start? Sure, I can try to switch off WFI() in debug mode, but this is only a quick & dirty fix.

I’m happy about any idea. Thank you so much. 

19 REPLIES 19

StandBy isnt good example. This mode is max power off and waking from it make reset of MCU , ten code dont continue in while.

But in your example you can see wfi is lats command on special sequence, and not for use alone.

When you plan use it, you need setup MCU to desired mode and then can use __WFI.

Piranha
Chief II

@MM..1​, sorry, but you are spreading misinformation.

@DRH​, your understanding of sleep mode is correct. When SLEEPDEEP bit is cleared (and that is the default state after reset), WFI instruction enters sleep mode - turns off CPU core clock until an interrupt becomes pending. If an interrupt is already pending, when WFI is called, WFI behaves as NOP. Obviously it saves the energy which would otherwise be wasted by CPU core on useless code looping/polling.

The real issue here is related to a bit for keeping debug interface active during SLEEP mode:

G0: RM0444 section 40.10.2, bit not present.

F0: RM0091 section 32.9.3, bit not present.

L0: RM0377 section 27.9.3, DBG_SLEEP bit present.

@Imen DAHMEN​, is really that bit removed in F0 and G0 series or is it a documentation issue? If it is removed, then is it somehow at all possible to debug these MCUs while using SLEEP mode?

MM..1
Chief III

if we discuss debuging only, then save energy modes is debuged by ampermeters and not debuger.

And when SLEEP is debuged simply enable systick interrupt and debuger start working. No special bits needed. Maybe you have it on STM32F3xx

STOP and STANDBY need this bits for debuging... And in this speci modes you need too STLINK or other debug with compatible firmware...

For real debuging on code then comment WFI out...is best choice

DRH
Associate III

@Imen DAHMEN​ , do you have any idea regarding debugging with WFI() on STM32G031?

Hello,

Thanks @Piranha​ ​ and @DRH​ for pointing out to me this discussion, and sorry for the delayed reply on this.

The DBG_SLEEP bit required is consequently unnecessary on STM32G0 product.

I can comment that on STM32G0, the FCLK and HCLK required for debug activity are kept active under sleep if debugger is active (a flag is indicating this in internal Cortex registers).

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
DRH
Associate III

Many Thanks Imen,

I understand your response in that way that there should be no issue with debugging with a code using WFI()? Unfortunately I didn't have success with the Nucleo board of the SMT32G031.

If you have it available, can you please try your example "PWM_EnterStandyMode" but comment the function "EnterStandbyMode(void)" completely but leave the WFI() command active.

void EnterStandbyMode(void)
{
//  /* Turn-off LED */
//  /* Note: LED state at this step depends on blinking state at the instant of user button is pressed. */
//  LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6);
//   
//  /* Enable pull up on wakeup pin */
//  /* Note: Setting not mandatory but recommended to avoid wake-up pin floating */
//  LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_0);
//  
//  /* Enable pull-up and pull-down configuration */
//  LL_PWR_EnablePUPDCfg();
//  
//  /* Set wakeup pin polarity */
//  LL_PWR_SetWakeUpPinPolarityLow(LL_PWR_WAKEUP_PIN1);
 
//  /* Enable wakeup pin */
//  LL_PWR_EnableWakeUpPin(LL_PWR_WAKEUP_PIN1);
//  
//  /* As default LL_PWR_WAKEUP_PIN1 state is high level, need to clear all wake up Flag again */
//  LL_PWR_ClearFlag_WU();
 
//  /** Request to enter Standby mode
//    * Following procedure describe in STM32G0xx Reference Manual
//    * See PWR part, section Low-power modes, Standby mode
//    */
//  /* Set Standby mode when CPU enters deepsleep */
//  LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
  
  /* Set SLEEPDEEP bit of Cortex System Control Register */
  //LL_LPM_EnableDeepSleep();
  
  /* This option is used to ensure that store operations are completed */
#if defined ( __CC_ARM)
  __force_stores();
#endif
  /* Request Wait For Interrupt */
  __WFI();
}

After first debugging, I got the message "Invalid ROM Table" and can't debug until I use the bootloader option. Do you have any idea where the issue is?

I use the WFI() command in another code but the message and issue is the same.

DRH
Associate III

Hi,

do anybody have the chance to check my example? Till now I don't have an idea how to debug with WFI(). With the SMT32F3xx we use in other projects there is no issue.

DRH
Associate III

Hi all,

to anybody that have the same issue. It looks like I missed to switch on the DBGMCU clock....

LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DBGMCU);

I have to make further investigation but this seems to have been the issue. Please excuse that it looks like there was a second issue behind my eyes.

Imen.D
ST Employee

Thanks @DRH​  for sharing your update and solution. This should be helpful for the Community =)

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
DRH
Associate III

Hi @Imen DAHMEN​ ,

thanks. Bad news, after some further tests, it looks like there is still the same issue with WFI() with the minimalized STM example programm. Are you able to check µVision and the NUCLEO-G031K8 example PWR_EnterStandbyMode on the Nucleo of STM32G031K8? It would be very helpful.

If not, is there somebody else that have this hardware available for a quick test?