Hello,Im reading position with encoder, the problem is that sometimes the count jump to erroneous date, like in the image:
I read position in a interrupt at 10KHz
I configure the EQeP fron this way:
void encoder(void)
{
EQep2Regs.QDECCTL.bit.QSRC=00; // El modulo cuenta en cuadratura
EQep2Regs.QEPCTL.bit.FREE_SOFT=2; //unaffected by emulation suspend
EQep2Regs.QEPCTL.bit.PCRM=00; // QPOSCNT se reseta con cada cero (Un0)
EQep2Regs.QEPCTL.bit.UTE=0; //1 Habilita la unidad de Timeout
EQep2Regs.QEPCTL.bit.QCLM=0; //1 Latch on unit time out
EQep2Regs.QEPCTL.bit.IEL = 1; // IEL_RISING
EQep2Regs.QEPCTL.bit.IEI = 2; // IEL_RISING
EQep2Regs.QPOSMAX=4*1024 - 1; // valor maximo del encoder
EQep2Regs.QEPCTL.bit.QPEN=1; //1 Habilita QEP
//EQep2Regs.QUPRD=150000; // unidad de tiempo en 100Hz si SYSCLKOTT=150MHz
and in the interrupt I have the next code:
interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++;
x_ac= EQep2Regs.QPOSCNT;
if (k<512)
{Pos[k]=x_ac;
k=k+1;}
else
{k=0;}
I have a Vector of 512 point so I can storage the information. Can Sombody help me??