我用的是STM32F103C8T6 想做BLDC控制 但是在霍尔接口方面一直有些弄不明白
1.如下图 选择了CH1 CH2 CHI3 异或后连接至TI1
选择了 TI1 映射到TIRC 触发源选择了 TI1P_ED 用软件仿真 为什么总是捕获和触发都没有进中断?
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_TRC;
// TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x5;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
TIM_SelectHallSensor(TIM2,ENABLE);
TIM_SelectInputTrigger(TIM2, TIM_TS_TI1F_ED);
TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
TIM_SelectMasterSlaveMode(TIM2, TIM_MasterSlaveMode_Enable);
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
TIM_ClearITPendingBit(TIM2, TIM_IT_CC1);
TIM_ClearITPendingBit(TIM2, TIM_IT_Trigger);
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE );
TIM_ITConfig(TIM2, TIM_IT_Trigger, ENABLE );
//TIM_Cmd(TIM2, ENABLE);//Enabel TIM2
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
麻烦各位高手赐教......
如果有哪位有完整的配置可以发一个给我 那就万分感谢了
zouyi890815@163.com
|