Showing results for 
Search instead for 
Did you mean: 

Conditional data watchpoint with debugger or DWT


I've tried both Eclipse and the VSCode Cortex debug plugin to set a conditional watchpoint but both fail (break every access irrespective of value). This I guess is due to OpenOCD not supporting the multiple compare registers in the DWT that are required for a conditional.

Is there a way I can code a watchpoint into the DWT directly so I can find what is causing my memory corruption?

I found the following snippet on StackOverflow but not idea what the magic number is about for FUNCTION1 and whether a conditional can only check for equality ?

DWT->COMP2 = <address to compare>;
DWT->COMP1 = <word to compare>;
DWT->FUNCTION1 = 0x20B06;

Can someone enlighten me with perhaps a worked example that includes a breakpoint or other trap so I can stop execution and find the culprit ?


Associate II

Hi frackers, did you end up figuring it out? I'm trying to do the same as you, and using by pyOCD the watchpoint condition gets ignored, so I'm guessing it isn't properly set up by the debugger like you said.


I found some doc from TI on the DWT registers. Not easy to decipher so before I did in, I wanted to know whether you succeeded.