stm32的TIM1定时器能不能产生4MHZ的信号啊?我的定时器开起来,最多能达到2MHZ左右,再改预分频值和自动重装载寄存器周期值的也不会改变频率。。。。[mw_shl_code=applescript,true]void TIM1_Int_Init(u16 arr,u16 psc)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); //时钟使能
//设置优先级
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;//先占优先级0级
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //从优先级0级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_TimeBaseStructure.TIM_Period = arr; //设置自动重装载寄存器周期值
TIM_TimeBaseStructure.TIM_Prescaler =(psc-1);//设置预分频值
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //设置时钟分割
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//向上计数模式
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;//重复计数设置
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseStructure);
TIM_ClearFlag(TIM1, TIM_FLAG_Update);//清中断标志位
TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM1, ENABLE); //使能TIMx外设
}
//定时器3中断服务函数
void TIM1_UP_TIM10_IRQHandler(void)
{
TIM_ClearITPendingBit(TIM1,TIM_IT_Update); //清除中断标志位
LED1=!LED1;//DS1翻转
}[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
没有,是100M高速的。
一周热门 更多>