Skip to content

Commit 15a347b

Browse files
yeaissanashif
authored andcommitted
drivers: mcux_os_timer: Add Kconfig option for MIN_DELAY configuration
Introduce CONFIG_MCUX_OS_TIMER_MIN_DELAY to allow the configuration of the minimum delay cycles. Signed-off-by: Yassine El Aissaoui <[email protected]>
1 parent 3e081ac commit 15a347b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

drivers/timer/Kconfig.mcux_os

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@ config MCUX_OS_TIMER_PM_POWERED_OFF
2121
OS Timer is turned off in certain low power modes. When this option is
2222
picked, OS Timer will take steps to store state and reinitialize on wakeups.
2323

24+
config MCUX_OS_TIMER_MIN_DELAY
25+
int "Minimum delay cycles for OS timer match value"
26+
default 1000
27+
help
28+
Timer hardware requires a minimum setup time to reliably trigger
29+
interrupts. If a match value is set too close to the current timer
30+
count, the hardware may not have enough time to process it.
31+
Lower values can improve timing precision but may be less reliable.
32+
Higher values provide more safety margin but slightly reduce timing accuracy.
33+
2434
endif # MCUX_OS_TIMER

drivers/timer/mcux_os_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define CYC_PER_US ((uint32_t)((uint64_t)sys_clock_hw_cycles_per_sec() / (uint64_t)USEC_PER_SEC))
2929
#define MAX_CYC INT_MAX
3030
#define MAX_TICKS ((MAX_CYC - CYC_PER_TICK) / CYC_PER_TICK)
31-
#define MIN_DELAY 1000
31+
#define MIN_DELAY CONFIG_MCUX_OS_TIMER_MIN_DELAY
3232

3333
static struct k_spinlock lock;
3434
static uint64_t last_count;

0 commit comments

Comments
 (0)