-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Current unchanged when trying to turn off QSPI during sleep #3360
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
Comments
Does We need turn off other peripherals(USB, SPI, PWM and etc) using high frequency clock (HFCLK), and then go to sleep. |
Yes, the dotstar library uses SPI if it can. Below is from https://github.com/adafruit/Adafruit_CircuitPython_DotStar/blob/master/adafruit_dotstar.py. The way around this would be to modify the code to force it to use bit-bang method it does when SPI is not avialable on the requested pins. That is, just remove the code in the self._spi = None
try:
self._spi = busio.SPI(clock, MOSI=data)
while not self._spi.try_lock():
pass
self._spi.configure(baudrate=baudrate)
except (NotImplementedError, ValueError):
self.dpin = digitalio.DigitalInOut(data)
self.cpin = digitalio.DigitalInOut(clock)
self.dpin.direction = digitalio.Direction.OUTPUT
self.cpin.direction = digitalio.Direction.OUTPUT
self.cpin.value = False |
It didn't even occur to me to test current with the LED still on but I did and got this:
|
@catequalsgood try disabling the Dotstar in the board definition you are using. It will configure SPI if it's marked as a status LED for the board. |
@catequalsgood When LFCLK is off, the current of nRF52840 is a few uA. While, other parts of the board may have higher power consumption. As you see, a LED takes about 0.95 mA. The hardware I used is the M60 keyboard. It is optimized for low power consumption. Other parts of it still needs around 50 uA. |
Thanks for everyone's explanations and tips!
That dropped the current during sleep to 0.95 mA which is obviously way better than what I got when turning off the LED using Is 0.5 mA going to be the limit for the itsybitsy simply because it was not designed with low-power applications in mind? PS: Defining all digital pins as outputs might result in a further reduction of about 30 uA or so but I is hard to tell with my cheap multimeter. |
@catequalsgood Yup, that's what I was thinking to disable the dotstar status neopixel. I'm not sure what the lowest possible value is. @xiongyihui's work is the best indication of it. When I added the low power support, it was mainly to get the code base ready for it. |
I think this is fixed by the led status rework plus #4236 |
After reading about the ability to turn off QSPI during sleep for the nRF52840 in 6.0.0 alpha 3 I tried emulating what @xiongyihui did in issue #3244 on my itsybitsy BLE (also nRF52840). However after building CircuitPython with the CIRCUITPY_ENABLE_MPY_NATIVE=1 flag to be able to use the @micropython.asm_thumb decorator and adding a few lines to xiongyihui's code to disable the DotStar LED the current drawn from battery (no USB connected) is still identical to what it was when using 6.0.0 alpha 2 (about 2.5 mA). The quiescent current of the DotStar is around 1 mA and I will physically remove it once the project is nearly finished.
I am not sure how I could tell if QSPI is actually off other than looking at the current and since xiongyihui measured far less (on a different board however) I assume I am either doing something wrong or the difference in hardware is to blame (maybe turning off the DotStar in this way doesn't allow QSPI to turn off?).
this is all I added to xiongyihui's code:
import board
import adafruit_dotstar as dotstar
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1)
dot[0] = (0, 0, 0)
The text was updated successfully, but these errors were encountered: