I'm using STM32F103RBT6 for my project, I've designed a custom board.
I'm using cubemx to generate the basic code and Atollic for debugging.
I'm reading the switches using external interrupt. In the external interrupt call back, I'm starting a timer.
In the timer interrupt handler, I'm doing some work.
I've kept the timer timeout period to 2 seconds.
My problem is whenever the code is started to run for the first time and when I press the switch, the code immediately goes to the timer interrupt handler. This happens only once for the first time. After this, whenever I press the switch, code goes to the timer interrupt in 2 seconds which is correct.
Why does it go immediately goes to the interrupt handler for the first time and then works fine thereafter??
I've attached the c file for reference.
Is there any changes to be made??