Skip to content

Commit 1647ad5

Browse files
stomschik-askmmahadevan108
authored andcommitted
timing: fix ARM Cortex-M timing functions wrap-around issue
Added casts to uint32_t in arch_timing_cycles_get() to handle the wrap-around of the 32-bit cycle counter correctly. Signed-off-by: Simon Tomschik <[email protected]>
1 parent 5ee9d7a commit 1647ad5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm/core/cortex_m/timing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ timing_t arch_timing_counter_get(void)
104104
uint64_t arch_timing_cycles_get(volatile timing_t *const start,
105105
volatile timing_t *const end)
106106
{
107-
return (*end - *start);
107+
return ((uint32_t)*end - (uint32_t)*start);
108108
}
109109

110110
uint64_t arch_timing_freq_get(void)

0 commit comments

Comments
 (0)