cancel
Showing results for 
Search instead for 
Did you mean: 

In (STM32F103RB) Advanced-control timers (TIM1), I wonder why PWM signal (TIM1-CH3N) is not generated.

kkiha
Associate

I want to generate a PWM signal through the Timer.

(STM32F104RB) In CubeMX, "channel 3" of timer1 (TIM1) is set to "PWM Generation CH3N", and "channel4" of timer1 is set to "PWM Generation CH4".

The parameter settings are the same as shown below.

(Prescaler 399 / Counter Mode Up / Counter Period 999 / PWM Mode 1 / Pulse 499 / Fast Mode disable / CHN Polarity High / CHN Idle State Reset)

In Atollic TrueSTUDIO, I added the code as below.

HAL_TIM_Base_Start_IT (& htim1);

HAL_TIM_PWM_Start (& htim1, TIM_CHANNEL_3);

HAL_TIM_PWM_Start (& htim1, TIM_CHANNEL_4);

As a result of checking with the oscilloscope, the "TIM1 - CH4" pin (PA11) generates the PWM signal as intended but no signal is generated in the "TIM1 - CH3N" pin (PB15). I do not know how to solve it. I need your help.

3 REPLIES 3

You need to enable CHxN by setting CCxNE bit in TIMx_CCER There is some function in Cube for that; I don't use Cube.

JW

AGoeh
Associate

I had a similar issue with TIM8 and CH1N.

This is the function I found to enable the channel.

LL_TIM_CC_EnableChannel(TIM8, LL_TIM_CHANNEL_CH1N);

This function is in stm32F4xx_ll_tim.c

I added it after the configuration of TIM8.

The PWM now has an output.

Chupacabras
Associate III

I had the same problem. I solved it this way:

HAL_TIM_Base_Start(&htim1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);
TIM_CCxChannelCmd(htim1.Instance, TIM_CHANNEL_3, TIM_CCxN_ENABLE);

"HAL_TIM_PWM_Start" enables "TIM_CCx_ENABLE", not "TIM_CCxN_ENABLE", and that is the problem.