Chip behaves differently in debug vs flash
How did you implement the timing? Are you using a hardware time or do you have a buys wait loop that's tuned empirically? The latter would behave different in debug mode since the compiler adds overhead to collect debug information. In general processors run "slower" in debug mode, or to be precise: the same code executes slower because of the debug overhead