dwt_delay
dwt_delay copied to clipboard
Cortex M7 support
Hi, I cannot make it work under STM32F769, perhaps the unlocking sequence.
void DWT_Init(void)
{
if (!(CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)) {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->LAR = 0xC5ACCE55;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
}
}
I have place the init after SystemClock_Config such
SystemClock_Config();
DWT_Init();
What am I missing?
Thanks,
The problem seems to be the if clause
if (!(CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)) {
For some reason it returns false, such as if it was been enable.
I have this in F730 and seems to work as expected: `void DWT_Init(void) {
DWT->LAR = 0xC5ACCE55;
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
}`
Thanks for pointing this out!
I'd suggest to make explicit initialization on STM32F7 without condition. And as it turned out to work ok, i'd rather remake that if
condition some day, when i get F7 on hands to experiment.
Thanks again for sharing your experience!