This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

使用TM4C123GH6PM的QEI模块计算电机转度和位置问题

Other Parts Discussed in Thread: TIDM-TM4C123STEPPERMOTOR

对QEI模块进行如下初始化设置

void Init_QEI(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0);

GPIOPinConfigure(GPIO_PD6_PHA0);
GPIOPinTypeQEI(GPIO_PORTD_BASE, GPIO_PIN_6);
GPIOPinConfigure(GPIO_PD7_PHB0);
GPIOPinTypeQEI(GPIO_PORTD_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PF4_IDX0);
GPIOPinTypeQEI(GPIO_PORTF_BASE, GPIO_PIN_4);

GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_6,
GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_7,
GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4,
GPIO_STRENGTH_4MA,
GPIO_PIN_TYPE_STD);

QEIConfigure(QEI0_BASE,(QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET |
QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 4095);

QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, SysCtlClockGet()/100);

QEIVelocityEnable(QEI0_BASE);
QEIEnable(QEI0_BASE);

QEIIntEnable(QEI0_BASE,QEI_INTTIMER);
IntEnable(INT_QEI0);

}

怎么在中断处理函数里计算电机的转速和位置呢?

void
QEIIntHandler(void)
{
QEIIntClear(QEI0_BASE, QEI_INTTIMER);

???????
}