赞
踩
void PWM_TIM1(uint16_t arr,uint16_t psc) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); //定时器TIM1时钟使能 TIM_DeInit(TIM1); //设置在下一个更新事件装入活动的自动重装载寄存器周期的值 TIM_TimeBaseStructure.TIM_Period =arr; //设置用来作为TIMx时钟频率出书的预分频值 TIM_TimeBaseStructure.TIM_Prescaler =psc; //设置时钟分割 TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置计数模式 TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //初始化参数 TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_2); //TIM1channel2 GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_2); //TIM1channel3 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); //PA9 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_OType
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。