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.

TMS320F280049: QEP Position Compare Updates

Part Number: TMS320F280049

Hello, 

When using the position compare feature of the QEP, what is the best mechanism to update a new on the fly compare value?  For example, with an encoder producing 5000 pulses, if you want to send out Strobe pulses at 1000,2000,3000,4000 and 0(5000) counts, what is the best way to update the compare register.  It was not clear if there was an auto load feature where they can maintain the absolute position within one rev.

Customer wants to enable a strobe interrupt using following code. Your guidance/ approach is appreciated. 


 
Main()
{
 
….
 
  /* Set GPIO 22 for EQEP1S - Strobe */
  GPIO_setMode(halHandle->gpioHandle,GPIO_Number_22,GPIO_22_Mode_EQEP1S);
 
  // init QEP Int ISR to QEP_Index_ISR
   HAL_Obj *obj = (HAL_Obj *)halHandle;
   PIE_Obj *pie = (PIE_Obj *)obj->pieHandle;
   EALLOW;
   pie->EQEP1_INT = &qep_int;
   EDIS;
…..
…..
 
  QEP_set_strobe_event_init(halHandle->qepHandle[0],QEPCTL_Sei_Rising_Edge_Init);
  QEP_set_select_sync_pin(halHandle->qepHandle[0],QEP_Spsel_Strobe_Pin_Sync_Output);
 
  //Enable the sync output
  QEP_enable_sync_out(halHandle->qepHandle[0]);
 
  // Set the counter
  QEP_write_posn_compare(halHandle->qepHandle[0],500);
 
  // clear the QEP interrupt flag
  QEP_clear_interrupt_flag( halHandle->qepHandle[0], QEINT_Sel);
   //Enable interrupt
   QEP_enable_interrupt(halHandle->qepHandle[0],QEINT_Sel);
 
   //Enable the posn
    QEP_enable_posn_compare(halHandle->qepHandle[0]);
    PIE_enableInt(halHandle->pieHandle,PIE_GroupNumber_5,PIE_InterruptSource_EQEP1);
 
…..
….
 
}
 
 
 
 
 
interrupt void qep_int(void)
{
 
    HAL_Obj *obj = (HAL_Obj *)halHandle;
    PIE_Obj *pie = (PIE_Obj *)halHandle->pieHandle;
 
 
#ifdef J5
    QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[1];
#else
    QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
#endif
 
    if(qep->QFLG & 0x200)
    {
        qep->QCLR = 0x0FFF;
    }
     /* Clear the interrupt */
    qep->QCLR = 0x0FFF;
 
   /* Ack the group 5 interrupt */
    pie->PIEACK = 0xFFF;
 
 
}

  • Hi Prasanna,

    You can update the QPOSCMP register on every interrupt within ISR.

    Also, can you clarify on what you mean by maintaining absolute position within revolution.

    Regards,
    Nirav
  • HI,
    I have need to generate a signal pattern based on the encoder position. As Prasanna mentioned we have 5000 line encoder and I need to generate a trigger pulse on every encoder index position in the range 625-1250, 1875-2500,3125-3750 and 4375-5000. This generated signal is used as a triggering mechanism for external circuitry. I am trying to use the strobe pin as output.

    Problem in the above code is ISR is not called at any point of time.

    if you have any better suggestion instead of updating the QPOSCMP on every interrupt, is welcome. As per my knowledge I can use shadow register to add one position a head, but not range of different positions.

    Regards
    Eshwar Danduri
  • Hi Eshwar,

    Correct, when you enable shadow mode for QPOSCMP register where on every compare match or QPOSCNT=0 depending on the configuration of QPOSCTL[PCLOAD] it will reload the QPOSCMP with shadow register value. But you can only compare absolute value and not the range.

    Regards,
    Nirav
  • Hi Eshwar,

    Any more questions/concerns regarding the issue that you have mentioned in this thread? If not, can you please go ahead and close it.

    Thanks,

    Nirav