[PATCH 2/2] bsps/arm: Remove DWT based clock.

Christian Mauderer christian.mauderer at embedded-brains.de
Tue Oct 17 09:46:15 UTC 2017


From: Christian Mauderer <Christian.Mauderer at embedded-brains.de>

It seems that the DWT CYCCNT does not advance when the CPU waits on a
WFI instruction.

That leads to the effect that for example on the atsamv BSP a sleep(1)
needs something in the range of a few minutes (depending on the
configured systick). A debugger might disables some deep sleep modes so
that the problem only appears if the application is executed without a
debugger.
---
 .../arm/shared/armv7m/clock/armv7m-clock-config.c  | 37 ++++------------------
 1 file changed, 7 insertions(+), 30 deletions(-)

diff --git a/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c b/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c
index e03ba9d83f..1c17a92cb5 100644
--- a/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c
+++ b/c/src/lib/libbsp/arm/shared/armv7m/clock/armv7m-clock-config.c
@@ -88,18 +88,6 @@ static void _ARMV7M_TC_systick_tick(void)
   );
 }
 
-static uint32_t _ARMV7M_TC_dwt_get_timecount(struct timecounter *tc)
-{
-  volatile ARMV7M_DWT *dwt = _ARMV7M_DWT;
-
-  return dwt->cyccnt;
-}
-
-static void _ARMV7M_TC_dwt_tick(void)
-{
-  rtems_timecounter_tick();
-}
-
 static void _ARMV7M_TC_tick(void)
 {
   (*_ARMV7M_TC.tick)();
@@ -131,7 +119,6 @@ static void _ARMV7M_Systick_initialize(void)
   #endif
   uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick();
   uint64_t interval = (freq * us_per_tick) / 1000000ULL;
-  bool cyccnt_enabled;
 
   systick->rvr = (uint32_t) interval;
   systick->cvr = 0;
@@ -139,23 +126,13 @@ static void _ARMV7M_Systick_initialize(void)
     | ARMV7M_SYSTICK_CSR_TICKINT
     | ARMV7M_SYSTICK_CSR_CLKSOURCE;
 
-  cyccnt_enabled = _ARMV7M_DWT_Enable_CYCCNT();
-  if (cyccnt_enabled) {
-    _ARMV7M_TC.base.tc.tc_get_timecount = _ARMV7M_TC_dwt_get_timecount;
-    _ARMV7M_TC.base.tc.tc_counter_mask = 0xffffffff;
-    _ARMV7M_TC.base.tc.tc_frequency = freq;
-    _ARMV7M_TC.base.tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
-    _ARMV7M_TC.tick = _ARMV7M_TC_dwt_tick;
-    rtems_timecounter_install(&_ARMV7M_TC.base.tc);
-  } else {
-    _ARMV7M_TC.tick = _ARMV7M_TC_systick_tick;
-    rtems_timecounter_simple_install(
-      &_ARMV7M_TC.base,
-      freq,
-      interval,
-      _ARMV7M_TC_systick_get_timecount
-    );
-  }
+  _ARMV7M_TC.tick = _ARMV7M_TC_systick_tick;
+  rtems_timecounter_simple_install(
+    &_ARMV7M_TC.base,
+    freq,
+    interval,
+    _ARMV7M_TC_systick_get_timecount
+  );
 }
 
 static void _ARMV7M_Systick_cleanup(void)
-- 
2.12.3




More information about the devel mailing list