Skip to content
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

Higher power usage in deep sleep with v1.4 #12

Open
woutervhoof opened this issue Apr 26, 2023 · 7 comments
Open

Higher power usage in deep sleep with v1.4 #12

woutervhoof opened this issue Apr 26, 2023 · 7 comments

Comments

@woutervhoof
Copy link

Hi,

I have trouble using the deep sleep function of the nrc7292. I tried the sample_ps_standalone sample from the SDK v1.4 on a silex sx-newah module. It's just the module and some decoupling capacitors, so no other components connected. When I try the sample code, i get about 790uA in deep sleep.

thumbnail_img0421_224006

I tried the same sample_ps_standalone sample code but the older version from SDK v1.3.4. With the older version, i measure about 580uA.

thumbnail_img0421_222813

It seems that the nrc_ps_deep_sleep function from the newest SDK is worse than the previous one as it uses about 200uA more.

Apart from that, I think the power usage in deep sleep is still extremely high. 600uA for a microcontroller in deep sleep seems a lot to me and not really useful for a battery powered device. Especially when they specify that Wi-Fi Halow supports coin cell battery devices.

What am I doing wrong or is it something that has to be fixed in the future?

Thanks in advance!

@puffie
Copy link

puffie commented May 30, 2023

Hi woutervhoof,
With SDK 1.4, a user needs to set the GPIO's to correct state that will not leak the current during deep sleep.
One should use following API's to set correct GPIO pin states.
nrc_ps_set_gpio_direction(uint32_t gpio_direction_mask); // direction_mask bit set to 0 means input, and 1 means output. i.e. 0xFFFFFFFF will set all of the GPIO's to direction output.
nrc_ps_set_gpio_out(uint32_t output_mask); // output_mask bit set to 1 to output high and 0 to output low. i.e. 0x0 will output low for all of the GPIO's.
nrc_ps_set_gpio_pulllup(uint32_t pullup_mask; // If any of the GPIO pin is selected for input, one can change if the GPIO should be internally pull high or low.
i.e. nrc_ps_set_gpio_direction(0xFFFFFF3F); // Set GPIO 6 and GPIO7 as input.
nrc_ps_set_gpio_out(0x0); // all of the GPIO pins set to direction output will be outputting low.
nrc_ps_set_gpio_pullup(0x00000040); // GPIO 6 will be pulled high and GPIO 7 will float (match voltage from input).

Since Silext newah module exposes GPIO pin from 0 to 17 to outside world, you can assume GPIO 18 to GPIO 31 are not connected to anything and you will need to set correct states for GPIO 0 - 17 depends on how those pins are connected to out side world.

Assuming your circuit does not have GPIO 0 to 17 connected to nothing.
I suggestion below settings made right before going to sleep.

nrc_ps_set_gpio_direction(0xFFFFFFFF);
nrc_ps_set_pio_out(0);
nrc_ps_set_gpio_pullup(0);

If there are any GPIO pins used, make adjustment please.

Let me know if you have any question.

@woutervhoof
Copy link
Author

woutervhoof commented May 31, 2023

Hi @puffie

Thanks for your answer!

I'm aware of the nrc_ps_set_gpio functions but they don't work for me. I raised this as an issue but haven't got any support on that problem.

I tried your code again to check if I didn't make a mistake the previous times . I used following code:
nrc_ps_set_gpio_direction(0xFFFFFCFF); // Set GPIO 8 and GPIO9 as input.
nrc_ps_set_gpio_out(0x0); // all of the GPIO pins set to direction output will be outputting low.
nrc_ps_set_gpio_pullup(0x00000100); // GPIO 8 will be pulled high and GPIO 9 will float (match voltage from input)

If I'm not wrong, this should set GPIO 8 and 9 as input. I inserted this code right before I call the deep sleep function. When I measure the pins on the module, nothing changed. It looks like the set values are always overwritten with output low, except for the UART pins. I tried putting the gpio functions on other places in the code but that had the same result.

Do these functions work for you? And do you have working code I can test on my module?

Thanks in advance!

@puffie
Copy link

puffie commented May 31, 2023

It seems that setting GPIO pin to input and pulling the pin to high isn't quite working as expected. I was getting the voltage of 0.8v instead of system voltage (3.3V) during deep sleep.
I'm thinking that you can set GPIO pin 8 to direction output, and set the pin to output high.

With below code in sample_ps_standalone.c, GPIO 8 was outputting 3.3v.

#if defined(WAKEUP_GPIO_PIN)
nrc_ps_set_gpio_wakeup_pin(false, WAKEUP_GPIO_PIN);
wakeup_source |= WAKEUP_SOURCE_GPIO;
#endif /* defined(WAKEUP_GPIO_PIN) */

wakeup_source |= WAKEUP_SOURCE_RTC;
nrc_ps_set_wakeup_source(wakeup_source);

/* To detect disconnections, the operation time must exceed 3 seconds. */
user_operation(3000);

nrc_ps_set_gpio_direction(0xFFFFFDFF);
nrc_ps_set_gpio_out(0x00000100);
nrc_ps_set_gpio_pullup(0x0);

while (1) {
	/* Try to enter deepsleep */

#if TIM_DEEPSLEEP
/* STA can wake up if buffered unit is indicated by AP or timeout is expired.
(if gpio is set for wakeup source, STA also can wake up by gpio input) /
if (nrc_ps_wifi_tim_deep_sleep(IDLE_TIMEOUT, SLEEP_TIME_MS) == NRC_SUCCESS) {
#else
/
STA can wake up if timeout is expired.
(if gpio is set for wakeup source, STA also can wake up by gpio input) */
if (nrc_ps_deep_sleep(SLEEP_TIME_MS) == NRC_SUCCESS) {
#endif

I also set "SLEEP_TIME_MS" to 0 to disable periodic wake up. The original code was waking up every 5 sec on top of TIM mode sleep.

@woutervhoof
Copy link
Author

Hi @puffie

Thanks for your answer!

I tested the code this afternoon and didn't succeed in pulling pin 8 high. I used the sample_ps_standalone.c and your code on the exact same place. I tested it in TIM and non-TIM mode.

Weird that the code works for you... :/
Which version of the SDK are you using? I'm using the latest version. And does it matter that I'm using a module from Silex?

Thanks in advance!
Wouter

@puffie
Copy link

puffie commented Jun 2, 2023

I confirmed that there's an issue in SDK. There will be new SDK release soon.

@woutervhoof
Copy link
Author

Great! Looking forward to that!

Another question... What is the current consumption you achieve in deep sleep? Like I mentioned in the first post, i got around 700uA.

@AkhilPuranik
Copy link

Hi Everyone,
I am curious to know if there is any update about the issue resolution in the newer SDK. if yes can you share the current consumption recorded during sleep and deep sleep modes? I need this information to decide if I can use NRC7292 for battery-operated devices. If 550uA is the least consumption it can reach, then that might drain the batteries soon.

Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants