AnsweredAssumed Answered

Dectecting the presence of a debugger on STM32F767 does not work

Question asked by Richard Peters on Jun 6, 2018
Latest reply on Jun 12, 2018 by Richard Peters

Hello all!

 

I'm trying to detect whether a debugger is attached to my program. I've read in other threads (like this one: https://community.st.com/thread/25890?commentID=69875#comment-69875  ) that there is a register in the SCB named DHCSR (Debug Halt Control and Status Register) which is used by debuggers who set bit 0 when they attach. ARM Information Center  gives more details about this register.

 

However, when I read out that register on my Nucleo-F767ZI board, bit 0 is always set to 1. Of course it should be 1 when I launch my program from System Workbench, but when I disconnect the debugger and reset the microcontroller, bit 1 is still set. The contents of DHCSR is different when debugging or not debugging (when debugging, it is 0x1000d, when not debugging, it is 0x1010001), but I expected the least significant bit to be 0 when not debugging.

 

I use this code to read out DHCSR:

 

volatile unsigned int* const SCB_DHCSR = (volatile unsigned int *)0xE000EDF0;
if (*SCB_DHCSR & 1)

    ...

 

Am I doing something wrong? Is this a peculiarity with the STM32F767?

Outcomes