cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot get DWT counter running on STM32H750XB (STM32H750-DK) ?

bully
Senior

Hello,

I'm trying to enable and read DWT counter from assembly on STM32H750-DK board.

My code is :

// Register Addresses
 
	.equ     DEMCR,   		0xe000edfc // DEMCR reg
	.equ     DWT_CYCCNT,   	0xE0001004 // DWT_CYCCNT reg (RM, pp.3211)
	.equ     DWT_CTRL,   	0xE0001000 // DWT_CTRL   reg (RM, pp.3209)
 
  		ldr r0, =DEMCR
  		ldr r1, [r0]
  		orr r1,r1,#(1<<24)  // Enabling TRCENA bit (is already on according to SFRs)
  		str r1, [r0]
 
  		ldr r0, =DWT_CTRL
  		ldr r2, [r0]
  		orr r2,r2,#1      // Enabling CYCCNTENA bit
  		str r1, [r0]
 
  		ldr r0, =DWT_CYCCNT
  		ldr r3, [r0]
 
		mov r5,#100
tloop:	subs r5,r5,#1
		bne tloop
 
  		ldr r4, [r0]

I'm reading zero in r3 and r4. Obviously DWT counter is not running.

What is wrong in my code ?

Thanks.

4 REPLIES 4
bully
Senior

Have corrected line 15 to

str r2, [r0]

Now it works, but still can't find DTW counters among SFR registers ?

Outside of the debugger you'd also need to unlock access via the LAR

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

I couldn't find LAR register related to DWT... Any other way to enable those counters ?

CYCCNT seems to work, but other are equal to zero...

 

Thanks,

Regards.

 

https://community.st.com/t5/stm32-mcus-products/where-are-dwt-ctrl-dwt-cyccnt-and-so-on-explained/td-p/278876

The CM7 need the LAR to be unlocked for you to be able to access the registers, this will be especially important when not connected to a debugger

DWT->LAR = 0xC5ACCE55;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..