We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I want to measure microseconds with the Cycle Counter of the DWT-Unit on a STM32F7. After long long searching, I found a lot of examples to do this by setting the CoreDebug->DEMCR register with TRCENA and the DWT->CTRL register with CYCCNTENA.
So it seems to be a very easy code:
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; DWT->CYCCNT = 0; DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
But with this code, nothing happens in the controllregisters (DEMCR and CTRL) all enable bits are 0 and the Cycle Counter doesn't run. I tested with and without a connected ULINKpro. With ULINKpro, the counter is running and my measurement works (CYCCNTENA=1). But without ULINKpro despite with "DWT->CTRL |= 1" stays the CYCCNTENA bit 0 and the counter don't run...
Have anybody an idea, whats the reason for the missing write-access to the control register is? Also tests with "DWT->LAR = 0xC5ACCE55" don't change anything.
After the study of the ARMv7-ArchitectureRM and all the other referenced manuals I'm happy about any new ideas! Maybe I miss any bits in other modules like ITM...?
Thanks a lot!
Thank you Clive for your replay!!!
I compared my code with yours and I think it's the same. All your address defines are equal to my used defines of DWT and CoreDebug register from the CMSIS.
I found my misstake arround that code sequence. I test the access to the DWT->CTRL and the Lock-Present Bit by reading out the LSR register before I set the TRCENA in SCB_DEMCR. So all registers give back Zeros...
Thank you.