高级定时器
PWM互补输出,带死区时间,带刹车控制。
具体看注释。
void Advance_TIM_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_InitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_BDTRInitTypeDef TIM_BDTRInitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB,ENABLE);
//PA8 :TIM1_CH1的输出比较通道 ->推挽复用模式
//PB13:TIM1_CH1的输出比较通道的互补通道 ->推挽复用模式
//PB12:TIM1_CH1的输出比较通道的刹车通道 ->推挽复用模式
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP