Low power mode pyb.wfi()
Low power mode pyb.wfi()
Is there any documentation on pyb.wfi() ?
Ive searched plenty, and even tried to look at the source. Im a little lost there.
According to the datasheet for the processor there are various levels of sleep/power down modes. Can we choose the different modes with pyb.wfi().
Im sure I read somewhere a while ago on what the current consumption is in low power mode but cannot find it now. Does anyone have details on this?
Ive searched plenty, and even tried to look at the source. Im a little lost there.
According to the datasheet for the processor there are various levels of sleep/power down modes. Can we choose the different modes with pyb.wfi().
Im sure I read somewhere a while ago on what the current consumption is in low power mode but cannot find it now. Does anyone have details on this?
Re: Low power mode pyb.wfi()
WFI is a CPU instruction that basically means "Wait For Interrupt".
Basically, the CPU stops executing instructions and waits for an interrupt to occur.
I don't believe that WFI has any choice about types of modes. That's really outside the scope of wfi.
Basically, the CPU stops executing instructions and waits for an interrupt to occur.
I don't believe that WFI has any choice about types of modes. That's really outside the scope of wfi.
Re: Low power mode pyb.wfi()
Using pyb.wfi() allows you to reduce power consumption by about 1/2 if you are waiting in a loop.
Consider:
versus:
The second code will run the same, but use about 1/2 the power. This is because the wfi instruction pauses the CPU, waiting for an internal or external interrupt. Since the systick timer interrupts at 1kHz, wfi() waits at most for 1ms (unless irqs are disabled). It's always a good idea to put wfi() in a "busy" loop like the one above.
The other power saving modes are pyb.stop() and pyb.standby(). pyb.stop() works well, and the CPU is woken on an external interrupt (see ExtInt class).
pyb.standby() is woken only by RTC alarm (not currently implemented) and special external interrupts.
You can also adjust the CPU frequency to reduce power consumption: pyb.freq(30000000) will clock down to 30MHz and save you a lot of power.
Consider:
Code: Select all
sw = pyb.Switch()
while True:
if sw():
print("switch pressed")
Code: Select all
sw = pyb.Switch()
while True:
if sw():
print("switch pressed")
pyb.wfi()
The other power saving modes are pyb.stop() and pyb.standby(). pyb.stop() works well, and the CPU is woken on an external interrupt (see ExtInt class).
pyb.standby() is woken only by RTC alarm (not currently implemented) and special external interrupts.
You can also adjust the CPU frequency to reduce power consumption: pyb.freq(30000000) will clock down to 30MHz and save you a lot of power.
-
- Posts: 23
- Joined: Tue Sep 30, 2014 4:02 pm
Re: Low power mode pyb.wfi()
Hi all.
I try to reduce frequency with pyb.freq(30000000), but after this command pyboard hungs without any reacts. I was trying other values, but it behaves the same.
What I am doing wrong?
In the docs is written not all. For example, about pyb.SD class I did not find any information. Where I can find some info about available frequencies?
I try to reduce frequency with pyb.freq(30000000), but after this command pyboard hungs without any reacts. I was trying other values, but it behaves the same.
What I am doing wrong?
In the docs is written not all. For example, about pyb.SD class I did not find any information. Where I can find some info about available frequencies?
Evgeny
Re: Low power mode pyb.wfi()
Do you have recent firmware?
You can check the firmware version when you start the REPL. You should see a line something like this:
Anything earlier than Oct 5 doesn't have the proper frequency changing code.
You can check the firmware version when you start the REPL. You should see a line something like this:
Code: Select all
Micro Python v1.3.3-92-gfb765bc-dirty on 2014-10-22; PYBv1.0 with STM32F405RG
-
- Posts: 23
- Joined: Tue Sep 30, 2014 4:02 pm
Re: Low power mode pyb.wfi()
I use Micro Python v1.3.5 on 2014-10-29; PYBv1.0 with STM32F405RG
Evgeny
Re: Low power mode pyb.wfi()
The pyb.freq() command supports frequencies (in MHz) between 24MHz and 168MHz, and it rounds them to a compatible value. Sometimes when you change the frequency while connected over USB you will lose the USB connection, but this doesn't happen very often. And I think pyb.freq(24000000) doesn't allow USB to work at all. But otherwise it should be working.
Re: Low power mode pyb.wfi()
Are you typing pyb.freq(30000000) at the REPL prompt when connected over the USB serial? Can you try pyb.freq(168000000) and also pyb.freq() to see what the output of that says?
-
- Posts: 23
- Joined: Tue Sep 30, 2014 4:02 pm
Re: Low power mode pyb.wfi()
I want give more information, but don't know method: pyboard does not return traceback or something else.
Evgeny
-
- Posts: 23
- Joined: Tue Sep 30, 2014 4:02 pm