|
@@ -34,16 +34,17 @@
|
34
|
34
|
|
35
|
35
|
#if defined(__arm__) || defined(__thumb__)
|
36
|
36
|
|
37
|
|
- #if __CORTEX_M == 7
|
|
37
|
+ #if WITHIN(__CORTEX_M, 3, 7)
|
38
|
38
|
|
39
|
|
- // Cortex-M7 can use the cycle counter of the DWT unit
|
|
39
|
+ // Cortex-M3 through M7 can use the cycle counter of the DWT unit
|
40
|
40
|
// http://www.anthonyvh.com/2017/05/18/cortex_m-cycle_counter/
|
41
|
41
|
|
42
|
42
|
FORCE_INLINE static void enableCycleCounter() {
|
43
|
43
|
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
44
|
44
|
|
45
|
|
- // Unlock DWT.
|
46
|
|
- DWT->LAR = 0xC5ACCE55;
|
|
45
|
+ #if __CORTEX_M == 7
|
|
46
|
+ DWT->LAR = 0xC5ACCE55; // Unlock DWT on the M7
|
|
47
|
+ #endif
|
47
|
48
|
|
48
|
49
|
DWT->CYCCNT = 0;
|
49
|
50
|
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|