Skip to main content
bully
Senior
November 14, 2022
Question

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

  • November 14, 2022
  • 1 reply
  • 1288 views

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.

1 reply

bully
bullyAuthor
Senior
November 14, 2022

Have corrected line 15 to

str r2, [r0]

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

Tesla DeLorean
Guru
November 14, 2022

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

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
bully
bullyAuthor
Senior
January 7, 2024

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.