cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling an PWM output enabled channel with SPL lib - STM32F103RB

Posted on March 22, 2018 at 15:48

Hello to all of you, 

I'm using SPL libs for STM32f103 64 pin mcu and I need 6 tim channel to generate 6 independent pwm signals. But due to the project pinout needs I must to configure the channels from 3 timers. So, I'm using 3 timers: 1, 2 and 3. 

SPL lib provide a lot of timer functions, as initialization of output compare structs and output compare channel x. In this init function the channel ccer bit is enabled driving pwm signal to the output channel pin: 

/*channel 1 of tim 2*/

TIM_OC2Init(TIM2, TIM_OCInitStruct);

My question is, 

is there a function that can disable the pwm channel as there is a function for init and start the pwm signal? if not, does it means that these channels will be generating pwm signal -once they are enabled- for ever until the app stops running? What to do if you want to stop only some pwm channel (or more than one) ? is there a type of function for turning back to idle state reset (so Low level signal)?

Advanced timers as tim 1 and tim 8 must be enabled and can be disabled with the same function, but this function is only available for them: 

TIM_CtrlPWMOutputs(TIM1, ENABLED); //on

TIM_CtrlPWMOutputs(TIM1

,

 DISA

BLED

); //off

Any information will be helpful. 

Thanks in advance.

#stm32f103-pwm #output-compare #spl #timer-channel
1 REPLY 1
Jason Dough
Associate
Posted on May 20, 2018 at 01:23

I found this function, is this what you need ?

/**

  * @brief  Enables or disables the TIM Capture Compare Channel x.

  * @param  TIMx: where x can be 1 to 14 except 6 and 7, to select the TIM peripheral.

  * @param  TIM_Channel: specifies the TIM Channel

  *          This parameter can be one of the following values:

  *            @arg TIM_Channel_1: TIM Channel 1

  *            @arg TIM_Channel_2: TIM Channel 2

  *            @arg TIM_Channel_3: TIM Channel 3

  *            @arg TIM_Channel_4: TIM Channel 4

  * @param  TIM_CCx: specifies the TIM Channel CCxE bit new state.

  *          This parameter can be: TIM_CCx_Enable or TIM_CCx_Disable.

  * @retval None

  */

void

TIM_CCxCmd

(

TIM_TypeDef

* TIMx,

uint16_t

TIM_Channel,

uint16_t

TIM_CCx)