Setting up my STM32L031 for PWM input using TIM2
Hi Folks,
I think I've set up my TIM2 correctly using the CUBEMX but I'm new to the STM32 world and I'd like someone to take a look at this. I'm going to be reading the output from a optocoupler connected to the 120VAC line and then through a buffer so the frequency will be 60Hz (here in the US). I need to measure the pulse width to an accuracy of +/- 500 uS (1/2000 sec). I can then calculate the peak voltage and take action if it falls below a set value. I haven't been able to find a clear description on how to set up the TIM2 in CubeMX but here's what I've started with:


Am I close to getting it correct? My pulse generator decided that today was a good day to quit so I won't be able to test the code until Thursday when the new one shows up.
Any help will be greatly appreciated.
RC
#pwm #pwm-input