STM32F1 troubles with a timer
When a debugger stops program execution, manually or by hitting a breakpoint, it freezes the Cortex-M core (including System tick counter) while leaving the rest of system running.

Peripherals continue to count, read and write to memory and IOs, and to raise interrupt flags. The flags accumulate and once the processor is resumed, it starts servicing them.

Most peripherals can be set to suspend when the CPU is suspended, this is useful when program intervention is needed to keep correct function. By default, they are usually unaffected by debugger, although exceptions exist (Freescale FTM timer which stops by default).

STM32F1 MCUs have dedicated register for setting debug behaviour of peripherals, the DBG->DBGMCU_CR.