STM32F411 STOP MODE

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Kisen
Posts: 73
Joined: Fri Jan 24, 2020 10:38 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

STM32F411 STOP MODE

Post 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.

Kisen
Posts: 73
Joined: Fri Jan 24, 2020 10:38 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: STM32F411 STOP MODE

Post 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));  
}

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32F411 STOP MODE

Post 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);

Kisen
Posts: 73
Joined: Fri Jan 24, 2020 10:38 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: STM32F411 STOP MODE

Post 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??

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32F411 STOP MODE

Post by LeighM »

Is this HAL library already built into flowcode??
Yes

Farren
Posts: 2
Joined: Tue Apr 18, 2017 12:14 am
Been thanked: 1 time
Contact:

Re: STM32F411 STOP MODE

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: STM32F411 STOP MODE

Post 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.

Post Reply