I am using the STM32F7-Discovery board and trying to turn on the DWT loop counter. From what I saw on the Internet, this is enough to turn it on:
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CYCCNT = 0; DWT->CTRL |= 1;
However, when I run this code, the values ββdo not change or the operations are skipped (I'm not sure what is happening).
I tried making pointers to addresses in memory and changing them directly to no avail. Example:
volatile uint32_t *DWT_CONTROL = (uint32_t *) 0xE0001000; volatile uint32_t *DWT_CYCCNT = (uint32_t *) 0xE0001004; volatile uint32_t *DEMCR = (uint32_t *) 0xE000EDFC; *DEMCR = *DEMCR | 0x01000000; *DWT_CYCCNT = 0; *DWT_CONTROL = *DWT_CONTROL | 1;
Currently, the only way I got it is to go with the debugger in Visual Studios (with VisualGDB) if I changed the DWT-> CTRL value to ON, which starts the loop counter. Other than this, however, I cannot force the value to change the code.
Edit: what can cause behavior when these lines of code do not perform their tasks, but also do not fail and continue.
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CYCCNT = 0; DWT->CTRL |= 1;
After starting these lines of code, all values ββin these memory cells remain unchanged and do not change during the execution of operations that should have been performed.
eg.:
This should result in a DWT-> CTRL value of 0x40000001, but it remains the default 0x40000000
The following are examples of what happens at runtime.
Before after
source share