新手上路
- 积分
- 33
- 金钱
- 33
- 注册时间
- 2015-4-21
- 在线时间
- 0 小时
|
5金钱
#ifdef _COSMIC_
@far @interrupt void EXTI_PORTD_IRQHandler(void)
#else /* _RAISONANCE_ */
void EXTI_PORTD_IRQHandler(void) interrupt 6
#endif /* _COSMIC_ */
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
u8 State,Trigger;
EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOD, EXTI_SENSITIVITY_RISE_FALL);//hall_mode
State = GPIO_ReadInputData(GPIOD);
Trigger = (u8)(State & 0x1C);//PD2|3|4 现在我要用的是PD3,PC5,PE5三个引脚用来获取霍尔信号
if(Trigger != 0)
{
switch(Trigger)
{
case 0x04:Motor_Step = 1;break;//next->AC
case 0x0c:Motor_Step = 2;break;//next->BC
case 0x08:Motor_Step = 3;break;//next->BA
case 0x18:Motor_Step = 4;break;//next->CA
case 0x10:Motor_Step = 5;break;//next->CB
case 0x14:Motor_Step = 0;break;//next->AB
}
Commutation(Motor_Step,Duty_Cycle);
}
|
最佳答案
查看完整内容[请看2#楼]
写一个函数,替代:GPIO_ReadInputData(GPIOD);函数。
实现读取PD3,PC5,PE5,并按要求组合。
|