- int Pulse(void)
- {
- tiM_TimeBaseInitTypeDef TimeStruct;
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
- TIM_SelectInputTrigger(TIM2,TIM_TS_ITR3);//
- TIM_SelectSlaveMode(TIM2,TIM_SlaveMode_External1);
- TimeStruct.TIM_Prescaler=0;
- TimeStruct.TIM_CounterMode=TIM_CounterMode_Up;
- TimeStruct.TIM_Period=29;
- TimeStruct.TIM_ClockDivision=TIM_CKD_DIV1;
- TimeStruct.TIM_RepetitionCounter=0;
- TIM_TimeBaseInit(TIM2, &TimeStruct);
- TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
- ///Master Configuration code
- ...
- }
- void TIM2_IRQHandler(){
- if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
- {
- x=x+1;
- TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
- }
- }
我打算在
STM32f10x下配置一个主从配置。我正确地连接了它们,但在第一步它会在启用主定时器或启用从定时器之前生成一个中断。这是我的代码:
调用 Pulse 函数后,它会生成 TIM2 中断(x=1),我需要知道为什么它在未配置/启用触发源时生成中断。