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.

Error in example code for EQEP in SPRC892

The exmple code for the eqep_pos_speed example has the following code:

//**** Low-speed computation using QEP capture counter ****//
if(EQep1Regs.QEPSTS.bit.UPEVNT==1) // Unit position event
if(EQep1Regs.QEPSTS.bit.COEF==0) // No Capture overflow
temp1=(unsigned long)EQep1Regs.QCPRDLAT; // temp1 = t2-t1
else // Capture overflow, saturate the result

p->Speed_pr = _IQdiv(p->SpeedScaler,temp1); // p->Speed_pr = p->SpeedScaler/temp1

if (Tmp1>_IQ(1))
p->Speed_pr = _IQ(1);
p->Speed_pr = Tmp1;

// Convert p->Speed_pr to RPM
if (p->DirectionQep==0) // Reverse direction = negative
p->SpeedRpm_pr = -_IQmpy(p->BaseRpm,p->Speed_pr); // Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q
else // Forward direction = positive
p->SpeedRpm_pr = _IQmpy(p->BaseRpm,p->Speed_pr); // Q0 = Q0*GLOBAL_Q => _IQXmpy(), X = GLOBAL_Q

EQep1Regs.QEPSTS.all=0x88; // Clear Unit position event flag
// Clear overflow error flag

The last line is incorrect.  The line should be
This clears the capture overflow flag which is a read/write sticky bit, cleared by writing a 1.  

The 0x80 bit is the unit position event flag (UPEVNT) bit which is read only.  
Writing to this bit caused erroneous reading to be pulled from the period latch register QCPRDLAT  in the sample code ( at least on the 28035 chip I'm using)
 These reading were always 65535, with an occasional valid result.

Not sure where else to post, to avoid other programmers running in to the same issue.