AnsweredAssumed Answered

QEI - INX CNT can not count, when A / B(SIGMODE =0) stop. 

Question asked by yansin lee on Jul 13, 2020
Latest reply on Jul 20, 2020 by yansin lee

中文 :

功能說明 : 設計Z偵測到脈波輸入時,觸發中斷,清除AB向脈波計數值。

 

問題描述 :

QEI - 當AB相沒有收到任何輸入脈波時,INCNT無法計數。

當AB相有偵測到輸入脈波時,INCNT才會計數。

這現象會導致,編碼器AB 輸入停止時,無法成功清除AB相計數值。

有其他方法可以讓Z 計數獨立計算,不受INGATE(index gating configuration) 影響嗎?

 

English : 

My Function :   when Z detect pulse , interrtup will clear AB count value.

Problem : 

QEI - when AB encoder  no  input  pulse, INCNT can not  count.

when AB encoder detect input pulse, INCANT can count.

lead  to   " when AB encoder stop,  it can not clear AB count value."

 

have other way?   let Z  count indepdently.  INGATE ( index gating configuration) can not work.

 

 

 

以下是我QEI 設定

--------------------------------

 

static void Setup_QEI(void)
{
 /* Enable the clock to the Switch Matrix */
 Chip_Clock_EnablePeriphClock (SYSCTL_CLOCK_QEI);
 Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 27, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 28, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 29, (IOCON_MODE_PULLDOWN | IOCON_FUNC1));
 Chip_SWM_MovablePinAssign(SWM_QEI0_PHA_I, 27); 
 Chip_SWM_MovablePinAssign(SWM_QEI0_PHB_I, 28); 
 Chip_SWM_MovablePinAssign(SWM_QEI0_IDX_I, 29); 
 Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
     
/* QEI Control register reset */
LPC_QEI->CON = 15;    
LPC_QEI->CLR = 0xFFFFFFFF;
/* Set QEI signal mode = AB */
LPC_QEI->CONF &= ~(1 << ((uint32_t)1));

 /* Set QEI capture mode  2XAB */
 LPC_QEI->CONF &= ~(1 << ((uint32_t)2));

/* PLCK = 72M, Edges = 2, Load = 72M */
/* 72M = 1000 ms, 1 ms = 72000 */
LPC_QEI->LOAD = (uint32_t) EnCoderPeriod * 72000;
LPC_QEI->MAXPOS = 0xFFFFFFFF;
/* Enable the interrupt for the QEI */
/* SCT/QEI(0) > MRT(6) > Can(7), Priotity 0~7, 0 is the highest */
NVIC_EnableIRQ (QEI_IRQn);
NVIC_SetPriority(QEI_IRQn, 0);

/* QEI Interrupt Enable Clear register, claer all interrupt enable */
LPC_QEI->IEC = 0xFFFFFFFF;

/* QEI Interrupt Enable Set register for INX_EN(BIT0)*/
LPC_QEI->IES = ((uint32_t)(1 << 0));
}
void QEI_IRQHandler(void)
{
    /* Check QEI interrupt status (Bit 0) for INX_EN(Z) */
    if(LPC_QEI->INTSTAT & ((uint32_t)(1 << 0)))
    {
        /* When index pulse(Z) was detedtd, clear Encoder pulse */  
        /* QEI Control register reset */
        LPC_QEI->CON = 15;           
        /* QEI Interrupt Status clear (Bit 15) for INX_EN(Z) */
        LPC_QEI->CLR = ((uint32_t)(1 << 0));    
    }
}

Outcomes