Skip to main content
aamirali641989
Associate III
May 21, 2014
Question

Sneding STM205RBT6 in sleep mode

  • May 21, 2014
  • 5 replies
  • 764 views
Posted on May 21, 2014 at 14:09

Is below is right way to send STM32F205RBT6 in sleep mode:

I have to do some task, then send MCU in sleep mode for 1 sec & then again execute those tasks.

main()

{

while(1)

{

// do some task

configure_timer_1_sec();   //configure interrupt when 1 sec completes

__wfi();

}

}

timer_isr()

{

clear_interrupt_flag();

}
    This topic has been closed for replies.

    5 replies

    chen
    Associate II
    May 21, 2014
    Posted on May 21, 2014 at 18:27

    Hi

    I am not familiar with the part you are using.

    __wfi() is definitely the ARM command to put the processor into sleep mode (as defined by ARM).

    The short code you showed does not show all the setup that should be done to get the most power saving. For instance, on the STM32F405 part that I have implemented power save on, the peripherals can be clock gates (select which peripherals still get clocked during sleep mode) - this really saves power.

    aamirali641989
    Associate III
    May 22, 2014
    Posted on May 22, 2014 at 10:36

    First I am trying to send CPU in sleep mode. I am not worried about peripherals now.

    So I initialized a timer to 1 sec interrupt & then used __wfi().

    So when MCU has 1 sec timer interrupt it wake up & start executing next instruction

    EDIT: is there any specific register in which we can select which peripherals can be clock gated or its jusy by enabling clock to peripherals

    chen
    Associate II
    May 22, 2014
    Posted on May 22, 2014 at 10:56

    ''So I initialized a timer to 1 sec interrupt & then used __wfi().

    So when MCU has 1 sec timer interrupt it wake up & start executing next instruction''

    Generally, yes. However testing it is a problem.

    When you use a debugger - the processor is not actually suspended (clock stopped).

    Probably, the easiest way is to have your main loop toggle an LED. When the processor goes into sleep, the toggling should stop.

    ''EDIT: is there any specific register in which we can select which peripherals can be clock gated''

    For the SMT32F405 - yes.  The registers are in the RCC register set. See the reference manual for details.

    ''or its jusy by enabling clock to peripherals''

    Yes, you can manually control the peripherals.

    I have implemented both in my work because it give better power saving. I have turned off any peripheral that is not in use and only a small number of peripherals are clocked during Sleep mode, just the peripheral that may wake the processor.

    aamirali641989
    Associate III
    May 23, 2014
    Posted on May 23, 2014 at 12:54

    For clock gating , register in STM32F205RBT6 is RCC->AHB1ENR , depending upon peripheral. 

    Will enabling/disabling a particular register reinitialize all the peripheral register values. or it maintain the set values

    chen
    Associate II
    May 23, 2014
    Posted on May 23, 2014 at 13:20

    Hi

    ''For clock gating , register in STM32F205RBT6 is RCC->AHB1ENR , depending upon peripheral. 

    Will enabling/disabling a particular register reinitialize all the peripheral register values. or it maintain the set values''

    Please check the reference manual (possible data sheet) for definitive answer.

    I think that the peripheral(s) should remain unchanged when the clock is stopped and then restored.