Idle task and WFI Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Idle task and WFI

Post by vrollei »

Hello,

can not get idle task work correctly with ARM_ENABLE_WFI_IDLE = TRUE and STM32L1 low power sleep mode.

It works fine with modified _idle_thread function:

static void _idle_thread(void *p) {

(void)p;

while (true) {
/*lint -save -e522 [2.2] Apparently no side effects because it contains
an asm instruction.*/
__WFI();
// port_wait_for_interrupt();
// /*lint -restore*/
// CH_CFG_IDLE_LOOP_HOOK();
}
}

Chibios version 16.1.5

Thanks in advance!

--
Vitaly
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Idle task and WFI

Post by Giovanni »

Hi,

Strange problem, moving this topic in "bug reports".

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Idle task and WFI

Post by Giovanni »

Bumped.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Idle task and WFI

Post by Giovanni »

Hi,

I am unable to replicate the problem, by setting CORTEX_ENABLE_WFI_IDLE to TRUE a WFI instruction is placed inside the idle loop.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Idle task and WFI

Post by vrollei »

Hi,

the problem is in different current consumption:

1. lowest current consumption with __WFI() directly put in while loop. It is about 5uA with one active timer for systick.
2. it is about 30-40uA using inline function port_wait_for_interrupt

compiled with gcc-arm-none-eabi-5_4-2016q3

--
Vitaly
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Idle task and WFI

Post by Giovanni »

Hi,

In my case WFI is inlined in the idle loop, there is no function call, what compiler options are you using?

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Idle task and WFI

Post by vrollei »

[font=Courier New]# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT =
endif[/font]
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Idle task and WFI

Post by Giovanni »

Hi,

It is because -O0 (no optimizations), that disables inlining, if you are concerned by consumption you should really use at least -O2.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Idle task and WFI

Post by vrollei »

Giovanni,

thanks a lot!
Post Reply