2016-03-17 05:22 AM
Hi,
I'm trying to get the value of the CYCCNT in a STM32F746 Nucleo Board. Code is as follows:
// Configuring DEMCR & CTRL registers
CoreDebug->DEMCR &= ~0x01000000;
CoreDebug->DEMCR |= 0x01000000;
DWT->CTRL &= ~0x00000001;
DWT->CTRL |= 0x00000001;
DWT->CYCCNT = 0;
//Do something...
uint32_t Count = DWT->CYCCNT;
Registers were not written, and Count is always zero.
Has anyone faced a similar issue?
I employ the same code for Cortex M4 STM32F4xx MCUs, and it works perfect!
Thanks,
#stm32f746zgtx-dwt-issue
2016-03-17 07:58 AM
Has anyone faced a similar issue?
Yes, and it has been covered here before, you need to unlock access to the registers. Google a bit, something will come up.2016-03-17 08:27 AM
Thanks for the reply,
A functional code is as follows:
1.
DWT->LAR = 0xC5ACCE55;
// Unlock code
2.
3.
DWT->CTRL |= 0x01;
4.
DWT->CYCCNT = 0;
5.
6.
// Do something...
7.
8.
uint32_t Count = DWT->CYCCNT;