Hi
I am trying to have an ISR fired when the QEP Index signal goes 1, but no way
The ISR is called every time I move the rotor and not only when the index gives one
Where is the error:
// init QEP Int ISR to QEP_Index_ISR HAL_Obj *obj = (HAL_Obj *)halHandle; PIE_Obj *pie = (PIE_Obj *)obj->pieHandle; EALLOW; #ifdef J5 pie->EQEP2_INT = &QEP_Index_ISR; #else pie->EQEP1_INT = &QEP_Index_ISR; #endif EDIS; #ifdef QEP // initialize the ENC module encHandle = ENC_init(&enc, sizeof(enc)); // setup the ENC module ENC_setup(encHandle, 1, USER_MOTOR_NUM_POLE_PAIRS, USER_MOTOR_ENCODER_LINES, 0, USER_IQ_FULL_SCALE_FREQ_Hz, USER_ISR_FREQ_Hz, 8000.0); // configure QEP Index Interrupt obj = (HAL_Obj *)halHandle; #ifdef J5 QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[1]; #else QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0]; #endif //QEP_clear_interrupt_flag( qep, QEINT_Iel); //QEP_enable_interrupt( qep, QEINT_Iel); EQep1Regs.QCLR.all = 0x0FFF; // clear Int Flags EQep1Regs.QEINT.all = 0; // disable int EQep1Regs.QEINT.bit.IEL = 1; // Set IE for Index //EQep1Regs.QEPCTL.bit.IEI = 2; // Initializes the position counter on the rising edge of the QEPI signal (QPOSCNT = QPOSINIT) // Enable PIE group 5 interrupt 1 for EQEP1_INT PIE_enableInt( obj->pieHandle, PIE_GroupNumber_5, PIE_InterruptSource_EQEP1 ); // PieCtrlRegs.PIEIER5.bit.INTx1 = 1; // PieCtrlRegs.PIEIER5.all = M_INT1; // enable the cpu interrupt for QEP interrupts CPU_enableInt(obj->cpuHandle,CPU_IntNumber_5);
the ISR
//-------------------------------------------------------------------------------------------------
__interrupt void QEP_Index_ISR(void)
{
//GpioDataRegs.GPBDAT.bit.GPIO34 = 1- GpioDataRegs.GPBDAT.bit.GPIO34;
//GpioDataRegs.GPBDAT.bit.GPIO39 = 1 - GpioDataRegs.GPBDAT.bit.GPIO34;
HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
// acknowledge the QEP interrupt
HAL_Obj *obj = (HAL_Obj *)halHandle;
#ifdef J5
QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[1];
#else
QEP_Obj *qep = (QEP_Obj *)obj->qepHandle[0];
#endif
// clear the QEP interrupt flag
// QEP_clear_interrupt_flag( qep, QEINT_Iel);
//EQep1Regs.QCLR.bit.INT = 1; // Clears the interrupt flag and enables further interrupts to be generated if an event flags is set to 1
EQep1Regs.QCLR.all = 0x0FFF; // clear Int Flags
// Acknowledge interrupt from PIE group 5
//PIE_clearInt(obj->pieHandle,PIE_GroupNumber_5);
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
}