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.

Using external interrupt for sensing the press of a switch in GPIO12

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

  I am studing how the different modules of TMS320 F28027 is working. I am using Piccolo launchpad. When I am using the xint1 for sensing the pressing of the switch in the GPIO12, the program is not going to the interrupt subroutin. I have given below  the codes that I am using. Please support me.

//#############################################################################

// $TI Release: f2802x Support Library v200 $

// $Release Date: Tue Jul 24 10:01:39 CDT 2012 $

//#############################################################################

 

#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 xint1_isr(void);

 

void LED1();

void LED2();

void InitGPIO();

void Initint();

CLK_Handle myClk;

FLASH_Handle myFlash;

GPIO_Handle myGpio;

PIE_Handle myPie;

 

// Global variables for this example

volatile uint32_t Xint1Count;

uint32_t LoopCount;

 

#define DELAY (CPU_RATE/1000*6*510)  //Qual period at 6 samples

 

void main(void)

{

    CPU_Handle myCpu;

    PLL_Handle myPll;

    WDOG_Handle myWDog;

 

 

    int i;

    // 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

 

    InitGPIO();

    Initint();

    // Setup a debug vector table and enable the PIE

    PIE_setDebugIntVectorTable(myPie);

    PIE_enable(myPie);

    CPU_enableInt(myCpu, CPU_IntNumber_1);

    CPU_enableGlobalInts(myCpu);

 

    LED1();

    for(;;) {

               asm(" NOP");

               for(i=1;i<=10;i++) {

 

 

                             }

           }

 

}

 

 

interrupt void xint1_isr(void)

{

 

        LED2();

 

    // Acknowledge this interrupt to get more from group 1

    PIE_clearInt(myPie, PIE_GroupNumber_1);

}

 

 

void Initint()

{

 

 

 

// Register interrupt handlers in the PIE vector table

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

 

 

    // Clear the counters

    Xint1Count = 0; // Count XINT1 interrupts

    LoopCount = 0;  // Count times through idle loop

 

    // Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5

    // Enable INT1 which is connected to WAKEINT

    PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);

 

 

    // Enable Global Interrupts

 

 

 

    // GPIO0 and GPIO1 are inputs

    GPIO_setMode(myGpio, GPIO_Number_12, GPIO_12_Mode_GeneralPurpose);

    GPIO_setDirection(myGpio, GPIO_Number_12, GPIO_Direction_Input);

    GPIO_setQualification(myGpio, GPIO_Number_12, GPIO_Qual_ASync);

 

 

 

    // GPIO0 is XINT1, GPIO1 is XINT2

    GPIO_setExtInt(myGpio, GPIO_Number_12, CPU_ExtIntNumber_1);

 

 

    // Configure XINT1

    PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingAndFallingEdge);

 

 

    // Enable XINT1 and XINT2

    PIE_enableExtInt(myPie, CPU_ExtIntNumber_1);

 

}

 

 

void InitGPIO()

{

 

// Configure GPIO 0,1,2,3as outputs

      GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);

      GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);

      GPIO_setMode(myGpio, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);

      GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);

 

      GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);

      GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);

      GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);

      GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);

 

      GPIO_setLow(myGpio, GPIO_Number_0);

      GPIO_setLow(myGpio, GPIO_Number_1);

      GPIO_setLow(myGpio, GPIO_Number_2);

      GPIO_setLow(myGpio, GPIO_Number_3);

 

}

 

void LED1()

{

        DELAY_US(1000000);

 

        GPIO_setHigh(myGpio, GPIO_Number_0);

        GPIO_setHigh(myGpio, GPIO_Number_1);

        GPIO_setHigh(myGpio, GPIO_Number_2);

        GPIO_setHigh(myGpio, GPIO_Number_3);

 

}

 

void LED2()

{

 

               DELAY_US(100000000);

 

                            GPIO_setLow(myGpio, GPIO_Number_0);

                            GPIO_setLow(myGpio, GPIO_Number_1);

                            GPIO_setLow(myGpio, GPIO_Number_2);

                            GPIO_setLow(myGpio, GPIO_Number_3);

 

                            DELAY_US(100000000);

 

                                   GPIO_setHigh(myGpio, GPIO_Number_0);

                                   GPIO_setHigh(myGpio, GPIO_Number_1);

                                   GPIO_setHigh(myGpio, GPIO_Number_2);

                                   GPIO_setHigh(myGpio, GPIO_Number_3);

 

}

 

 

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

// No more.

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