-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Description of defect
Given the datasheet of the components mentioned in the title I expect a low power consumption of:
- STM32L476RG of around 10/20uA in STOP mode (I think the default is STOP2)
- sx1262 of a 1/2uA in sleep mode
I am getting an unusual behavior with higher power consumption ~800uA (On Average).
Target(s) affected by this defect ?
Custom board based on STM32L476RG, the configuration is identical to NUCLEO_L476RG.
pinmap:
PA_4 NSS
PA_5 SCK
PA_6 MISO
PA_7 MOSI
PA_8 RESET
PA_9 BUSY
PB_1 DIO1
PB_0 ANTSW (not used)
Toolchain(s) (name and version) displaying this defect ?
I am using the mbed os master branch.
What version of Mbed-os are you using (tag or sha) ?
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
mbed-cli version 1.10.5
arm-none-eabi-g++ (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release)
How is this defect reproduced ?
The following is a sample code I wrote to replicate the behavior without using the complete LoraRadio object.
The code takes some snippets of code from connectivity/drivers/lora/COMPONENT_SX126X/SX126X_LoRaRadio.cpp
to wake the radio up wakeup_radio()
and put it to sleep sleep_radio()
.
The code does the following:
- Create spi object and Digital In/Outs simulating the LoraRadio object
- Turn on the reset pin for 200ms
- call sleep_radio function
- put the stm device in STOP mode
- call wakeup_radio function
- wait 1s
- call sleep_radio function
- go to step 4
#include <mbed.h>
SPI spi(PA_7, PA_6, PA_5);
DigitalOut _chip_select(PA_4, 1);
DigitalIn _busy(PA_9, PullNone);
DigitalInOut reset_ctl(PA_8);
InterruptIn _dio1_ctl(PB_1, PullNone);
void sleep_radio(void) {
// warm start, power consumption 600 nA
uint8_t sleep_state = 0x04;
_chip_select = 0;
while (_busy) {
// do nothing
printf(".");
}
printf("\n");
spi.write(0x84); // SLEEP command
spi.write(sleep_state);
_chip_select = 1;
ThisThread::sleep_for(2);
}
void wakeup_radio() {
// hold the NSS low, this should wakeup the chip.
// now we should wait for the _busy line to go low
_chip_select = 0;
while (_busy) {
// do nothing
printf(".");
}
printf("\n");
_chip_select = 1;
}
#define TIME 5s
int main() {
printf("\n\nTesting SPI power consumption\n\n");
printf("putting radio to sleep\n");
reset_ctl=1;
ThisThread::sleep_for(200ms);
reset_ctl=0;
sleep_radio();
ThisThread::sleep_for(200ms);
printf("radio sleeping\n");
while (1) {
ThisThread::sleep_for(1000ms);
printf("\n\ndeep sleep time\n");
ThisThread::sleep_for(TIME);
printf("waking radio\n");
wakeup_radio();
printf("radio awake\n");
ThisThread::sleep_for(1000ms);
printf("putting radio to sleep\n");
sleep_radio();
ThisThread::sleep_for(200ms);
printf("radio sleeping\n");
}
}
The following is a screenshot captured with an otii of the power consumption of the device I am talking about. It contains the recording of some cycles of the code described before.
The strange thing is that on the first cycle the power consumption is as intended and after the power consumption rises to 300uA.