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-17 04:11 AM
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.2012-10-17 07:00 AM
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?2012-10-17 07:38 AM
Yes, using WFI is definitely good idea, it saves lots of power.
2012-10-17 10:18 AM
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.2012-10-17 11:56 AM
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);2012-10-17 12:43 PM
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.2012-10-17 01:25 PM
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.
2012-10-17 01:58 PM
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.2012-10-18 01:01 AM
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.