1.配置某位引脚输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_LED, &GPIO_InitStructure);
2.开始定时器
TIM_TimeBa seStructure.TIM_Period = 0x4AF;
TIM_TimeBaseStructure.TIM_Prescaler = 0xEA5F TIM_TimeBaseStructure.TIM_ClockDivision = 0x0 TIM_TimeBaseStructure.TIM_CounterMode = ounterMode_Up TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0000;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure)
TIM_Cmd(TIM2, ENABLE);
TIM_PrescalerConfig(TIM2, 0xEA5F, ReloadMode_Immediate);
TIM_ClearFlag(TIM2, TIM_FLAG_Update);
TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
文章评论(0条评论)
登录后参与讨论