学前班
最后登录1970-1-1
在线时间 小时
注册时间2017-12-11
|
关于定时器延时(和systick一样延时毫秒和微秒),为什么我写的不行呢?求大神帮忙看看,哪里的问题?
void timdelay_init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM7,ENABLE);
TIM_TimeBaseInitStruct.TIM_Prescaler=72-1;
TIM_TimeBaseInitStruct.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStruct.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit (TIM7,&TIM_TimeBaseInitStruct);
}
void timdelay_us(int nus)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
TIM_TimeBaseInitStruct.TIM_Period=nus;
TIM_TimeBaseInitStruct.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStruct.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit (TIM7,&TIM_TimeBaseInitStruct);
TIM_SelectOnePulseMode(TIM7,TIM_OPMode_Single);
TIM_Cmd (TIM7,ENABLE);
while(TIM_GetFlagStatus(TIM7,TIM_IT_Update)==RESET);
TIM_ClearFlag(TIM7,TIM_IT_Update);
}
|
|