初中生
最后登录1970-1-1
在线时间 小时
注册时间2016-7-23
|
楼主 |
发表于 2016-8-5 19:19:24
|
显示全部楼层
可是我并不是用这样的方式,我并没有宏定义那些东西 ,而是直接用了源文件中定义的名称
我是直接这样写的 这样子并不需要你那样打开宏吧
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=2;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
//NVIC_InitStructure.NVIC_IRQChannel=TIM4_IRQn;
//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;
//NVIC_InitStructure.NVIC_IRQChannelSubPriority=2;
//NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
//NVIC_Init(&NVIC_InitStructure);
}
//ÅäÖÃTIM3êä3öWMDÅoÅμÄÄ£ê½
static void TIMx_Mode_Config(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM3,ENABLE);
//ÅäÖûù′¡¶¨ê±Æ÷ TIM3
TIM_TimeBaseStructure.TIM_Period=255;
TIM_TimeBaseStructure.TIM_Prescaler = 1999;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
//TIM4
//RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM3,ENABLE);
//TIM_TimeBaseStructure.TIM_Period=255;
//TIM_TimeBaseStructure.TIM_Prescaler = 1999;
//TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1 ;
//TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
//TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
//PWMÄ£ê½ÅäÖÃ
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse=0;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_Low;
TIM_OC3Init(TIM3,&TIM_OCInitStructure); //ê1Äüí¨μà3
TIM_OC3PreloadConfig(TIM3,TIM_OCPreload_Enable); //ê1ÄüԤװÔØ
TIM_ARRPreloadConfig(TIM3,ENABLE); //ê1ÄüTIM3ÖØÔؼÄ′æÆ÷ARR
TIM_Cmd(TIM3,ENABLE); //ê1Äü¶¨ê±Æ÷3
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);//ê1ÄüupdateÖD¶Ï
NVIC_Config_PWM(); |
|