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

timer not working when duration is too high #22268

Closed
ifillonneau opened this issue Jan 28, 2020 · 3 comments
Closed

timer not working when duration is too high #22268

ifillonneau opened this issue Jan 28, 2020 · 3 comments
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug

Comments

@ifillonneau
Copy link
Contributor

Describe the bug
Starting a timer with huge time make the timer trigger without waiting.
Ex: k_timer_start(&timer, K_HOURS(19), 0); does not work at all whereas k_timer_start(&timer, K_HOURS(18), 0); is working. The problem seems to come from conversion from duration to tick witch is limited to signed 32 bits. as soon as the conversion in tick is greater than 0x7FFFFFFF, the timer is not working at all.

To Reproduce

#include <zephyr.h>
#include <kernel.h>

static void handler(struct k_timer *dummy)
{
	printk("handler called\n");
}

K_TIMER_DEFINE(timer, handler, NULL);

void main(void)
{
	printk("test Timer !\n");
#ifdef NOT_WORKING
	k_timer_start(&timer, K_HOURS(19), 0); // handler is called immediately
#else
	k_timer_start(&timer, K_HOURS(18), 0); // handler is called after 18 hours
#endif
}

Steps to reproduce the behavior:

  1. mkdir build; cd build
  2. cmake -DBOARD=nrf52_pca10040 path_to_above_main
  3. make

Expected behavior
timer to trigger after 19 hours

Impact
showstopper

Environment (please complete the following information):

  • OS: Linux
  • Toolchain Zephyr SDK
  • Commit SHA or Version used: 10fb64f
@ifillonneau ifillonneau added the bug The issue is a bug, or the PR is fixing a bug label Jan 28, 2020
@SebastianBoe
Copy link
Collaborator

Duplicate of #19075 ?

@ifillonneau
Copy link
Contributor Author

@SebastianBoe , yes, this is the same behavior, and the same root cause

@jhedberg
Copy link
Member

Closing since #19075 seems to be a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

4 participants