I'm trying to get the DWT cycle counter working for a STM32 STM32F3 ARM Cortex CPU inside the Embedded Studio debugger. For this, I am using the following code.
However, the cycle counter always returns 0 - in other words, it is not running.
Can someone help me to get this working inside the debugger?
Thanks and cheers,
Razer6
C Source Code
- void main(void) { int i; volatile uint32_t *DWT_CONTROL = (uint32_t *) 0xE0001000; volatile uint32_t *DWT_CYCCNT = (uint32_t *) 0xE0001004; volatile uint32_t *DEMCR = (uint32_t *) 0xE000EDFC; volatile uint32_t *LAR = (uint32_t *) 0xE0001FB0;
- *DEMCR = *DEMCR | 0x01000000; // enable trace *LAR = 0xC5ACCE55; // <-- added unlock access to DWT (ITM, etc.)registers *DWT_CYCCNT = 0; // clear DWT cycle counter *DWT_CONTROL = *DWT_CONTROL | 1; // enable DWT cycle counter
- for (i = 0; i < 100; i++) { printf("Hello World %d!\n", i); }
- uint32_t count = *DWT_CYCCNT; printf("Count is %d\n", count);
- do { i++; } while (1);}
However, the cycle counter always returns 0 - in other words, it is not running.
Can someone help me to get this working inside the debugger?
Thanks and cheers,
Razer6