cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051 TIM21 PWM capture

izzy84075
Associate II
Posted on February 18, 2015 at 18:51

I've been running around in circles all morning trying to figure out how to set up PWM capture on this thing... STM32CubeMX doesn't have any options for doing it on TIM21, but I see it mentioned in the reference manual for this chip/timer. I can't make heads or tails of what the example setup in the reference manual is actually doing, either.

What I have is a single pin, PA2(Which is TIM21_CH1), that I need to capture both the high and low active time on. Can I do this with TIM21, or do I need to look into rearranging things to get this on TIM2?

#stm32l0 #pwm-input #tim21
4 REPLIES 4
Posted on February 18, 2015 at 19:10

> I've been running around in circles all morning trying to figure out how to set up PWM capture on this thing... STM32CubeMX doesn't have any options for doing it on TIM21,

Then dump CubeMX and do it in the old fashioned way, setting up the registers directly.

> I can't make heads or tails of what the example setup in the reference manual is actually doing, either.

It can't really be more detailed - do exactly what the step-by-step description says.

Have a look at the ''snippets'' example, in [STM32L0xx_Snippets_Package_V1.0.0]\Projects\TIMERS\04_PWM_Input\ . Incidentally, it uses TIM21 as the default timer, although on PB13.

JW

izzy84075
Associate II
Posted on February 18, 2015 at 19:16

>> I can't make heads or tails of what the example setup in the reference manual is actually doing, either.

>It can't really be more detailed - do exactly what the step-by-step description says.

It's too-detailed, I think. The timers on these things are really complicated compared to what I've worked with in the past(Zilog MCUs), and it hasn't ''clicked'' yet how everything fits together.

I'll go look at that example, thanks.

izzy84075
Associate II
Posted on February 18, 2015 at 19:28

Also, I just figured out how to set it up in CubeMX. Disable the individual channels and select your PWM Input mode in the now-enabled Combined Channels dropdown.

Posted on February 18, 2015 at 20:03

OK, but then you'll be bound to the clickey stuff whole your life.... 😉

JW