cancel
Showing results for 
Search instead for 
Did you mean: 

Power consumption without low power ...

root
Associate II
Posted on October 17, 2012 at 12:35

Hello,

I'm using USB in my application so I cannot use any low power mode, not even __WFI(). I'm trying to understand what drives the power consumption of theMCU when using a while(1); loop in the main ... and can't find any logic conclusion. For example, in my systick handler, I have this :

void SysTick_Handler(void) 
{ 
oal_task_poll(); 
cdc_echo_task(); 
}

And I get 46mA all the time. If I add the following code :

void SysTick_Handler(void) 
{ 
oal_task_poll(); 
cdc_echo_task(); 
static int minVal = 120000; 
static int i = 0; 
if(SysTick->VAL < 
minVal
) 
minVal
= 
SysTick
->VAL; 
if(++i == 1000) 
{ 
i = 0; 
//printf(''Val = %d\n'', minVal); 
minVal = 120000; 
} 
}

Then consumption goes down to 23mA !!!!! Sometimes changing from while(1); to while(1) __nop(); doubles up the power consumption, but not in all cases. Arethere any rules that govern this ? Thomas.
15 REPLIES 15
zzdz2
Associate II
Posted on October 17, 2012 at 13:11

I noticed something similar. 

while(1); drains lots of power.

When I add some useless instructions inside the waiting loop then power consumption drops.

Unfortunately it's not quite predictable.

Posted on October 17, 2012 at 16:00

The alignment of the loop will impact things, as will things like flash lines and prefetch.

So what's the issue with using while(1) __WFI(); in the foreground idle wrt USB?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
zzdz2
Associate II
Posted on October 17, 2012 at 16:38

Yes, using WFI is definitely good idea, it saves lots of power.

root
Associate II
Posted on October 17, 2012 at 19:18

Hello,

It is a known limitation, no sleep with USB ... if you try, USB just stops working.

Nobody that I know of managed to get USB working along with sleep modes (someone claimed to be able in a few weeks ...).

Thomas.

Posted on October 17, 2012 at 20:56

It is a known limitation, no sleep with USB ... if you try, USB just stops working.

A raw __WFI() in the while loop does not appear to be deleterious to USB operation on F2 and F4 parts.

Are you talking about

  PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
root
Associate II
Posted on October 17, 2012 at 21:43

Hello,

Did you try it yourself ? I never managed or heard someone managed to get USB working on F205 using a while(1) __WFI(); loop.

Thomas.

Posted on October 17, 2012 at 22:25

I have an F4-Discovery running USB MSC on my desk prior to posting the previous message, happily transferring data 500 MB.

int main(void)
{
__IO uint32_t i = 0;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32fxxx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32fxxx.c file
*/
RCC_Configuration();
GPIO_Configuration();
USART2_Configuration();
puts(''MSC-DBG Testing'');
USBD_Init(&USB_OTG_dev,
#ifdef USE_USB_OTG_HS
USB_OTG_HS_CORE_ID,
#else
USB_OTG_FS_CORE_ID,
#endif
&USR_desc,
&USBD_MSC_cb,
&USR_cb);
while(1)
{
if (i++ == 0x100000)
{
STM_EVAL_LEDToggle(LED3);
STM_EVAL_LEDToggle(LED4);
STM_EVAL_LEDToggle(LED5);
STM_EVAL_LEDToggle(LED6);
i = 0;
}
__WFI();
}
}

I'm sure I've done it on my F205 board too, but will retest it.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 17, 2012 at 22:58

Yep, doing a similar thing with an STM32F205ZC, also seems to be functioning.

Compiling using Keil 4.60

Would seem like an architectural failure for a ''HALT'' loop not to permit an interrupt driven process to function in the background.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
root
Associate II
Posted on October 18, 2012 at 10:01

Hello,

If you manage to get HID  or VCP working on the OTG HS port with built in PHY using WFI in the main loop, I would be VERY interested to take a look at the code.

As soon as I'm using WFI, the USB stops working properly (unknown peripheral), and Altium confirmed me they had the same issue, and HCC Embedded can't make it work either, but they claimed they probably could in a few weeks.

Thomas.