cancel
Showing results for 
Search instead for 
Did you mean: 

How to reconfigure STM32L476 after exit standby mode

Lucas Oliveira
Associate II
Posted on May 24, 2017 at 15:34

Hi,

We are working with SensorTile (STM32L476). To reduce power consumption, we are using the standby mode with sram2 retention. Our intention is to configure BlueNRG-MS (with advertising enabled), enter standby mode and wait for a user connection through smartphone. The problem is that after wake-up, the SPI/BlueNRG-MS is reconfigured and we can't establish the connection.

We are trying to use this sequence:

- initilize the ble stack/SPI, storing in SRAM2 all the varibles we think that needs retention;

- enter advertising;

- enter standby mode with SRAM2 retendion;

- wait connection event (ble interrupt);

- reconfigure SPI; (for me our problem is here)

- trying to create connection after interrupt;

What is the best way to do this? What do we need to store in SRAM2 before standby? 

What do we

need to

 reconfigure after wake-up?
6 REPLIES 6
RomainR.
ST Employee
Posted on May 24, 2017 at 16:54

Hello Lucas,

Have a look to L476 Ref manual chapter 5.3.9 Standby Mode.

When exit from standby Mode, mcu will perform a reset phase. So, it's normal that your code restart and perform peripheral initialization which you defined.

It's same with Shutdown mode except for SRAM2 where no retention is available.

It's a best practice to check and manage after reset what is the reset source cause (seestm32l4xx_hal_pwr.h)

if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) ) ...�?

Then clear the corresponding flag with:

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB)...�?

And choose what to do after.

- If reset cause is a Cold reset. Then perform peripheral configuration and wait a connection with a smartphone.

- If reset cause is when exit from Standby Mode, Then perform peripheral configuration, reload configuration stored into SRAM2,

and wait a connect

ion with a smartphone.

Regards.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on May 24, 2017 at 17:08

You can use the following example from Cube repository.

C:\Users\Your account\STM32Cube\Repository\STM32Cube_FW_L4_V1.7.0\Projects\STM32L476RG-Nucleo\Examples\PWR\PWR_STANDBY

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on May 24, 2017 at 18:23

Hi Romain, thanks for your reply. Actually I'm already checking PWR_FLAG_SB after Standby Mode. My doubt is how I should perform peripherals configuration after standby. What I really need to reconfigure for establishing the connection requested by smartphone?

Posted on May 25, 2017 at 06:18

Hi Lucas,

You have chosen for your application to use the standby mode which is the one that allows the STM32 to have the lowest power consumption.

- Core and systems clock are off (exept LSE/LSI)

- Peripherals are off.

Only the backup domain with the RTC timer are functional and the possibility to preserve the contents of the SRAM2.

After waking up the standby mode, the stm32 will reset and restart your program in the same way as if you made an external reset or a power cycle. And flag PWR_FLAG_SB will be set.

Before entering standby mode, your application should back up the useful data of your application in the SRMA2 or in the backup register.

Then it should also properly stop the BLE connection with smartphone.

So to be able to re-establish the connection with it, you must reconfigure the device (SPI) and restart the communication with the smartphone.

What is your method for getting out of standby mode?

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on May 25, 2017 at 13:56

Hi Romain,

We are using WakeUpPin for getting out standby mode. WakeUpPin is connected with BlueNRG-MS IRQ. 

When we enter standby mode, BLE is configured to send advertising and isn't connected with smartphone yet. The smartphone connection that wakes up STM32. After waking up, our application must restart the communication with BlueNRG without losing the connection.

Korhonen
Associate

I'm facing the similar problem... Did you manage to solve this issue?

BlueNRG's IRQ is connected to the STM32L4's wakeup pin. STM32L4 will be shut down to standby while BlueNRG is still up and running. BLE actions will nicely wakeup the STM32L4, but how to reconfigure BlueNRG from the STM32L4 without resetting and reinitialising everything? We don't like to loose existing data on the BLE characteristics or existing BLE connection while waking up the STM32L4 from the standby.