I have a faint memory of something to check to see if running debug or not. anyone know?
You missed the last line of my first reply, then?
See also: community.st.com/.../36036-how-to-check-at-runtime-if-a-debugger-is-connected