Try adding this line after while (!TIM1_SR1_CC1IF); while (!TIM1_SR1_CC2IF); // wait until capture event I think that you should wait for two events: first the CC2 event to read the duty cycle and the second one is to read the period. I hope this helps you otherwise I should run your code to find out the issue. Kep me informed. Mit besten grüssen, MCU Lüfter