小学生
最后登录1970-1-1
在线时间 小时
注册时间2020-9-20
|
楼主 |
发表于 2021-4-23 14:18:50
|
显示全部楼层
void GENERAL_TIM_Mode_Config(void)
{
GENERAL_TIM_APBxClock_FUN(GENERAL_TIM_CLK,ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
//
TIM_TimeBaseStructure.TIM_Period=GENERAL_TIM_Period;
//
TIM_TimeBaseStructure.TIM_Prescaler= GENERAL_TIM_Prescaler;
//
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
//
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter=0;
//
TIM_TimeBaseInit(GENERAL_TIM, &TIM_TimeBaseStructure);
uint16_t CCR1_Val = 2;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
// TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;
TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
TIM_OC1Init(GENERAL_TIM, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(GENERAL_TIM, TIM_OCPreload_Enable);
TIM_Cmd(GENERAL_TIM, DISABLE);
} |
|