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.

Compiler/TMS320F28069M: External Interrupt issue

Part Number: TMS320F28069M
Other Parts Discussed in Thread: CONTROLSUITE, MOTORWARE

Tool/software: TI C/C++ Compiler

Hi every one .

i tried to modify C:\ti\controlSUITE\Example_F2802xExternalInterrupt\Example_2802xExternalInterrupt.c and use it in Motorware proj_lab13b,c

but I did not get the good result of it. Please kindly see if it has any problem.

  // set the default controller parameters
  CTRL_setParams(ctrlHandle,&gUserParams);


  // setup faults
  HAL_setupFaults(halHandle);


  // initialize the interrupt vector table
  HAL_initIntVectorTable(halHandle);


  // enable the ADC interrupts
  HAL_enableAdcInts(halHandle);
//=================================================
  // this is my function for initializing External intrrupt 
  SAL_Xint(salHandel);

//=========================================================

  // enable global interrupts
  HAL_enableGlobalInts(halHandle);


  // enable debug interrupts
  HAL_enableDebugInt(halHandle);


  // disable the PWM
  HAL_disablePwm(halHandle);


  // initialize the ENC module
  encHandle = ENC_init(&enc, sizeof(enc));

my function is this

void SAL_Xint(SAL_Handle handle)
{
  SAL_Obj* obj= (SAL_Obj*) handle;
  //============================ external intrruot section=========================================

       // PIE_setDebugIntVectorTable(obj->HAL_Handle->pieHandle);
       PIE_enable(obj->HAL_Handle->pieHandle);

       EALLOW;
       ((PIE_Obj*)obj->HAL_Handle->pieHandle)->XINT1 = &xint1_isr;

       EDIS;

       // Register interrupt handlers in the PIE vector table
       PIE_registerPieIntHandler(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (PIE_IntVec_t)&xint1_isr);
       PIE_registerPieIntHandler(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_SubGroupNumber_5, (PIE_IntVec_t)&xint2_isr);

       // Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5
       // Enable INT1 which is connected to WAKEINT
       PIE_enableInt(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);
       PIE_enableInt(obj->HAL_Handle->pieHandle, PIE_GroupNumber_1, PIE_InterruptSource_XINT_2);
       CPU_enableInt(obj->HAL_Handle->cpuHandle, CPU_IntNumber_1);

       // Enable Global Interrupts
       CPU_enableGlobalInts(obj->HAL_Handle->cpuHandle);
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       GPIO_setMode(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_39_Mode_GeneralPurpose);
       GPIO_setDirection(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_Direction_Input);
       GPIO_setQualification(obj->HAL_Handle->gpioHandle, GPIO_Number_39, GPIO_Qual_Sync);

       GPIO_setMode(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_22_Mode_GeneralPurpose);
       GPIO_setDirection(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_Direction_Input);
       GPIO_setQualification(obj->HAL_Handle->gpioHandle, GPIO_Number_22, GPIO_Qual_Sample_6);
       GPIO_setQualificationPeriod(obj->HAL_Handle->gpioHandle, GPIO_Number_22, 0xFF);

       // GPIO0 is XINT1, GPIO1 is XINT2
       GPIO_setExtInt(obj->HAL_Handle->gpioHandle, GPIO_Number_22, CPU_ExtIntNumber_1);
       GPIO_setExtInt(obj->HAL_Handle->gpioHandle, GPIO_Number_39, CPU_ExtIntNumber_2);
       //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



  // initialize Intrrupt
       // Configure XINT1
       PIE_setExtIntPolarity(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingEdge);
       PIE_setExtIntPolarity(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_2, PIE_ExtIntPolarity_RisingEdge);

       // Enable XINT1 and XINT2
       PIE_enableExtInt(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_1);
       PIE_enableExtInt(obj->HAL_Handle->pieHandle, CPU_ExtIntNumber_2);


  //======================================================

}

please check if the sequence of  initialize has any problem.

__interrupt void xint1_isr(void)
{



    PulseCounter++;

    // Acknowledge this interrupt to get more from group 1
    PIE_clearInt(sal_Handel->HAL_Handle->pieHandle, PIE_GroupNumber_1);
}

__interrupt void xint2_isr(void)
{

    PulseCounter++;

    // Acknowledge this interrupt to get more from group 1
    PIE_clearInt(sal_Handel->HAL_Handle->pieHandle, PIE_GroupNumber_1);
}

I would be happy if you help me.

Regards

Dave.

  • Could you please check if the signal is triggered on the related GPIOs? And the XINT1/XINT2 interrupt can't enter always, or just enter one time?

    Btw, did you initialize the interrupt vector for XINT2? and initialize the sal_Handel?

  • thanks Dear  luo

    Could you please check if the signal is triggered on the related GPIOs? yes.i triggered it correctly

    Btw, did you initialize the interrupt vector for XINT2? and initialize the sal_Handel? ya .I initialized the sal_Handel.

    I think GPIO_Number_39 does not have external interrupt ,am I right?

    i think we can use GPIO_Number_00 ~GPIO_Number_31 .is that right?

    I could fix my problem , now I have other question:

    as I said I am using Motorware proj_lab13b,c.  what will happen if external int occur while program executing insta_SPIN Motion code?  

    my external pulse trigger is at least 100Khz which means in worst case we have 20 calls per CTRL_TICK .

    do you think is that going to interfere with Motion Control(FOC Control)? 

    BTW, I optimize my code to take a short time for executing.

    this is going to happen 100Khz in worst case.

    __interrupt void SAL_Mtr1ExtIntPulse(void)
    {
    PulseCounter++;
    
    // Acknowledge this interrupt to get more from group 1
    PIE_clearInt(sal_Handel->HAL_Handle->pieHandle, PIE_GroupNumber_1);
    }
    
    
    

    thanks for attention.

    Regards.

    Dave.

  • 1. Right, XINT just supports GPIO0~GPIO31.
    2. Not a good idea. I don't think there is enough CPU bandwidth to support entering the ISR so frequently, especially the PWM frequency of motor control is a higher one. The XINT interrupt will be missed some time except you enable interrupt nesting mode in the project, however, the instaSPIN-motion will be affected if the interrupt nest is enabled. Maybe you can try eCAP if you just want to measure the duty of the input signal and use a query mode to check the duty in the interrupt of motor control.