Page 1 of 1

STM32F411 STOP MODE

Posted: Thu Mar 19, 2020 1:18 pm
by Kisen
Hi,
Does anyone have any experience using the sleep modes on STM32.

I have read and watched several videos on this, but they all seem to relate to a HAL function.

In flowcode is this something i need to create?

Also when exiting sleep mode it appears that some code is required to reactivate the chip, does this go in an interrupt? How can the chip run if the oscillator is off until the code gives the command to turn it on.

I am using the wake pin on the STM32 triggered from an external source to provide the wake up signal.

Any help would be greatly appreciated.

Re: STM32F411 STOP MODE

Posted: Thu Mar 19, 2020 5:08 pm
by Kisen
I have found the function that is called to set the STM32 into stop mode.

Unfortunalty, I appear to have zero clue on how to implement this in Flowcode in a C block.

Has anyone got any pointers?

Code: Select all

void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
{
  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(Regulator));
  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
  
  /* Select the regulator state in Stop mode: Set PDDS and LPDS bits according to PWR_Regulator value */
  MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS), Regulator);
  
  /* Set SLEEPDEEP bit of Cortex System Control Register */
  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
  
  /* Select Stop mode entry --------------------------------------------------*/
  if(STOPEntry == PWR_STOPENTRY_WFI)
  {   
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __SEV();
    __WFE();
    __WFE();
  }
  /* Reset SLEEPDEEP bit of Cortex System Control Register */
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));  
}

Re: STM32F411 STOP MODE

Posted: Thu Mar 19, 2020 5:24 pm
by LeighM
Hi,
The note in the source file above your quoted section explains the parameters.
You would call this in a C icon in Flowcode, for example...

Code: Select all

HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);

Re: STM32F411 STOP MODE

Posted: Thu Mar 19, 2020 5:31 pm
by Kisen
Hi Leigh,

Your reply has just confused me even more.

You suggest to call the function in C. Thats not a problem.
But where is flowcode getting the instructions from to set and clear the registers as per the code i quoted?
Is this HAL library already built into flowcode??

Re: STM32F411 STOP MODE

Posted: Thu Mar 19, 2020 5:50 pm
by LeighM
Is this HAL library already built into flowcode??
Yes

Re: STM32F411 STOP MODE

Posted: Mon Mar 07, 2022 1:15 pm
by Farren
Hi,
I have FlowCode Professional Version 7 and about to upgrade to V9 ( i bought flowcode in 2017 and never used it till today )
I want to put an STM32F405 into low power sleep or stop mode to be waken from an interrupt.
Must I put the HAL code into a C Icon in Flowcode or have they update in V9 to have a function ( block ) for this ?
Has anyone got an example of how to do this ?

I am familiar with low power modes using the STM32Lxxx Standard Peripheral Libraries and C compiler.
It is the first time I am trying this with flowcode. :P

Cheers
Farren

Re: STM32F411 STOP MODE

Posted: Mon Mar 07, 2022 3:34 pm
by Benj
Hello Farren,

We don't have anything regarding a component to drive this in v7 or v9, if you already have C code to do it then yes you can simply pop it into a C icon as part of the program and it should work fine.