Skip to main content
David Martins
Senior
November 14, 2017
Question

STM32F030F4P STOP mode: enter and exit

  • November 14, 2017
  • 9 replies
  • 6369 views
Posted on November 14, 2017 at 22:09

Hello.

I'm having some problems with the STOP mode of STM32F030F4P.

After having all my application working with standbye mode awake by the RTC alarm, I checked that my application can not have floating pins.

So I thought, sacrifice some uA in exchange for not having to 'dirty' my PCB and use the STOP mode to keep at least weak pull-up resistor.

The problem is that I can not use the examples because some functions are not declared in the 'stm32f0xx_hal_rtc_ex.h' file, for example: HAL_RTCEx_SetWakeUpTimer_IT.

They are only available for the STM32F030xC version.

But the RTC alarm should be enough to wake up, but the MCU does not enter STOP mode when I call the function 'HAL_PWR_EnterSTOPMode (PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI)'.

At this point my code is very simple, because I have been removing everything so that I can only test if the MCU enters Stop mode or not ...

Physically the LED is on 10s, turns off 100mS and repeats again ...

That is, nothing more happens.

.. PS: RTC and alrm work as expected, because if I put my code to enter STANDBY, the current drops to ~ 5uA as expected (during ~1min, the alarm duration).

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_SPI1_Init();
 MX_TIM17_Init();
 MX_I2C1_Init();
 MX_RTC_Init();

 /* USER CODE BEGIN 2 */

 __HAL_RCC_PWR_CLK_ENABLE();

 //Configura RTC
 HAL_RTC_MspInit (&hrtc);

 while (1)
 {

 HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 1);

 HAL_Delay(10000);
 HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 0);

 HAL_Delay(100);

 HAL_PWR_EnableBkUpAccess();

 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
 void MX_RTC_Init(void)
 {
 RTC_TimeTypeDef sTime;
 RTC_DateTypeDef sDate;
 RTC_AlarmTypeDef sAlarm;

 /**Initialize RTC Only
 */
 hrtc.Instance = RTC;
 hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
 hrtc.Init.AsynchPrediv = 100;
 hrtc.Init.SynchPrediv = 400;
 hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
 hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
 hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
 if (HAL_RTC_Init(&hrtc) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }

 /**Initialize RTC and set the Time and Date
 */
 sTime.Hours = 0x0;
 sTime.Minutes = 0x0;
 sTime.Seconds = 0x0;
 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
 sTime.StoreOperation = RTC_STOREOPERATION_RESET;
 if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }

 sDate.WeekDay = RTC_WEEKDAY_MONDAY;
 sDate.Month = RTC_MONTH_JANUARY;
 sDate.Date = 0x1;
 sDate.Year = 0x17;

 if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }

 /**Enable the Alarm A
 */
 sAlarm.AlarmTime.Hours = 0x0;
 sAlarm.AlarmTime.Minutes = 0x1;
 sAlarm.AlarmTime.Seconds = 0x0;
 sAlarm.AlarmTime.SubSeconds = 0x0;
 sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
 sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
 sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY|RTC_ALARMMASK_HOURS
 |RTC_ALARMMASK_SECONDS;
 sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_ALL;
 sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_WEEKDAY;
 sAlarm.AlarmDateWeekDay = RTC_WEEKDAY_MONDAY;
 sAlarm.Alarm = RTC_ALARM_A;
 if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BCD) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }

 }

 void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
 {

 if(rtcHandle->Instance==RTC)
 {
 /* USER CODE BEGIN RTC_MspInit 0 */

 /* USER CODE END RTC_MspInit 0 */
 /* RTC clock enable */
 __HAL_RCC_RTC_ENABLE();

 /* RTC interrupt Init */
 HAL_NVIC_SetPriority(RTC_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(RTC_IRQn);
 /* USER CODE BEGIN RTC_MspInit 1 */

 /* USER CODE END RTC_MspInit 1 */
 }
 }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

I need help putting the MCU in stop mode.

Thank you.

#stm32f030-stop #low-power-stop-mode #stm32f030 #stop-mode
This topic has been closed for replies.

9 replies

David Martins
Senior
November 15, 2017
Posted on November 15, 2017 at 12:36

Can someone help?

What is missing here in the process?

In fact, in addition to the 'information' that I find in the examples, I can not find documentation explaining the STOP mode.
David Martins
Senior
November 15, 2017
Posted on November 15, 2017 at 19:05

I found a very simple example in the folder: Projects\STM32F072RB-Nucleo\Examples_MIX\PWR\PWR_STOP\

It could easily be exported to my case.

The only difference is that EXTI is not triggered by a pin, but by the RTC alarm.

What's the big difference? Could it be the MCU?

I am open to any suggestions.

Thank you.
David Martins
Senior
November 15, 2017
Posted on November 16, 2017 at 00:30

I'm debugging the code.

Basically the processor passes the STOP mode command without the WFU being SET.

That is, the core does not enter and exits STOP mode ... the core never enters STOP mode.

I have been testing various possibilities, but nothing changes..

The RTC ALARM continues to function well.

After 1min, the alarm occurs and the SET of the WFU bit is done at that time.

https://s7.postimg.org/s3u33yr7f/Capturar.jpg

David Martins
Senior
November 16, 2017
Posted on November 16, 2017 at 12:28

Can someone help?

Can someone from ST help me with this?

Or because it's an value line MCU does not deserve attention?

It starts to be strange the lack of information / response ...
Nesrine M_O
Associate
November 16, 2017
Posted on November 16, 2017 at 13:40

Hi

Martins.David

,

I recommend you to start from example under the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef0.html

STM32Cube_FW_F0_V1.9.0\Projects\STM32F030R8-Nucleo\Examples\PWR\PWR_CurrentConsumption:

STM32Cube_FW_F0_V1.9.0\Projects\STM32072B_EVAL\Examples\PWR\PWR_STOP

Also please have a look to these documents it may help you:

  1. http://www.st.com/content/ccc/resource/technical/document/application_note/group0/71/b8/5f/6a/8e/d5/45/0a/DM00226326/files/DM00226pdf/jcr:content/translations/en.DM00226pdf

  2. refer also toPower control (PWR) chapter in your r

    http://www.st.com/content/ccc/resource/technical/document/reference_manual/cf/10/a8/c4/29/fb/4c/42/DM00091pdf/files/DM00091pdf/jcr:content/translations/en.DM00091pdf

    you find information aboutLow-power modes

-Nesrine-

Nesrine M_O
Associate
November 16, 2017
Posted on November 16, 2017 at 13:44

Hi

Martins.David

,

if you are designing your own STM32 board , I recommend you also to have a look to theGetting started with

http://www.st.com/content/ccc/resource/technical/document/application_note/91/66/2d/8c/f9/b5/47/55/DM000898pdf/files/DM000898pdf/jcr:content/translations/en.DM000898pdf

-Nesrine-

David Martins
Senior
November 16, 2017
Posted on November 16, 2017 at 14:26

Hello

ELMHIRI.Syrine

.

I've done several applications with STM32 (not F0 family, nor low-power applications) and everything went well. I followed all the indications of the application notes.

I also wrote that I reviewed the examples made available and in specific the example of PWR_STOP.

My question is this: What can cause not enter in the STOP mode?

I have already put here an image that shows that the core does not enter in STOP mode and the SET of the WFU flag is not done.

The RTC ALARM continues to function well. After 1min, the alarm occurs and the SET of the WFU bit is done at that time.

All obvious flags are reset when I run the

HAL_PWR_EnterSTOPMode (PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI).

The P.C. goes through the WFI ()and exits immediately ... but it should Wait For Interrupt, but there is no SET of any interrupt flag.

So I think there is something else that can prevent the core from entering STOP mode. That's why I was asking for your help.

Nesrine M_O
Associate
November 16, 2017
Posted on November 16, 2017 at 14:50

Hi

,

Try to disable the

Systick interrupt

/* Enter Stop Mode */HAL_SuspendTick();HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);HAL_ResumeTick();

-Nesrine-

David Martins
Senior
November 16, 2017
Posted on November 16, 2017 at 16:26

I think I've tried to do this without positive results, but I will try again.

Anyway I leave here some more pictures.

EXTI and PWR registers before executing STOP mode command.

https://s7.postimg.org/3mugt67mz/st1.jpg

https://s7.postimg.org/tv5lik763/stjpg

EXTI and PWR registers after executing STOP mode command.

https://s7.postimg.org/xrixejkfv/st2.jpg

https://s7.postimg.org/pm0vgebmj/stjpg

It seems to be all fine for the core enter in STOP mode ...

The SET of the

LPDS bit is done while executing the function. It's the only difference it seems to have ...

There is no change in the EXTI

registers

, so I can only assume that the core does not enter in STOP mode.

WFI() does not wait for any interruption ...

Nesrine M_O
Associate
November 17, 2017
Posted on November 17, 2017 at 09:54

Hi

,

It is good to hear that it was solved

To reduce current consumption, I recommend you to configure all GPIO as analog

 GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Warning : Reconfiguring all GPIO will close the connexion with the debugger */ /* Enable GPIOs clock */ __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /* Disable GPIOs clock */ __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOF_CLK_DISABLE();�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

-Nesrine-

David Martins
Senior
November 17, 2017
Posted on November 17, 2017 at 10:19

ELMHIRI.Syrine

Thanks for the answer.

In fact, consumption has dropped to ~ 450uA, but it is still too high.

I am using a clean PCB that even the LED has not attached to the pin.

T

he MCU is free of any 'external' disturbance.

PS: I tried the STANDBY mode again and I still get ~ 5uA.

Nesrine M_O
Associate
November 17, 2017
Posted on November 17, 2017 at 11:56

  1. I recommend you to have a look to theGetting started with

    /external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fcontent%2Fccc%2Fresource%2Ftechnical%2Fdocument%2Fapplication_note%2F91%2F66%2F2d%2F8c%2Ff9%2Fb5%2F47%2F55%2FDM000898pdf%2Ffiles%2FDM000898pdf%2Fjcr%3Acontent%2Ftranslations%2Fen.DM000898pdf

    to be sure about your hardware implementation.
  2. If you have an STM32F0 discovery board or a nucleo board maybe you can test your software.

David Martins
Senior
November 17, 2017
Posted on November 17, 2017 at 12:06

ELMHIRI.Syrine

I do not have a STM32F0 nucleo board (I only have F4).

But is it possible for someone to test the code in an EVB and confirm the results?

There is no support circuit for the MCU to enter in STOP mode ... so if it works on a nucleo board, it will work with me...

But I'll analyze and see if I find difference in the circuit (mine vs EVB).