Hello,
I like to get the current time with a kernel_timer. So I use the function k_uptime_get().
However,with each call the timer starts again from the beginning (from 0).Is there a method how i can bypass that it starts again from 0.
Hello,
I like to get the current time with a kernel_timer. So I use the function k_uptime_get().
However,with each call the timer starts again from the beginning (from 0).Is there a method how i can bypass that it starts again from 0.
Hello,
k_uptime_get() does not reset when you use it. Is it saying "0" every time? I'm guessing youre looking at it with a printk or LOG_XXX function. If so it's probably just not printing the 64 bit number correctly. For instance,
while(1) { printk("%d\n", k_uptime_get()); k_msleep(1000); }
Would print "0" every time because the %d is not expecting a 64 bit number. It's only printing the upper 32 bits which is 0 until 4,294,967,295 milliseconds have elapsed.
If you do this instead:
while(1) { printk("%"PRIu64"\n", k_uptime_get()); k_msleep(1000); }
Then it will print the correct values. Or you could use this if you dont need all 64 bits:
while(1) { printk("%d\n", k_uptime_get_32()); k_msleep(1000); }
thank you for your answer.
enclosed you can see my output. As you can see I have output currenttime. However, with both the system restarts, so that the same number is printed out. After "Tasks_sleep_mode" my system ist entering the IDLE Thread and is waking up with an interrupt. In my Interrupt i am printing the current time. Does the timer starts again after getting out of the IDLE Thread?
If you turn the ticket to privat, it would be better and than I can post a part of my code.
Is it possible?
Hi Tal and Louis,
Thank you a lot for the answers Louis, we appreciate that the community is helping out!
Tal, DevZone is a public forum as you know, and not all that answers are Nordic Employees.
Louis is not a Nordic employee, so if I make the case private, he can no longer see the case.
Instead of making the case private, I suggest that you take one of our samples, for example zephyr/samples/hello_world and re-create the issue in this sample.
This has two advantages:
If you do so, I will try the sample and see if I can figure out what is wrong.
And if Louis want to, he can have a look as well.
Does that work for you?
Regards,
Sigurd Hellevik
Thank you. I find the problem and solve it.
Thanks anyway
Good to hear that you were able to solve it Tal!
Are you able to share how you solved your problem?
I just call the function k_uptime_get one time in my code. Thats why I get the same time, when I print the time
I just call the function k_uptime_get one time in my code. Thats why I get the same time, when I print the time