pwm

TIM1 PWMN 无输出?

TIM1 PWM3 有输出无死区 PWM3N 无数输出 ?

代码


/ USER CODE BEGIN 2 /


HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);
TIM1->CCR3 = 1200;

HAL_TIM_PWM_Start(&htim16, TIM_CHANNEL_1);
TIM16->CCR1 = 192;

HAL_TIM_PWM_Start(&htim17, TIM_CHANNEL_1);
TIM17->CCR1 = 6000;




/ USER CODE END 2 /



/ TIM1 init function /
void MX_TIM1_Init(void)
{

TIM_MasterConfigTypeDef sMasterConfig;
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig;
TIM_OC_InitTypeDef sConfigOC;

htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 2400;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
HAL_TIM_PWM_Init(&htim1);

sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig);

sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
sBreakDeadTimeConfig.DeadTime = 24;
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig);

sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3);

}
已邀请:

stm相间

赞同来自: lxtqyh

自己看库函数,会发现pwmn那路硬件并没有打开,需要自己加上!在hal库文件里面有。具体可以看hal库函数使用手册。没有电脑,只能帮到这里了!

生命大陆

赞同来自:

what!PWM N那路没打开?

Sokit2

赞同来自:

@stm32相间 什么函数啊

engin周伟

赞同来自:

http://www.stm32cube.com/article/149

xia_yangchun

赞同来自:

STM32 HAl库PWM的TIMx_CHxN需要把TIM_OCx_SetConfig函数中//tmpccer &= ~TIM_CCER_CCxNE;改为tmpccer |= TIM_CCER_CCxNE;

觞酒、罪天

赞同来自:

谢谢,完美解决了我的疑问

要回复问题请先登录注册