0

Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by dshadoff on Sun Jun 09, 2019 3:22 pm

I just purchased and started using the "Adafruit Feather nRF52 Bluefruit LE - nRF52832" (product ID 3406), and it's a nice little device (aside from the boot loader download which initially put me off-balance).

There is more CPU power on this chip than I need for my current project, so I was looking to drop the power consumption by dropping the CPU clock a bit.

Since the module is Cortex M4F-based, I started with the assumption that I could use the same technique I am using on the ItsyBitsy M4 Express:
MCLK->CPUDIV.reg = MCLK_CPUDIV_DIV(n);

However, this didn't work, and when I went searching for the "startup.c" file in the "<base path>\packages\adafruit\hardware\nRF52" directory, I wasn't able to find it.
I was able to find something vaguely resembling this in "...\nRF52\0.11.0\cores\nRF5\nordic\nrfx\mdk\system_nrf52.c", where SYSTEM_CORE_CLOCK is set to 64000000, but this is just an attribute used for calculations, apparently not one of the core CPU-control registers. I was looking for the series of dividers which are normally available, but also didn't find them.

Can you steer me in the right direction ? Or is this feature actually buried inside of the pre-compiled boot loader for some reason, and not exposed to user-level ? If this is the case, I'd like to understand whether this is for a "system requirements" reason, or whether it's more of a "human-effort required to expose that code" reason. (Of course, it's probably available somewhere - I'm just having trouble locating it).

Dave

dshadoff
 
Posts: 14
Joined: Fri Mar 22, 2019 8:01 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by pcaddict on Mon Jun 10, 2019 1:33 pm

As far as I am aware, the NRF52 series does not have any mechanism to lower its clock speed. This functionality is nowhere to be found in Nordic's own SDK or the product specification for the NRF52.

When not using the NRF52's radio, the CPU uses an incredibly small amount of energy on its own, in the neighborhood of less than 10uA. This of course varies depending on what peripherals you are using and if you are dropping it into sleep mode and not using delays (use waitForEvent where possible for low power). On a development board such as the feather however the base current consumption is quite a bit higher, primarily due to the onboard 3.3v regulator.

Another thing you should consider is that lowering the clock speed in order to conserve power can sometimes have the opposite effect. I do not remember where I found it, but at one point I ran across a blog post where someone compared power consumption and clock speed and listed their results. I may have linked it on this forum in one of my old posts if you want to look.

pcaddict
 
Posts: 69
Joined: Thu Aug 31, 2017 9:24 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by dshadoff on Mon Jun 10, 2019 7:07 pm

My concern for power usage is not based on a blue-sky design limited only by the desire to extend the life of a battery (where sleep mode might come in handy).

Instead, I am looking to replace a 25-year-old peripheral with new technology. This old device already exists and is part of an ecosystem I am not in control of, and is not battery-powered; rather it's powered from a limited-power regulated supply in a host device. As such, I need to be aware of the device's power usage - both peak and net - and stay within the existing power envelope at all times. While sleep mode might be helpful for net power usage, it does nothing for peak usage.

The existing (25-year-old) device consumes about 6mA. While I probably have a little bit of leeway, I want to stay as close as possible to the original power envelope... and with today's technology, it should be possible to do so (although maybe not with these specific parts).

I measured the nRF52832 power consumption as follows:
- before pairing: jumped between 24 and 32 mA
- once paired: 16-19mA

This is with the M4F core at 64MHz.

Based on what I had measured on the ItsyBitsy M4, if I cut this in half down to 32MHz, I should be able to reduce consumption between 4 and 6 mA, which would be generous step in the right direction. A further drop by half - to 16MHz - would yield an additional 2 to 3 mA.

Hopefully this helps to contextualize why I'm concerned about power usage beyond the application of sleep modes.

dshadoff
 
Posts: 14
Joined: Fri Mar 22, 2019 8:01 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by pcaddict on Mon Jun 10, 2019 9:26 pm

What are you powering from the feather? Are the power measurements you listed for the feather only? Are you doing any floating point math? Based on a 4dBm TX setting, the most the feather should pull is somewhere around 8.5mA if the internal DCDC regulator is enabled. Without the internal DCDC regulator the peak TX current rises to near 17mA. It looks like the feather may have the required inductor for the internal DCDC regulator but I am not positive as the reference circuit shows two inductors whereas the feather only shows one.

You could try enabling the internal regulator by placing NRF_POWER->DCDCEN = 1; in main and see if your power consumption drops.

pcaddict
 
Posts: 69
Joined: Thu Aug 31, 2017 9:24 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by dshadoff on Tue Jun 11, 2019 12:08 am

In answer to your questions...
- I am not powering anything from the feather
- power measurements are for the feather itself, taken by a USB power meter at 2-3 samples per second; most of the time they don't jump around too much, but do seem to shift according to distinct 'states' (i.e. boot up; pairing; operation once paired)
- no floating point math in use; I am just using the example "central HID" script, modified to also catch mouse events

Then I tried the line of code you mentioned, and it had an effect:
- startup was still in the ~20-25mA area for several seconds, even though I put the line of code as early as I dared, after blue fruit instantiation/initialization
- HOWEVER, after that - even without pairing - the current usage dropped considerably after that. Instead of ~16-19mA, the usage went to 6-10mA.

Thanks !

dshadoff
 
Posts: 14
Joined: Fri Mar 22, 2019 8:01 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by pcaddict on Tue Jun 11, 2019 9:37 am

Try enabling the DCDC regulator before you initialize bluetooth. The NRF52 has internal DCDC and LDO regulators that it can switch between depending on current consumption. Since the DCDC regulator is more efficient at higher current you're missing a lot of its benefit by enabling it after initializing bluetooth. You should be able to completely eliminate the high current spikes above 10mA.

pcaddict
 
Posts: 69
Joined: Thu Aug 31, 2017 9:24 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by dshadoff on Tue Jun 11, 2019 10:17 pm

OK, I tried that, but there was no difference in the startup period (10-15 seconds).

But I found a loose thread I need to unravel:
The first few lines of this example sketch try to print something to the serial port if it's available; waiting for a several-second period.
I thought it would be interesting to check the serial output after the power drain dropped to the low level: When I opened the serial port monitor on the PC, the power drain jumped up to 20mA again.

I'm not sure whether this is due to direct power drain to the serial port circuitry, or whether this forces an override of the DCDC regulator back to the LDO.
This weekend, I'll try checking power drain while driving the device from a separate 3.3V supply (avoiding the USB port altogether).

dshadoff
 
Posts: 14
Joined: Fri Mar 22, 2019 8:01 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by pcaddict on Wed Jun 12, 2019 7:23 am

Looks like the CP2102 USB/UART can use between 20 and 26mA during normal operation.

pcaddict
 
Posts: 69
Joined: Thu Aug 31, 2017 9:24 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by dshadoff on Fri Jun 14, 2019 7:04 pm

Wow, BIG difference between being USB-powered and being powered from an external 3.3V supply.

The external 3.3V supply booted and stayed in the 6-7mA area until pairing.
Once paired, it dropped to 2-3mA.
(I left the last version of the sketch on the device - the one which enabled the DC-DC regulator).

This level of power consumption is very nice !

I'm sure somebody around here might assume that the difference is due to the 5V->3.3V regulator, but I don't. I'm pretty sure it's because when power is supplied from USB, some USB-related circuitry is on (but is disabled when the power doesn't come via USB), and this circuitry consumes a lot of power.

dshadoff
 
Posts: 14
Joined: Fri Mar 22, 2019 8:01 pm

Re: Adafruit Feather nRF52 Bluefruit LE - nRF52832 CPU clock

by jpconstantineau on Sun Jun 16, 2019 10:22 pm

Power usage on the nrf52832 depends greatly on how you code the application and how long it goes into low power mode. For example, for a keyboard application I have with a standalone nrf52832 module (no serial, no LEDs), a power consumption of about 1.5 mA (BSP 0.11.0). When not managed properly, it can easily use 7.5 mA. Have a look at this video video and you will see that when broadcasting BLE, current is well above 10-20mA. However, this is for a very brief period. When not broadcasting, the processor "might" still be doing something and it's the time between BLE broadcasts that actually has the greatest impact on average power consumption. If the CPU is "active" and running, current is in the range of 5-7 mA. When in low power mode, it's quite low (I am not sure exactly how low).

I suspect your unpaired code has room where power usage could be improved.

Troubleshooting power usage isn't easy. I have spent countless hours trying things and sometimes doing something has the opposite effect of what you would think.

When in deep sleep (a change in voltage on a pin will wake up the chip. i.e a key being pressed), the nrf52832 uses about 1uA. That's pretty low for most battery applications. When pressing a key, a hardware event is generated and that wakes up the nrf52 and it boots up similarly to when first powered up (goes through bootloader, etc). That takes a bit of time...

jpconstantineau
 
Posts: 42
Joined: Tue Nov 13, 2018 12:30 pm

Please be positive and constructive with your questions and comments.