An isolating transformer would be a start, but I would personally disconnect the mains and power the micro from the debugger (if possible, I'm guessing that you're switching mains with the micro, so this may not be practical)
I am switching mains with the MCU so i cannot power it up from the debugger.
I can check the logical run through though.
But with mains power i get an unisolated 5v and the ADC reading on this is not measurable.With the debugger power i am able to measure and take action depending on the reading..but the same piece of code when run on actual power ,i get erratic actions..so theres some trouble....so i was hoping that maybe i connect a 1:1 xmer and connect the debugger directly.