drivers: timer : cortex_m_systick MAX_TICKS protection
when CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC set to 960M and CONFIG_SYS_CLOCK_TICKS_PER_SEC set to 100 the MAX_TICKS will be zero or even negative value, which is not expected. so need add a protection here downgrading the accuracy to its as high as possible also add build message to show that tickless has no effect fixes: #36766 there used to be a workaround, not a fix, either change the CONFIG_SYS_CLOCK_TICKS_PER_SEC=200 or CONFIG_PM to set the CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC to 32678 Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
parent
53374c6257
commit
8add9219a7
@ -17,11 +17,23 @@
|
||||
#define COUNTER_MAX 0x00ffffff
|
||||
#define TIMER_STOPPED 0xff000000
|
||||
|
||||
#define CYC_PER_TICK (sys_clock_hw_cycles_per_sec() \
|
||||
/ CONFIG_SYS_CLOCK_TICKS_PER_SEC)
|
||||
#define MAX_TICKS ((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1)
|
||||
|
||||
#if defined(CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME)
|
||||
extern unsigned int z_clock_hw_cycles_per_sec;
|
||||
#define CYC_PER_TICK (z_clock_hw_cycles_per_sec/CONFIG_SYS_CLOCK_TICKS_PER_SEC)
|
||||
#else
|
||||
#define CYC_PER_TICK (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC/CONFIG_SYS_CLOCK_TICKS_PER_SEC)
|
||||
#endif
|
||||
|
||||
/* add MAX_TICKS protection */
|
||||
#define _MAX_TICKS (int)((k_ticks_t)(COUNTER_MAX / CYC_PER_TICK) - 1)
|
||||
#define MAX_TICKS ((_MAX_TICKS > 0) ? _MAX_TICKS : 1)
|
||||
#define MAX_CYCLES (MAX_TICKS * CYC_PER_TICK)
|
||||
|
||||
#if (COUNTER_MAX / CYC_PER_TICK) == 1
|
||||
#pragma message("tickless does nothing as CONFIG_SYS_CLOCK_TICKS_PER_SEC too low")
|
||||
#endif
|
||||
|
||||
/* Minimum cycles in the future to try to program. Note that this is
|
||||
* NOT simply "enough cycles to get the counter read and reprogrammed
|
||||
* reliably" -- it becomes the minimum value of the LOAD register, and
|
||||
|
||||
Loading…
Reference in New Issue
Block a user