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.

Interrupting mainISR

Hi,

I'm working on an SPI controlled motor controller using a TMS320F28069. The mainISR where the controller runs from takes about 50-60us to complete. My SPI data needs to be moved from the RxFifo to a buffer every 4 words or I will get an overflow and loose data. To prevent that I want to interrupt the mainISR with my SPI ISR. My question is this, is it a good idea to interrupt the mainISR to service the SPI? Are there certain function calls in the mainISR that should not be interrupted?

Thanks,

Kevin

  • Kevin,
    I moved this to the C2000 forum to get a faster / better response.
    e2e.ti.com/.../449319


    I know in general though you shouldn't interrupt the fastest ISR that is running off your ADC conversion done data for your control loop.
  • My question is more one of motor control I believe. I'm wondering if delaying any of this by interrupting it will have adverse effects on motor performance.

    Here is my mainISR

    interrupt void mainISR(void)
    {
    	ENABLE_INTERRUPTS;
    	static uint16_t stCnt = 0;
    	CTRL_Obj *obj = (CTRL_Obj *)ctrlHandle;
    	ST_Obj *stObj = (ST_Obj *)stHandle;
    
      // toggle status LED
      if(gLEDcnt++ > (uint_least32_t)(USER_ISR_FREQ_Hz / LED_BLINK_FREQ_Hz))
      {
        HAL_toggleLed(halHandle,(GPIO_Number_e)HAL_Gpio_LED2);
        gLEDcnt = 0;
      }
    
      if(stCnt++ >= ISR_TICKS_PER_SPINTAC_TICK) {
    	ST_runPosConv(stHandle, encHandle, ctrlHandle);
    	ST_runVelCtl(stHandle, ctrlHandle);
    	stCnt = 1;
      }
      
      if(gVariables.userControlMode == current_mode)
      {
    	 gMotorVars.IqRef_A = gVariables.set_current;
      }
      else if(gVariables.userControlMode == velocity_mode)
      {
    	  gMotorVars.IqRef_A = _IQmpy(STVELCTL_getTorqueReference(stObj->velCtlHandle), _IQ(USER_IQ_FULL_SCALE_CURRENT_A));
      }
    
      // update Iq reference
      updateIqRef(ctrlHandle);
    
      // compute the electrical angle
      ENC_calcElecAngle(encHandle, HAL_getQepPosnCounts(halHandle));
    
      // acknowledge the ADC interrupt
      HAL_acqAdcInt(halHandle,ADC_IntNumber_1);
    
      // convert the ADC data
      HAL_readAdcData(halHandle,&gAdcData);
    
      // Run the SpinTAC Components
      CTRL_run(ctrlHandle,halHandle,&gAdcData,&gPwmData,ENC_getElecAngle(encHandle));
    
      // write the PWM compare values
      HAL_writePwmData(halHandle,&gPwmData);
    
      // setup the controller
      CTRL_setup(ctrlHandle);
    
      // if we are forcing alignment, using the Rs Recalculation, align the eQEP angle with the rotor angle
      if((EST_getState(obj->estHandle) == EST_State_Rs) && (USER_MOTOR_TYPE == MOTOR_Type_Pm)) //TODO figure this out
      {
    	  ENC_setZeroOffset(encHandle, (uint32_t)(HAL_getQepPosnMaximum(halHandle) - HAL_getQepPosnCounts(halHandle)));
      }
      GPIO_setLow(halHandle->gpioHandle, GPIO_Number_29);
      return;
    } // end of mainISR() function

  • yes, this is probably an issue to have anything that can interrupt the main control loop.
    it is critical in a closed loop application that you have samples from a known time that get processed to create a control output.

    if your serial interrupt were of a known small amount of time perhaps you could fit it in without issues, but this certainly is NOT recommended.