hi 1. I want to use the QEI in TM4c1294ncpdt launchpad, I wrote a code based on tivaware , but it looks like i did some mistakes in the code. please help me to configure it correctly. 2. What to do with the index pin of QEI? 3. please clarify me how to calculate the values for QEIConfigure , QEIVelocityConfigure , QEIPositionSet. 4. up to how much RPM i can handle? how to calculate it? 5. What QEI interrupts does ? where it is needed? ( I am using 2 hall effect sensor which provides 90 degree phase shifted waves coupled with 36 poles (10 degree) the code is as follows /*Global includes, definitions and functions.*/ #include #include #include "inc/tm4c1294ncpdt.h" #include #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_qei.h" #include "driverlib/sysctl.h" #include "driverlib/interrupt.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/debug.h" #include "driverlib/pwm.h" #include "driverlib/pin_map.h" #include "driverlib/qei.h" volatile int Direction; volatile int Velocity; volatile int Position; int main(void) { SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); GPIOPinConfigure(GPIO_PL1_PHA0); GPIOPinConfigure(GPIO_PL2_PHB0); GPIOPinTypeQEI(GPIO_PORTL_BASE, GPIO_PIN_1 | GPIO_PIN_2); QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1999); QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, 10); QEIPositionSet(QEI0_BASE, 1); QEIEnable(QEI0_BASE); QEIVelocityEnable(QEI0_BASE); /* Loop forever.*/ while(1) { Direction = QEIDirectionGet(QEI0_BASE); Velocity = QEIVelocityGet(QEI0_BASE); Position = QEIPositionGet(QEI0_BASE); } } /*Global includes, definitions and functions.*/#include #include #include "inc/ tm4c1294ncpdt .h"#include #include "inc/hw_memmap.h"#include "inc/hw_types.h"#include "inc/hw_gpio.h"#include "inc/hw_qei.h"#include "driverlib/sysctl.h"#include "driverlib/interrupt.h"#include "driverlib/fpu.h"#include "driverlib/gpio.h"#include "driverlib/debug.h"#include "driverlib/pwm.h"#include "driverlib/pin_map.h"#include "driverlib/qei.h" volatile int Direction;volatile int Velocity;volatile int Position; int main(void){ SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); GPIOPinConfigure(GPIO_PL1_PHA0); GPIOPinConfigure(GPIO_PL2_PHB0); GPIOPinTypeQEI(GPIO_PORTL_BASE, GPIO_PIN_1 | GPIO_PIN_2); QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1999); QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, 10); QEIPositionSet(QEI0_BASE, 1); QEIEnable(QEI0_BASE); QEIVelocityEnable(QEI0_BASE); /* Loop forever.*/ while(1) { Direction = QEIDirectionGet(QEI0_BASE); Velocity = QEIVelocityGet(QEI0_BASE); Position = QEIPositionGet(QEI0_BASE); } }
↧