Hi Team,
How to start with the sleepy code in nRF connect desktop SDK, can anyone provide me a refernce which has clear insights?
Thanks,
Pranathi
Hi Team,
How to start with the sleepy code in nRF connect desktop SDK, can anyone provide me a refernce which has clear insights?
Thanks,
Pranathi
Hi,
Th enRF Connect SDK includes the Zephyr RTOS, where there is always a idle thread that enters sleep mode when idle. So you do not need to do anything special to enter sleep, other than don't do anything. Note that for instance having a main loop that runs continiously means using the CPU at all times, so if you do, you can for instance wait with k_sleep() to sleep for a specified ammount of time.
Hi,
Can you provide me a sample code for some clear refernece for my side?
I want to use a timer based sleep mechanism as such I want the board to wake up when I am trying to exhibit a functionlity and after executing it my board should go into sleep and wake up when the said functionlity to be executed. And FYI I am using nRF52840 DK.
Thanks,
Pranathi.
Pranathi CH said:Can I use k_sleep(K_FOREVER) in my code (in main) to make my system go in constant sleep and then use an RTC as a wakeup source to wake the core of my system?
No, that is not how it works. If you don't want the main thread (or any other thread for that matter) anymore, just let it return. The idle task always runs.
Pranathi CH said:I am getting around 5mA of current consumption without any sleep exhibited and I am aiming to reduce the current consumption for a better battery life.
Can you share what you are doing? If for instance you have an eternal loop with no sleep so that the CPU is on 100% that could give you numbers of that magnitude.
I am using a thread that is defined as
int main(void) { #My code# return 0; } void control_thread(void) { while(true) { #My logic# k_sleep(K_MSEC(50)); } } K_THREAD_DEFINE(control, 1024, control_thread, NULL, NULL, NULL, -1, 0, 1000);
I see. Nothing obviously stands out here. If you comment out your logic and keep only the sleep, what current consumption do you measure then? If that is also high, you need to look somewhere else. Either in other parts of the application, or it oculd also be worth looking at your hardware and how you measure the current consumption.
My actual code consists the logic, I just shared you the syntax of where I was using the sleep.
And I didn't check the current consumptions with the code as it is I provided in the above reply, I checked the currents with my logic in it. That's why I have mentioned "my code" and "my logic" so that you can understand that there is some logic I have written there which I couldn't share in the dev zone as it is irrelevant.
I understand. I am not interested in your logic, but if you measure a unexpected high current consumption and want input on what oculd cause it I need to know more about the application you run, the hardweare you are testing on and how you measure.
So, if you would like to proceed, I suggest the following:
I understand. I am not interested in your logic, but if you measure a unexpected high current consumption and want input on what oculd cause it I need to know more about the application you run, the hardweare you are testing on and how you measure.
So, if you would like to proceed, I suggest the following:
Thank you for your comprehension and guidance. I will notify you once I have completed the mentioned procedure.
I am using the nRF52840 development kit for my evaluation.
I currently bought it to 150 uA by using thi function (previously it was 4.8mA).
As I mentionned before, the CPU will sleep by default as long as you don't do anything. But if any peripherals etc are enabled, they will continue to be. What do you use in your application? A typical problem is UART if you have logging enabled. So the first thing you should make sure is to disable logging, by adding configs like these:
CONFIG_CONSOLE=n CONFIG_UART_CONSOLE=n CONFIG_SERIAL=n CONFIG_LOG=n