2012-10-17 03:35 AM
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.
2012-10-18 12:39 PM
Thomas,
Not sure if this is much help to you, but... I am running uCos-II on an SMT32F103xE which uses the USB port. I use__WFI()
in the hook for the idle task (which it spends most it's time in). The USB functionality operates normally, including with the WFI call when I'm idle. I have the USB connected to a Windows 7 64 bit box, in case that makes a difference. Charlie2012-10-18 01:08 PM
The FS VCP example (STM32_USB-Host-Device_Lib_V2.1.0) ported to my STM32F205 board, also continues to function with WFI in the foreground loop.
2012-10-23 06:31 AM
Hello,
I prepared my main like this :// __nop();
// __nop();
// __nop();
// __nop();
while(1);
And playing with the number of nops, I can get significant power consumption reduction.
You just have to find the sweet spot once the rest is ok for release.
Thomas.
2012-12-07 04:26 AM
Hi,
Were you able to find a fix for your problem? I am facing a similar problem with USB OTG HS using embedded Full speed PHY on a custom board with an F207 chip. Using WFI results in the control transfers going haywire. I have seen the controller sending some 1000 bytes out on the bus where it was supposed to send an eight byte setup packet. It all goes away if I remove WFI from my system. Regards, Awais2012-12-15 09:43 AM
Dear all,
Thank you for posting this interesting issue, Here I give the details of the behavior and THE solution :This unwanted behavior is caused by bit ''OTGHSULPILPEN'' that is set by default in register AHB1LPENR ( See below) , reset state is [1].
When working with our High Speed peripheral in full speed mode and you want to enter SLEEP using WFI cortex-M low power mode, the firmware side should configure these bits in this way :
1) Clear bit
OTGHSULPILPEN
in register AHB1LPENR 2) Set bit OTGHSLPEN in register AHB1LPENR ( already set after reset) Hope it helps you.O
ur Firmware library
and USB examples will implement this change in
future.
Cheers, STOne-32 { your STM32 Moderator }2012-12-15 11:57 AM
Ok, well that's interesting. None of my boards have HS/ULPI, which explains my lack of issues in this regard.