求助各位大佬,最近在调一块板子,芯片是STM32F407VGT,在调试TIM3中断的时候出现问题,仅仅是想定时通过串口输出东西,串口能调通,普通定时功能也正常,就是打开定时中断之后程序卡死了,仿真发现程序会跑到0x00000000,点run就一点点爬,请问各位大佬这是什么问题?
代码如下:
定时器初始化:
void TIM3_init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE); ///ê1ÄüTIM3ê±Öó APB1 = 42MHZ TIM3 = APB1*2 = 84Mhz
TIM_DeInit(TIM3);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Prescaler = 8400-1;
TIM_TimeBaseStructure.TIM_Period = 19999;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;//ÏòéϼÇêy
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
WF_NVIC_Set(TIM3_IRQn,1,1,ENABLE);
TIM_ClearITPendingBit(TIM3,TIM_IT_Update);
TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE );
TIM_SetCounter(TIM3, 0);
TIM_Cmd(TIM3, ENABLE);
}
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_Update)==SET)
{
printf("11111111r\n");
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>