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
}