cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a compile time conditional statement for debugging?

JayDev
Senior II

Hello everyone!

I am trying to debug some code but there are some flags in flash that keep getting set when I exit debug and it enters run mode (or when I power up the sensor. Basically, anytime it gets a chance to run before I can get it in debug mode).

This had me wondering, is there a compile time debug command I can run that wouldn't run on the microcontroller unless I was in debug mode? Something like #DEBUG or something to that effect?

Tried searching the forums but it turns out, the word "debug" is very popular . . . heh. Any help you can give me would be appreciated. Thanks!

2 REPLIES 2

You could add a breakpoint instruction (BKPT), or loop on a GPIO state.

Put external pull-downs on I2C pins so that the device operated differently when you want to debug it, or have it output diagnostic telemetry.

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

Crossworks used to have an infinite loop in their debug startup code that waited for a debugger to connect.

Perhaps you can emulate that with your setup, possobly using TeslaDeLorean's suggested methods.