dwt_delay icon indicating copy to clipboard operation
dwt_delay copied to clipboard

Cortex M7 support

Open mhanuel26 opened this issue 5 years ago • 3 comments

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,

mhanuel26 avatar Mar 29 '19 01:03 mhanuel26

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.

mhanuel26 avatar Mar 29 '19 01:03 mhanuel26

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;

}`

arkadiuszmakarenko avatar Jun 14 '20 14:06 arkadiuszmakarenko

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!

keatis avatar Jun 11 '21 20:06 keatis