How to set up TIM2 of stm8s003 to capture and compare signal? My sensor is connected to PD3 and generates PWM signal with +- the similar period, but with different pulse width.