cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746ZGTx DWT Issue

victorfernandez
Associate
Posted on March 17, 2016 at 13:22

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
2 REPLIES 2
Posted on March 17, 2016 at 15:58

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
victorfernandez
Associate
Posted on March 17, 2016 at 16:27

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;