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.

External interrupt issue with F28027

Other Parts Discussed in Thread: TMS320F28027, CONTROLSUITE

Hi,

I'm new to the forums and to C programming and am attempting to create an interrupt when the signal on one of the GPIO pins goes high. Using some of the example code for writing external interrupts I was able to successful enter the ISR with a button push, however, when I change the GPIO # to monitor a low/high on a incoming signal the ISR does not execute.

This is the code I'm using to set up the interrupt for the switch. Then, I change the GPIO from #12 to #34 (input signal pin) and the code no longer works when a change from low to high occurs. Is there a different setup or interrupt I need to enable?   

 

PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4, (intVec_t)&xint1_isr);

PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);  

CPU_enableInt(myCpu, CPU_IntNumber_1);

GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose);

GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input);

GPIO_setPullUp(myGpio, GPIO_Number_12, GPIO_PullUp_Disable);

GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1);

PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingEdge);

PIE_enableExtInt(myPie, CPU_ExtIntNumber_1);

In addition, I have 3 separate external interrupts I would like to use, is it possible to tie all 3 pins to one interrupt and monitor the interrupt flag for which GPIO pin was triggered? (I'm used to the MSP430 and monitoring the port flags)

Thanks in advance.

--Sean

  • Upon further review of the datasheet I believe that XINTx only works on GPIO0-31 so I changed the GPIO pin of my incoming signal, however, the ISR still did not trigger. In addition, I was able to set up XINT1, XINT2, and XINT3 to all work with the button press, but none of them seem to work with another GPIO pin.

     

    EDIT: After using a GPIO # within the appropriate range and ensuring that CPU interrupt 1 and 12 were both enabled according to PIE Group Number 1 and 12 all three interrupts executed without a problem!

  • Hi Sean,

       I am also using the three external interrupts of TMS320F28027 in my project. Xint1 & Xint 2 are working with out any problem. Xint3 is not working. I use the same instruction lines as Xint1 & Xint2. I am not able to find out where did I make the mistake. Can you please let me know, any special instruction to be used for Xint 3. Please support me.

    Regards,

    Mahesh K.R.

  • Hello Mahesh,

    Are you using line  PIE_enableExtInt(myPie, CPU_ExtIntNumber_3); for enabling XINT3?

    If so, I think there is a bug on this API PIE_enableExtInt().

    From pie.c (C:\ti\controlSUITE\device_support\f2802x\v220\f2802x_common\source), it mentions that the index is 10 (means INT11). It shoud be 11 (means INT12).

    void PIE_enableExtInt(PIE_Handle pieHandle, const CPU_ExtIntNumber_e intNumber)
    {
        PIE_Obj *pie = (PIE_Obj *)pieHandle;
        uint16_t index;
        uint16_t setValue;

        
        if(intNumber < CPU_ExtIntNumber_3)
        {
          index = 0;
          setValue = 1 << (intNumber + 3);
        }
        else
        {
          index = 10; // --> This should be 11
          setValue = 1 << 0;
        }


        // set the value
        pie->PIEIER_PIEIFR[index].IER |= setValue;


        // set the bits
        pie->XINTnCR[intNumber] |= PIE_XINTnCR_ENABLE_BITS;

        return;
    } // end of PIE_enableExtInt() function

    I haven't checked another APIs but I hope this helps.

    Best regards,

    Maria

  • Hi Maria,

      I have changed as per your instruction. No improvement. Xint3 is not working.

    Regards,

    Mahesh K.R.

  • Can you attach your code so we can check it together?

  • Hi Marina,

    In Main program I am using below three lines specific to Xint3.

    {

    InitXint3();

    PIE_registerPieIntHandler(myPie, PIE_GroupNumber_12, PIE_SubGroupNumber_1, (intVec_t)&xint3_isr);

    CPU_enableInt(myCpu, CPU_IntNumber_12);

    }

    Initalization InitXint3 is called.

     

    void InitXint3()

    {

     

    PIE_enableInt(myPie, PIE_GroupNumber_12, PIE_InterruptSource_XINT_3);

     

     

    GPIO_setQualification(myGpio, GPIO_Number_29, GPIO_Qual_ASync);

     

    GPIO_setExtInt(myGpio, GPIO_Number_29, CPU_ExtIntNumber_3);

     

    PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_3, PIE_ExtIntPolarity_RisingEdge);

     

    PIE_enableExtInt(myPie, CPU_ExtIntNumber_3);

    }

    Interrupt subroutine below program.

    interrupt void xint3_isr(void)

    {

           InitLCD();

     

           Displayscreen();

     

           PIE_clearInt(myPie, PIE_GroupNumber_12);

    }

     

    Regards,

    Mahesh K.R.

  • Hello Mahesh,

    What kit that you use for your MCU (F28027)?

    Please make sure that GPIO29 is not use anywhere else (hardware and firmware).

    If you use C2000 Launchpad, you need to switch off the serial switch (S4).

    Best regards,

    Maria

  • Hi Marina,

     I am using C2000 Launchpad.  One of my C2000 Launchpad processor failed and I removed the processor from the Launchpad and soldered the programming lines to a connector and use that connector to program prototyping board ( I made it by soldering  TMS320F28027  processor on a general purpose PQFP 48 pin prototyping board). So all the GPIOs are configured different from C2000 Launchpad. I am using GPIO 5, GPIO16 & GPIO 29 for the three external interrupts. I interchanged these GPIOs to three external interrupts. All the time Xint3 will not work, other two are working, it is not the problem of GPIO. I use the same instructions as other external interrupts, So it is not the problem of the program. I suspect some  bug in the include file or supporting file. I am not sure.

    Regards,

    Mahesh K.R.

  • Mahesh Kodakkattil said:
    I suspect some  bug in the include file or supporting file

    You can check all the files that contain APIs that you use above for EXTINT3 and compare them with the datasheet. Maybe you will find something.

    Or for safer, use the registers directly to set all the bits (not using provided APIs).

    Best regards,

    Maria

  • Mahesh,

    When I have a time, I will try this to my C2000 LP.

    In the mean time, hope you figure out the solution and solve it.

    Best regards,

    Maria

  • Hello Mahesh,

    I have tried XINT3 in my C2000 LP and it works well.

    The bug was only the one that I mentioned before.

    pie.c

    void PIE_enableExtInt(PIE_Handle pieHandle, const CPU_ExtIntNumber_e intNumber)
    {
        PIE_Obj *pie = (PIE_Obj *)pieHandle;
        uint16_t index;
        uint16_t setValue;

        if(intNumber < CPU_ExtIntNumber_3)
        {
          index = 0;
          setValue = 1 << (intNumber + 3);
        }
        else
        {
          //index = 10;
          index = 11;    // modified
          setValue = 1 << 0;
        }

        // set the value
        pie->PIEIER_PIEIFR[index].IER |= setValue;

        // set the bits
        pie->XINTnCR[intNumber] |= PIE_XINTnCR_ENABLE_BITS;

        return;
    } // end of PIE_enableExtInt() function


    Here I attach my code. GPIO01 is connected as XINT3. And GPIO03 in LP is the LED that will be toggled in interrupt every time external interrupt occurs.

    //#############################################################################
    //
    //!   This program sets up GPIO01 as XINT3.
    //!
    //!   XINT3 input is synched to SYSCLKOUT.
    //!
    //!   GPIO03 will be toggled in the interrupt when there is falling edge interrupt.
    //!
    //!   For C2000 LP, connect GPIO01 to GND and then release. The LED that connected
    //!   to GPIO03 will be OFF and ON.
    //
    //  (C) Copyright 2012, Texas Instruments, Inc.
    //#############################################################################
    // $TI Release: PACKAGE NAME $
    // $Release Date: PACKAGE RELEASE DATE $
    //#############################################################################
    
    #include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
    
    #include "f2802x_common/include/clk.h"
    #include "f2802x_common/include/flash.h"
    #include "f2802x_common/include/gpio.h"
    #include "f2802x_common/include/pie.h"
    #include "f2802x_common/include/pll.h"
    #include "f2802x_common/include/pwr.h"
    #include "f2802x_common/include/wdog.h"
    
    // Prototype statements for functions found within this file.
    __interrupt void xint3_isr(void);
    
    CLK_Handle myClk;
    FLASH_Handle myFlash;
    GPIO_Handle myGpio;
    PIE_Handle myPie;
    
    #define DELAY (CPU_RATE/1000*6*510)  //Qual period at 6 samples
    
    void main(void)
    {
        CPU_Handle myCpu;
        PLL_Handle myPll;
        WDOG_Handle myWDog;
    
        // Initialize all the handles needed for this application 
        myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj)); 
        myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
        myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
        myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
        myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
        myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
        myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));
    
        // Perform basic system initialization    
        WDOG_disable(myWDog);
        CLK_enableAdcClock(myClk);
        (*Device_cal)();
        
        //Select the internal oscillator 1 as the clock source
        CLK_setOscSrc(myClk, CLK_OscSrc_Internal);
        
        // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
        PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);
        
        // Disable the PIE and all interrupts
        PIE_disable(myPie);
        PIE_disableAllInts(myPie);
        CPU_disableGlobalInts(myCpu);
        CPU_clearIntFlags(myCpu);
        
        // If running from flash copy RAM only functions to RAM   
    #ifdef _FLASH
        memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif 
    
        // Setup a debug vector table and enable the PIE
        PIE_setDebugIntVectorTable(myPie);
        PIE_enable(myPie);
    
        // Register interrupt handlers in the PIE vector table
        PIE_registerPieIntHandler(myPie, PIE_GroupNumber_12, PIE_SubGroupNumber_1, (intVec_t)&xint3_isr);
    
        // Enable XINT3 in the PIE: Group 12 interrupt 1
        PIE_enableInt(myPie, PIE_GroupNumber_12, PIE_InterruptSource_XINT_3);
        CPU_enableInt(myCpu, CPU_IntNumber_12);
    
        // Enable Global Interrupts
        CPU_enableGlobalInts(myCpu);
    
        // GPIO1 are inputs
        GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);
    	GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Input);
    	GPIO_setQualification(myGpio, GPIO_Number_1, GPIO_Qual_Sync);
    
        // GPIO01 is XINT3
        GPIO_setExtInt(myGpio, GPIO_Number_1, CPU_ExtIntNumber_3);
    
        // Configure XINT3
        PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_3, PIE_ExtIntPolarity_FallingEdge);
    
        // Enable XINT3
        PIE_enableExtInt(myPie, CPU_ExtIntNumber_3);
    
        // C2000 LP, LED (GPIO03)
    	GPIO_setLow(myGpio, GPIO_Number_3);
    	GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);
    	GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);
    
        for(;;) {
        }
    }
    
    __interrupt void xint3_isr(void)
    {
    
        //GPIO_setLow(myGpio, GPIO_Number_34);
    	GPIO_toggle(myGpio, GPIO_Number_3);
    
        Xint1Count++;
    
        // Acknowledge this interrupt to get more from group 1
        PIE_clearInt(myPie, PIE_GroupNumber_12);
    }
    
    //===========================================================================
    // No more.
    //===========================================================================
    

    I used C:\ti\controlSUITE\device_support\f2802x\v220\f2802x_examples_drivers\external_interrupt as the template. You may try it to your device.

    Best regards,

    Maria

  • Hi Maria,

      Thank you very much for all the support. There were few issues in my programming.

    1. As you mentioned previously, I changed below in 'pie.c'.

     //index = 10;
          index = 11;    // modified

    2.  I did all the changes as you suggested and did 'C' coding for all the external interrupts, still Xint1 & Xint2 were working fine. Xint3 was not working. I am using three PWM interrupts, One timer interrupt, three external interrupts and four ADC interrupts in my project. I blocked all the other interrupts and ran only three external interrupts, All are working fine. So I think the culprit is some clash between the other interrupts. Now I have to enable one by one interrupts and see what is really causing this problem. I will update you once I find out the root cause.

    Regards,

    Mahesh K.R.

  • OK, really hope you find it soon!

    Best regards,

    Maria

  • Hi Maria,

        I tested the external interrupts separately and all the three are working fine. When I enabled PWM interrupts, Xint3 stop working. I enabled the timer interrupt, No problem. I enable PWM1, PWM2 & PWM3 interrupts. Then I found PWM3 interrupt is also not working. PWM1 & PWM2 are working with out any problem. Right now Xint1 & Xint2, PWM1 & PWM2 are working fine. Xint3 & PWM3 are not working. This is going to make a trouble for my project. I am using 50KHz PWM switching (PWM1 & PWM2 for two power supply) for two Boost converters.

    Right now, I am planning to optimize the configurations such a way that I use two interrupts from Xint and two interrupts from PWM, one Timer interrupt and two ADC interrupts. Later stage if some one support me to resolve this issue, I will expand the interrupts.

    Thank you very much for all the support.

    Regards,

    Mahesh K.R.

  • Hello Mahesh,

    That's good that you can narrow down the problem.

    You can post new thread about XINT3 and PWM3 problems that you are facing.

    Hope your project is going well.

    Good luck!

    Best regards,

    Maria