His,
I am trying to get quadrature encoder counts using the TMS570LS04HDK. I've tried everything I can think of, but I still cannot read any data from it. I am enable to initialize it to a value I want, but nothing but QCTMR and QCTMRLAT actually change during normal run operation. I have attached the project in hopes someone can point out a silly error I made somewhere. The code is taken pretty much directly from the HalCoGen example:
/* USER CODE BEGIN (2) */ #define UNIT_POSITION_X 60U /* USER CODE END */ void main(void) { /* USER CODE BEGIN (3) */ uint16 deltaT = 0U; float velocity = 0U; int count = 0; /* EQEP initialization based on GUI Configuration. */ QEPInit(); /* Enable Position Counter */ eqepEnableCounter(eqepREG1); /* Enable Unit Timer. */ eqepEnableUnitTimer(eqepREG1); /* Enable capture timer and capture period latch. */ eqepEnableCapture(eqepREG1); eqepREG1->QEPCTL |= 0xC000; while(1) { eqepBASE_t encoder = * eqepREG1; /* Status flag is set to indicate that a new value is latched in the QCPRD register. */ if((eqepREG1->QEPSTS & 0x80U) !=0U) { /* Elapsed time between unit position events */ deltaT = eqepREG1->QCPRD; count = eqepReadPosnCount(eqepREG1); /* Calculate Velocity from deltaT and the value of the unit position. */ /* The value of Unit Position is a sample value and should be changed by the User as per the actual value in the UNIT_POSITION_X macro above. */ velocity = (float)(UNIT_POSITION_X/deltaT); /* Clear the Status flag. */ eqepREG1->QEPSTS |= 0x80U; } } /* USER CODE END */ }
Thanks,