Stm32 uses Monte Carlo method to measure duty cycle