-
• #2
I think you just need this in BOARDNAME.py:
'makefile' : [ 'DEFINES += -DESPR_LSE_ENABLE ',
-
• #3
Thank you so much! I will do some digging...
What about D0 being P0.00/XL1 and D1 being P0.01/XL2. Is this true?
-
• #5
the software config is here https://github.com/espruino/Espruino/blob/master/targets/nrf5x/bluetooth.c#L2365
If you would use Nordic SDK directly, LF source it is typically chosen in the SDK config file https://github.com/espruino/Espruino/blob/master/targetlibs/nrf5x_12/nrf52_config/sdk_config.h#L262 (in newer SDKs there are actually two settings there to change, one generic and one for the softdevice)
-
• #6
It is very clear. Thank you very much!
So I guess I have to reassign the Espruino DFU/reset Pin to something other than D0 to have this feature working?
Maybe by modifyingD0
in line'BTN1' : { 'pin' : 'D0', 'pinstate' : 'IN_PULLDOWN' }
of fileMDBT42Q.py
withD3
. -
• #7
Oh, so you want to add crystal to existing MDBT42Q board? And now I also noticed
I would like to use the external low-frequency 32678 kHz crystal to improve the board power consumption when used as a beacon.
How much of power you expect to save? It may not be that much and it is likely other components on board may draw more. See e.g. this https://devzone.nordicsemi.com/f/nordic-q-a/25540/is-external-crystal-neccessary-at-all-on-52832/100707#100707 so it is really not much. Was thinking you already have board with the crystal and just want to enable it so it is not sitting there wasted.
And BTW there is also the builtin DCDC converter, it could save more if used , that is however more complicated to enable as it needs more components. see https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/power.html?cp=4_2_0_17_0#topic and https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/ref_circuitry.html?cp=4_2_0_52_1#schematic_qfn48_dcdc
just googled and here https://www.programmersought.com/article/18503111047/ someone claims enabling DC/DC can save 40% and crystal 1-2%
Anyway, yes those board file changes will help freeing D0 pin, however you need to build and update also the bootloader as that is where the button is actually checked.
-
• #8
Sorry for being that little clear: I don't have a MDBT42Q board. I want to define my own definition board, and I thought
MDBT42Q.py
was a good start...Indeed I do have a board with a low-frequency crystal (actually it is still in the mail) and I want to enable it so it is not sitting there wasted + to save some power.
I have 2 nRF52832 boards I would like to use as beacons:
- a Holyot YJ-17095 without any external low-frequency crystal,
- a FEASYCOM FSC-BT630 equipped with a MCU-external though board-embedded low-frequency crystal.
I used the standard
MDBT42Q.py
definition file to build the firmware for the Holyot board.
I would like to write a board definition file for the FEASYCOM that:- enables its MCU-external though board-embedded low-frequency crystal +
- sets a pin to let the board enter DFU mode / hard reset mode.
I did some power measurements on nRF51822 boards programmed as beacons (not nRF52832 boards though, not Espruino based) using the NORDIC Power Profiler Kit II, and I came out with this comparison chart:
Low-Frequency Oscillator Average Current Consumption @ 3V External 32768 kHz crystal 7.85 uA Internal RC circuit 8.24 uA (14% more) Thus I expect to save about 14%. This result corroborates this discussion on Nordic DevZone Q&A.
Once I successfully generate an optimised Esprino firmware for my FEASYCOM board, I would like to do the same comparison...
I did some measurements on the Holyot board programmed as a beacon using Espruino and was impressed by its low power consumption already!
However I also noticed little current spikes here and there in-between two broadcasting emissions (the board was sleeping?) that might be due (I have no clue though) to the use of the RC internal oscillator.
This is why I would like to try the same code on the FEASYCOM board which Espruino firmware is built enabling its low-frequency crystal (+ redefining the reset pin to be able to exit the
NRF.setAdvertising
mode easily).- Regarding the builtin DC/DC converter, I need to understand how to enable it using Espruino?
- Regarding the bootloader, I need to understand how to account for that new button pin definition?
- a Holyot YJ-17095 without any external low-frequency crystal,
-
• #9
That post you linked is excellent summary, thank you. Of course the calibration takes power, nice someone took care to compute that part too.
BTW if schematics in the Holyot YJ-17095 page is correct the DCDC should be supported there. It saves most power when current is high = bluetooth transmit. Now found source for information in that article I linked previously here https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/optimizing-power-on-nrf52-designs
For enabling DCDC define
ESPR_DCDC_ENABLE
as checked here https://github.com/espruino/Espruino/blob/99541c982aeef8114374cc673919fc42f1f874c7/targets/nrf5x/bluetooth.c#L2458 -
• #10
Great that the Holyot YJ-17095 board supports the DC/DC regulator!
It seems that the FEASYCOM FSC-BT630 board supports the DC/DC regulator too (see board datasheet, page 11, 4. PHYSICAL INTERFACE, 4.1 Power Supply).I will compare power consumption of the FEASYCOM FSC-BT630 used as a beacon, programmed using Espruino, for all the different setting combinations (as soon as I receive it).
AVERAGE POWER CONSUMPTION (in uA @ 3V):
Low-Frequency Oscillator / Internal Power Supply Regulator LDO (Default) DC/DC Internal RC Circuit (Default) ? ? External 32.768 kHz Crystal ? ? To let the bootloader take into account the new reset pin definition D3, I modified my board definition file with
'BTN1' : { 'pin' : 'D3', 'pinstate' : 'IN_PULLDOWN' }
and invokedmake
with argumentBOOTLOADER=1
. Is this enough?The Espruino documentation is top-notch and the file entitled Espruino Internals: Build Process explains how to enable the low-frequency crystal and the DC/DC converter as well:
'makefile' : [ 'DEFINES += -DESPR_LSE_ENABLE ', # to enable low-frequency crystal 'DEFINES += -DESPR_DCDC_ENABLE', # to enable DC/DC converter
@Gordon : Can you tell me how to get the Donated badge under my name in the forum? I did donate during the Bangle.js Kickstarter campaign and I own official Espruino boards (Pico, Puck.js) + your book.
-
• #11
I modified my board definition file with 'BTN1' : { 'pin' : 'D3', 'pinstate' : 'IN_PULLDOWN' } and invoked make with argument BOOTLOADER=1. Is this enough?
The line
'bootloader' : 1,
here enables bootloader and it is built as part of running make. If you use SWD you can even disable bootloader by setting value 0 there to make it more simple. Anyway when checking MDBT42Q.py board definition now, there is also LED1 on pin D1 so that one needs to be moved too. LED1 is optional so you can remove it completely. Button is also optional if you disable bootloader. Also you can set thedefault_console
toEV_BLUETOOTH
if you want to remove serial pin definitions too. -
• #12
Thank you!
I already had removedLED1
from the definition file.
I keptBTN1
(set toD3
thought for the FEASYCOM FSC-BT630 board) to allow HARD RESET mainly, but to perform DFU upgrade too as I find it a nice feature. I was thinking to use SWD to flash the firmware only once and to perform next upgrades OTA.
Thanks to your assistance, I just switched the default console to bluetooth and removeddefault_console_tx
anddefault_console_rx
from the definition file.I am currently experimenting with my Holyot YJ-17095 board and will try it enabling the DC/DC regulator. I will make screenshots to observe the current spikes I was talking of and to compare power consumptions.
-
• #13
Hi @sebi! You mean you donated extra on the KickStarter campaign?
The badge is semi-automated and I hadn't actually added those who'd contributed in the campaign (just by http://www.espruino.com/Donate) so that's why you didn't show up. I'll add you on the list, and the next website update should have that in. Thanks!
-
• #14
@Gordon : I bought a pixel during the Bangle.js campaign. It is peanuts but I made sure to buy official boards and your book. I thought the donated badge was automatic when buying something during the campaign and it could be a mistake... I realise buying/donating are two different things. Additionally it is not worth putting that badge for peanuts.
-
• #15
@MaBe pointed out to me that I can get inspired from the Bangle.JS2 board definition file to tweak my boards' settings.
-
• #16
It seems enabling the DC/DC regulator doesn't improve (always?) performances: check my post on GitHub where I compare different settings on a nRF51 board programmed to be a beacon in C. Enabling the low-frequency crystal does improve power consumption thought.
I am planning to do the same comparison with my FEASYCOM FSC-BT630 (nRF52) as soon as I get it. Additionally I would like to compare the beacon when programmed using Espruino (see this post for the original code). But from my current tries with my Holyiot YJ-17095 board, it seems the Espruino version consumes about 45uA so about 5 to 6 times more than the beacon version in C.
I can't explain this as I thought
NRF.setAddress(mac); NRF.setAdvertising(adv, {interval:5000});
required restarting the BLE stack with different settings (disabling the communication with the IDE, etc) that would make this code running very similar to the code directly generated from C.
-
• #17
EDIT: I moved the content of this post to another thread in the forum as I plan to publish the code on Espruino App loader once it is finalized and refer to it for explanations.
-
• #18
But from my current tries with my Holyiot YJ-17095 board, it seems the Espruino version consumes about 45uA so about 5 to 6 times more than the beacon version in C
It seems something was wrong with my preliminary tests on the Holyiot YJ-17095 board since today I measured an average power consumption on the Puck.js acting as a beacon of only 6.30uA @ 3V (see this post on the forum).
I have a nRF52832 board equipped with an external low-frequency 32678 kHz crystal.
Is there a way to switch the low-frequency oscillator from:
...to generate an espruino build?
I would like to use the external low-frequency 32678 kHz crystal to improve the board power consumption when used as a beacon.
The external low-frequency crystal is connected between P0.00/XL1 and P0.01/XL2 (see enclosed picture).
D0 and D1 are used on the Esprino MDBT42Q board to switch to DFU/reset modes and to light an LED.
1 Attachment