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.

eQEP position compare interrupt problem



Hi Group,

I had tried to set up an eQEP position compare interrupt but I had no success. The interrupt subroutine is called only
one time event I cleared the interrupt flag.

I rotate the shaft passing the compare value (500 in my following code), and it shows that TestCount3 (in the

interrupt subroutine) increase one but when I try to pass second time (backward or forward) this compare value again

and then TestCount3 doesn't increase any more.

( I'm working on controlCard F28035 with an encoder and it worked well with the example of calculating speed in eQEP.
I tried with other experiments and it showed that the position compare interrupt was cleared very well ).

Do you have any idea?
If you had success in setting eQEP position compare interrupt please put your code.

Thank you very much for your time.

Jack

// =============== Setting interrupt ==================================
   InitSysCtrl();

   InitEQep1Gpio();
   DINT;

   InitPieCtrl();
  
// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

   EALLOW; 
   PieVectTable.EQEP1_INT = &QEP_ISRCounterCompare ;
   EDIS;   
  
   IER |= M_INT5 ;

   PieCtrlRegs.PIEIER5.bit.INTx1 = 1 ;
  
// Enable global Interrupts and higher priority real-time debug events:
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM
  
   EQep1Regs.QPOSCNT = 78 ; // testest init
   EQep1Regs.QPOSCMP = 500 ;

// =============== Init eQEP ============================================

    TestInitCount++ ;
    EQep1Regs.QUPRD=600000;             // Unit Timer for 100Hz at 60 MHz SYSCLKOUT

    EQep1Regs.QDECCTL.bit.QSRC=00;      // QEP quadrature count mode

    EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;
    EQep1Regs.QEPCTL.bit.PCRM=00;       // PCRM=00 mode - QPOSCNT reset on index event
    EQep1Regs.QEPCTL.bit.UTE=1;         // Unit Timeout Enable
    EQep1Regs.QEPCTL.bit.QCLM=1;        // Latch on unit time out

    EQep1Regs.QPOSMAX = 0xFFF ;         // for an encoder with 12-bits
    EQep1Regs.QEPCTL.bit.QPEN=1;        // QEP enable

    EQep1Regs.QCAPCTL.bit.UPPS=5;       // 1/32 for unit position
    EQep1Regs.QCAPCTL.bit.CCPS=6;       // 1/64 for CAP clock
    EQep1Regs.QCAPCTL.bit.CEN=1;        // QEP Capture Enable


    EQep1Regs.QPOSCTL.bit.PCE = 1 ; // enable position compare unit
  
    EQep1Regs.QEINT.bit.PCM = 1 ;   // enable pos compare interrupt

// =============== Interrupt subroutine ===================================

interrupt void QEP_ISRCounterCompare(void)  {
   
    TestCount3++ ;
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
    EQep1Regs.QCLR.bit.PCM = 1 ; // clear
   
}



  • Hi Group,

    I tried couple of ways to get interrupt for eQEP position compare as I discussed previous, but I have no luck.

    So for temporary,  I used timer interrupt (very fast, 10us) instead to check position compare flag to do my work and it works well. Hope to share my work with somebody doing similar.

    interrupt void Timer0_ISR(void)  {

      if ( EQep1Regs.QFLG.bit.PCM == 1 )   {

          // do my tasks

         //// Set next matching pos
         EQep1Regs.QPOSCMP = MyNextMotorPositionCompare ;

          EQep1Regs.QCLR.bit.PCM = 1 ; // clear

      }

    }

    I hope TI engineers will have some idea about eQEP position compare.

    Jack

  • Hi Jack,

    I am attaching a code snippet form one of our student's code, who had no problems with QEP position interrupt

    interrupt exit:

        // Spustimo INT zastavico
        EQep2Regs.QCLR.bit.INT = 1;        // clear global INT FLAG   
        EQep2Regs.QEPSTS.bit.UPEVNT = 1;
        // Spustimo INT zastavico v PIE enoti
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
    }  // end of POS_int

    I hope this will help

    Regards, Mitja

  • Hi Mitja,

    Thank you for your answer.

    I run again experiments and put here my eQEP position compare and it worked fine (with the same previous settings).

    interrupt void QEP_ISRCounterCompare(void)  {
       
        TestCount3++ ;       
        // do my taks

        // test next pos compare
        EQep1Regs.QPOSCMP += 200 ;       
       
        // Should be in this order
        EQep1Regs.QCLR.bit.PCM = 1 ;         // clear PCM
        EQep1Regs.QCLR.bit.INT = 1 ;        // clear global INT FLAG                
       
        PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;                       
       
    }

    Jack

     

     

  • Hi Jack

    It might be just the order of clearing the interrupt flags (first PCM then INT within QEP and člastly PIEACK)

    Regards, Mitja