Hi
I am using Tiva TM4C123GH6ZRB micro controller .Using QEI module for calculation of the speed. as per the formula (rpm = (clock * (2 ^ VELDIV) * SPEED * 60) ÷ (LOAD * ppr * edges)).
For getting the SPEED using his API QEIVelocityGet(QEI1_BASE).But SPEED is always constant even after change the fan speed.Could you please help me ,what could be the issue?I ma new to QEI module.
clock is 80Mhz and ppr 100. Here is my code
uint32_t get_fan_speed( ){
uint64_t velcount, rpm;
//Enable the QEI module
//The GPIO PIN peripheral enabled for QEI module
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
//
// The QEI peripheral enabled for use.
//
// SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1);
//
//Configure the pin for QEI
//
GPIOPinConfigure(GPIO_PG0_PHA1);
//
//Set the GPIO PIN to QEI type
//
GPIOPinTypeQEI(GPIO_PORTG_BASE, GPIO_PIN_0);
//
//Initial Disable the QEI module
//
QEIDisable(QEI1_BASE);
//
//Configure the QEI
//
QEIConfigure(QEI1_BASE,(QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP),0xF9F);
//
//Initial Disable the QEI Velocity
//
QEIVelocityDisable(QEI1_BASE);
//
//Configure the QEI velocity
//
QEIVelocityConfigure(QEI1_BASE,QEI_VELDIV_1,8000000);
//
// Enable the QUI velocity
//
QEIVelocityEnable(QEI1_BASE);
//
// Enable the QUI module
//
QEIEnable(QEI1_BASE);
velcount = QEIVelocityGet(QEI1_BASE);
System_printf("\nvelcount =%d\n",velcount);
rpm = (240 *velcount)/(400);//According to the formula of rpm = (clock * (2 ^ VELDIV) * SPEED * 60) ÷ (LOAD * ppr * edges) as per data sheet
//clock = 80000000Hz,VELDIV = QEI_VELDIV_1,SPEED = velcount,load = 80000000/4 = 200000000 ,ppr = 100 ,edges =4
System_printf("\n***rpm = %d",rpm);
return rpm;
}
Thanks & Regards
Durga