-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Power consumption #2
base: master
Are you sure you want to change the base?
Conversation
Nice work. Interesting that lowering the clock speed decreases power that much. I will have to setup a more precise way to measure the current. |
Okay, here's what I've seen so far. With the current version of the firmware, without leds, the keyboard draws 39.0 mA. With the clock change, without leds, it draws 25.8 mA. That's a tidy improvement. Now, in Deep-Sleep1, the the keyboard draws 1.3 mA. It seems to behave correctly when suspending, but occasionally it seems to hard fault when waking. So at the moment, this is no-go. |
I agree with not merging it yet. The current wakeup code doesn't work when the host wants the keyboard to resume. Additionally we'll loose keypresses when you're a typing fast during the resume. I didn't see a hardfault when the code tries to wakeup with the EXTI interrupt, but that was probably just luck. |
This only implements the three LEDs that are in place on an unmodified PCB. Since the LED matrix is connected with the key matrix, it has to be turned off while reading the key matrix to not short-circuit.
If the AHB clock frequency is decreased further to 24MHz and compiler optimizations are turned off, then the usb stack runs quickly into assertions with one of my newer test machines. Decreasing the AHB frequency to 24MHz would save another 4mA.
This decreases the power consumption to <1mA when the host suspends the pok3r.
During wakeup, pressed keys might get lost because the last report wasn't acknowledged by the host yet. This is a simple workaround that keeps a small queue for all reports to be sent.
Otherwise modifier keys are not sent if they were pressed first to wakeup from suspend. I suspect that the rest of suspend_wakeup_init is similarly tested, so i disabled the whole function.
4436d7d
to
083805f
Compare
Just some update on this pull request: I'm using it with a ChibiOS-Contrib tree where PR pok3r-custom/ChibiOS-Contrib#3 is applied. I've modified and force pushed one of the earlier commits that changed the AHB frequency. On my main development machine i could go down to 6MHz and didn't see any errors, while the keyboard only consumed 17mA. But unfortunately this didn't worked well together with the BIOS of a T480, where i got some USB state machine assertions. The first frequency that also worked on the T480 reliably was 48MHz, which brings us now to a power consumption of ~30mA without any LEDs on. Another change that i have stashed is a second condition "USB_DRIVER.state == USB_SUSPENDED" at qmk_pok3r/tmk_core/protocol/chibios/main.c Line 137 in f24fb6e
I won't commit that change, because a similar commit was included in the qmk master tree qmk@73a3399 which could be applied by rebasing. Another issue which can't be fixed since pok3r reuses keymap rows/colums for the dip switches: There will be no visible power consumption change if one of the dip switches is enabled. |
This decreases the power consumption when the pok3r is running by ~10mA.
Moreover the Deep-Sleep1 power saving mode is used when the host suspends it. It uses the EXTI Wakeup Interrupt to wake up when the user presses a key. The pok3r consumes less then 1mA during Deep Sleep, which can be tested e.g. by using powertop on Linux to toggle the Tunable "Autosuspend for USB device POK3R"
Before accepting this pull request, the submodule lib/chibios-contrib should be updated after accepting the outstanding Pull Request for ChibiOS-Contrib.