cancel
Showing results for 
Search instead for 
Did you mean: 

Single Timer, One Channel Capture, Second Channel PWM

Rogers.Gary
Senior II

Hello:

Using a single timer (TIM2) on an STM32L4, can the IC be set up so that it can function down to 300Hz, while the PWM is generating 20KHz?

Using CubeMX to do the device setup. I can not change the counter period as it is set correctly to generate the PWM. The only option is the prescalar, which can be DIV8. If the PWM generation is based on the PERIOD, does that impact the IC?

Thanks!

2 REPLIES 2
S.Ma
Principal

Create a 32 bit global RAM counter which is incremented at each timer overflow to create by SW the additional bits needed to run a 48 bit timer. When you get an input capture, grab the timer capture register and the global MSB and save it. Next capture do the same and substract to get the period.

There maybe other ways.

Rogers.Gary
Senior II

hi, thanks for your answer. I discovred two things. 1, I had missed a CubeMX setting. 2, it does work. I guess the capture and PWM generation are completely different entities? In any case, resolved.