-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
drivers: timer: Improve the accuracy of the MCUX OS Timer #84938
base: main
Are you sure you want to change the base?
drivers: timer: Improve the accuracy of the MCUX OS Timer #84938
Conversation
mmahadevan108
commented
Jan 30, 2025
- The sys_clock_idle_exit function could be invoked multiple times. Hence add code so that is counter is stopped and the OS Timer is initialized once.
- Reset the OS Timer when exiting low power modes where the OS Timer loses its state
- Improve the cycles conversion algorithm
1. The sys_clock_idle_exit function could be invoked multiple times. Hence add code so that is counter is stopped and the OS Timer is initialized once. 2. Reset the OS Timer when exiting low power modes where the OS Timer loses its state 3. Improve the cycles conversion algorithm Signed-off-by: Mahesh Mahadevan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the commit message is not clear about what the "improve cycles conversion algorithm" actually entails
is it possible to split these changes into 3 commits to make the changes easier to understand?
/* Counter is set to wakeup the system after the requested time */ | ||
if (counter_start(counter_dev) != 0) { | ||
ret = 1; | ||
} | ||
counter_running = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if counter_start fails, shouldn't counter_running be set to false ?
|
||
timeout = k_ticks_to_us_ceil32(curr_timeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change from ceil to near ? can it be in the commit message
|
||
/* Counter is set to wakeup the system after the requested time */ | ||
if (counter_start(counter_dev) != 0) { | ||
ret = 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this moved before getting the timer value ? I didn't understand from the commit message
mcux_lpc_ostick_isr(NULL); | ||
/* Announce the time slept to the kernel*/ | ||
mcux_lpc_ostick_isr(NULL); | ||
} | ||
} else { | ||
ret = 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole function is confusing to read, it can be cleaned up by inverting the conditionals, like
if (!counter_dev) {
return 1;
}
if (!counter_running) {
return 0;
}
/* rest of the code */
return 0;