Browse Source

soc: arm: nordic_nrf: timing: Fix wrapping

Fix wrapping case for SoC with 32 bit TIMER.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
pull/77285/head
Krzysztof Chruscinski 4 years ago committed by Anas Nashif
parent
commit
cd3dae7c2c
  1. 6
      soc/nordic/timing.c

6
soc/nordic/timing.c

@ -47,14 +47,14 @@ uint64_t soc_timing_cycles_get(volatile timing_t *const start, @@ -47,14 +47,14 @@ uint64_t soc_timing_cycles_get(volatile timing_t *const start,
{
#if defined(CONFIG_SOC_SERIES_NRF51X)
#define COUNTER_SPAN BIT(16)
#else
#define COUNTER_SPAN BIT64(32)
#endif
if (*end >= *start) {
return (*end - *start);
} else {
return COUNTER_SPAN + *end - *start;
}
#else
return (*end - *start);
#endif
}
uint64_t soc_timing_freq_get(void)

Loading…
Cancel
Save