cancel
Showing results for 
Search instead for 
Did you mean: 

STM8L050J3 SON8N - how to generate PWM on PC5 ?

SDomn
Associate

Hello,

I am trying to generate a PWM signal on pin PC5 using TIM2_CH1 , but no success. But I am able to generate PWM on pin PD0 using TIM3_CH2.

Normally the procedure is quite simple :

for TIM2_CH1 - pin PC5

 TIM2_OC1Init(TIM2_OCMode_PWM1,  TIM2_OutputState_Enable,

  DutyCycleValue,

  TIM2_OCPolarity_High,  TIM2_OCIdleState_Reset);

 TIM2_OC1PreloadConfig(ENABLE);

 TIM2_ARRPreloadConfig(ENABLE);

 TIM2_CtrlPWMOutputs(ENABLE);

 TIM2_Cmd(ENABLE);

But I see no PWM on pin PC5.

After searching in the RM0031 Reference manual I found this :

11.5.3 SYSCFG remap control register 3 (SYSCFG_RMPCR3)

0690X000009Yx7yQAC.png

So it appears the TIM2_CH1 can't be mapped on PC5 in STM8L with 8 pins ?

Because in STM8L050J3 datasheet it seems the function is supported

0690X000009Yx7jQAC.png

When I use a similar procedure on TIM3_CH2 there is a PWM on pin PD0

 TIM3_OC2Init(TIM3_OCMode_PWM1,  TIM3_OutputState_Enable,

  DutyCycleValue,

  TIM3_OCPolarity_High, TIM3_OCIdleState_Reset);

 TIM3_OC2PreloadConfig(ENABLE);

 TIM3_ARRPreloadConfig(ENABLE);

 TIM3_CtrlPWMOutputs(ENABLE);

 TIM3_Cmd(ENABLE);

Thank you,

Stefan

3 REPLIES 3
HDang.11
Associate

Me too. :(

Cristian Gyorgy
Senior III

Hello Stefan!

The RM0031 is probably too old and it has not been updated accordingly to contain the right information for all devices. STM8L051 is one of the newest devices in class, maybe this is why.

Just write in SYSCFG_RMPCR3 the 0x40 value, so set bit 6 like you found it, and it will work.

HGrze.1
Associate

I had similar problems and finally found out that TIM2_CH1_REMAP in SYSCFG_RMPCR3 register has to be set for STM8L050 to have working TIM2_CH1 on PC5.