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.

RTOS/EK-TM4C1294XL: TI-RTOS Add GPIO interrupt: interrupt pins, priority level, on rising edge

Part Number: EK-TM4C1294XL

Tool/software: TI-RTOS

Hi, 

I am currently trying to set up a GPIO interrupt on pin 3 of port P, also called PP3 on boosterpack 2 of the EK-TM4C1294XL. The GPIO interrupt example with the buttons worked fine, but as soon as I want to change the buttons to PP3, it won't work and goes into a load_exit() routine. The interrupt should be generated as soon as the launchpad gets a (+5V) signal from an external source (arduino for example). I used the following code

/* install Button callback */
GPIO_setCallback(INT_GPIOP3, gpioButtonFxn0);

/* Enable interrupts */
GPIO_enableInt(INT_GPIOP3);

Also, the interrupt should have the highest priority, how can I set the priority level?

Thanks in advance.

Jonas.

  • Hello jonas,

    Can you share the code to configure the GPIO as a whole too in addition to those snippets?
  • /*
     *  ======== gpiointerrupt.c ========
     */
    
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    /* variable to be read by GUI Composer */
    int count = 0;
    
    /*
     *  ======== gpioButtonFxn0 ========
     *  Callback function for the GPIO interrupt on Board_BUTTON0.
     */
    void gpioButtonFxn0(unsigned int index)
    {
        /* Clear the GPIO interrupt and toggle an LED */
        GPIO_toggle(Board_LED0);
    
        if (count++ == 100) {
            count = 0;
        }
    }
    
    /*
     *  ======== gpioButtonFxn1 ========
     *  Callback function for the GPIO interrupt on Board_BUTTON1.
     *  This may not be used for all boards.
     */
    void gpioButtonFxn1(unsigned int index)
    {
        /* Clear the GPIO interrupt and toggle an LED */
        GPIO_toggle(Board_LED1);
    
        if (count++ == 100) {
            count = 0;
        }
    }
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initUART();
    
        /* Turn on user LED */
        GPIO_write(Board_LED0, Board_LED_ON);
    
        System_printf("Starting the GPIO Interrupt example\nSystem provider is set"
                      " to SysMin. Halt the target to view any SysMin contents in"
                      " ROV.\n");
        /* SysMin will only print to the console when you call flush or exit */
        System_flush();
    
        /* install Button callback */
        GPIO_setCallback(INT_GPIOP3, gpioButtonFxn0);
    
        /* Enable interrupts */
        GPIO_enableInt(INT_GPIOP3);
    
        /*
         *  If more than one input pin is available for your device, interrupts
         *  will be enabled on Board_BUTTON1.
         */
        if (Board_BUTTON0 != Board_BUTTON1) {
            /* install Button callback */
            GPIO_setCallback(Board_BUTTON1, gpioButtonFxn1);
            GPIO_enableInt(Board_BUTTON1);
        }
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }

  • Hello Jonas,

    Thanks, I'm not terribly familiar with TI-RTOS yet so I wasn't sure what to make of the single lines.

    Okay so, the issue here is that you are trying to use the wrong input into the GPIO API's. Rather than trying to force the GPIO P3 in that location, you need to modify the EK_TM4C1294XL.c file, namely the GPIO_PinConfig, and add in your P3 port there which will be GPIOTiva_PP_3:

    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        /* EK_TM4C1294XL_USR_SW1 */
        GPIOTiva_PJ_0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
        /* EK_TM4C1294XL_USR_SW2 */
        GPIOTiva_PJ_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
    
        /* Output pins */
        /* EK_TM4C1294XL_USR_D1 */
        GPIOTiva_PN_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
        /* EK_TM4C1294XL_USR_D2 */
        GPIOTiva_PN_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    };

    If you want to use a new name than EK_TM4C1294XL_USR_SW1, you would need to go into EK_TM4C1294XL.h and modify:

    /*!
     *  @def    EK_TM4C1294XL_GPIOName
     *  @brief  Enum of LED names on the EK_TM4C1294XL dev board
     */
    typedef enum EK_TM4C1294XL_GPIOName {
        EK_TM4C1294XL_USR_SW1 = 0,
        EK_TM4C1294XL_USR_SW2,
        EK_TM4C1294XL_D1,
        EK_TM4C1294XL_D2,
    
        EK_TM4C1294XL_GPIOCOUNT
    } EK_TM4C1294XL_GPIOName;

  • Hi Ralph,

    Thank you very much for your help! After I adjusted the code in the EK_TM4C1294XL.h and .c files, I got the interrupt working.

    I then tried to implement the same code in an existing project written by my supervisor but unfortunately it does not work in that project. The idea behind the code is that the EK_TM4C1294XL reads data from a accelerometer on an interrupt and puts it on a queue. As soon as the interrupt is done, a TCPworker will then start to transmit the data through an ethernet connection to a PC. When I try to connect to the launchpad, it sends the data I manually put in the queue by ethernet, but as soon as I try to generate an interrupt, the code jumps to an "exit.c" file at "static void loader_exit(void)". I have no idea why it does this, could you help me?

    I configured pin PP3 as a pin with pulldown resistor and the interrupt is generated when the pin becomes high. The code is below.

    #include <stdint.h>  //int types
    #include <stdbool.h> //boolean types
    #include <stdio.h>
    #include <stdlib.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_ssi.h"
    #include "inc/hw_types.h"
    #include "driverlib/ssi.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/interrupt.h"
    #include "inc/hw_ints.h"
    #include "EK_TM4C1294XL.h"
    
    /*    ======== tcpEcho.c ========
     *    Contains BSD sockets code.
     */
    #include <string.h>
    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <xdc/cfg/global.h>
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/drivers/GPIO.h>
    
    /* NDK BSD support */
    //*******************************************************************************************************************
    #include <sys/socket.h>
    
    /* Example/Board Header file */
    //*******************************************************************************************************************
    #include "Board.h"
    
    /* Include semaphore support */
    //*******************************************************************************************************************
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Queue.h>
    #include <ti/sysbios/knl/Mailbox.h>
    
    //defines
    //*******************************************************************************************************************
    #define TCPPACKETSIZE 256
    #define NUMTCPWORKERS 3
    #define NUMMSGS 8           /* number of messages */
    #define TIMEOUT 10          /* timeout, in system ticks */
    
    // GLOBAL VARIABLES
    //Typedefs
    //*******************************************************************************************************************
    /* This structure can be added to a Queue because the first field is a Queue_Elem. */
    typedef struct Rec {
    Queue_Elem _elem;
    uint32_t data;
    } Rec;
    Queue_Handle myQ;
    
    typedef struct MsgObj {
        Int id; /* writer task id */
        Int val; /* message value */
    } MsgObj, *Msg;
    Mailbox_Handle mbx0;
    
    
    //integers
    //*******************************************************************************************************************
    uint32_t testVal = 0b00111000001110000011100000111000;
    uint32_t* testVal2= &testVal;
    uint32_t testVal3 = 0b10101010101010101010101010101010;
    uint32_t* testVal4= &testVal3;
    uint32_t testVal5;
    uint32_t meas_index;
    uint32_t buffer3;
    uint32_t ui32SysClkFreq;
    uint32_t ui32Index;
    uint32_t loopindex;
    uint32_t pui32DataTx[4];
    uint32_t pui32DataRx[4];
    uint32_t pui32MeasData[12000];
    uint32_t serial_parallel;
    uint32_t dac;
    uint32_t adc_config;
    uint32_t adc_meas;
    uint32_t meas_detect;
    uint32_t Test_Data;
    int Queue_Empty;
    int i = 33;
    
    //other stuff
    //*******************************************************************************************************************
    char buffer2[100];
    
    //functions
    //*******************************************************************************************************************
    void Meas_Trig_IntHandler(void);
    void gpioButtonFxn0(unsigned int index);
    
    /*  ======== tcpWorker ========
     *  Task to handle TCP connection. Can be multiple Tasks running
     *  this function.
     */
    Void tcpWorker(UArg arg0, UArg arg1)
    {
        int  clientfd = (int)arg0;
        int  bytesRcvd;
        int  bytesSent;
        char buffer[TCPPACKETSIZE];
        //char buffer3;
    
        System_printf("tcpWorker: start clientfd = 0x%x\n", clientfd);
    
        // define the response
        buffer2[0] = 0x6a;
        buffer2[1] = 0x61;
        buffer2[2] = 0x6e;
        buffer2[3] = 0x00;
    
        bytesRcvd = 4;
        /*
         * ========== BEGIN IEPE BOARD
         */
        // Initialize variables
        //*****************************************************************************
        uint32_t Queue_Retr_Ind;
        unsigned char bytes[4];
        unsigned long n = 175;
        Rec r1, r2, r3, r4;
        Rec* rp;
    
        // Initialize the clock at 120 MHz
        //*****************************************************************************
        ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
    
        // Main routine
        //*****************************************************************************
        loopindex = 0;
        serial_parallel = 0;
        dac = 0;
        adc_config = 0;
        adc_meas = 0;
        meas_index = 0;
    
        while(1)
        {
            //*****************************************************************************
            // Based on the position in the loop different componets are addressed
            //*****************************************************************************
            if (loopindex == 1)
            {
                serial_parallel = 1;
                dac = 0;
                adc_config = 0;
                adc_meas = 0;
            }
            if (loopindex == 2)
            {
                serial_parallel = 0;
                dac = 1;
                adc_config = 0;
                adc_meas = 0;
            }
            if (loopindex == 3)
            {
                serial_parallel = 0;
                dac = 0;
                adc_config = 1;
                adc_meas = 0;
            }
            if (loopindex == 4)
            {
                serial_parallel = 0;
                dac = 0;
                adc_config = 0;
                adc_meas = 1;
            }
            if (loopindex > 4)
            {
                serial_parallel = 0;
                dac = 0;
                adc_config = 0;
                adc_meas = 0;
            }
    
            // Define the serial to parallel part
            //*****************************************************************************
            if (serial_parallel == 1) // pin in srcs
            {
                // Define the command to send
                //*****************************************************************************
                pui32DataTx[0] = 250; //0b01111010;
                pui32DataTx[1] = 64;
                pui32DataTx[2] = 0;
                pui32DataTx[3] = 0;
    
                // Define the SSI configuration
                //*****************************************************************************
                SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
                GPIOPinConfigure(GPIO_PA2_SSI0CLK);
                GPIOPinConfigure(GPIO_PA3_SSI0FSS);
                GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
                GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
                GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
    
                SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 16);
    
                SSIEnable(SSI0_BASE);
    
                // Manually trigger SRCS: put it now high. Right before writing put it low
                //*****************************************************************************
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
                GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_0);
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, 1);
    
                // Put it on the spi wire
                //*****************************************************************************
    
                // Put SRCS low
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, 0);
    
                // Send 3 bytes of data.
                for(ui32Index = 0; ui32Index < 1 ; ui32Index++) //NUM_SSI_DATA
                {
                    // Send the data using the "blocking" put function.  This function
                    // will wait until there is room in the send FIFO before returning.
                    // This allows you to assure that all the data you send makes it into
                    // the send FIFO.
                    SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
                }
                //
                // Wait until SSI0 is done transferring all the data in the transmit FIFO.
                while(SSIBusy(SSI0_BASE))
                {
                }
    
                // Put SRCS high
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_0, 1);
    
                // Add r1 to the back of myQ.
                r2.data = pui32DataTx[0];
                Queue_put(myQ, &r2._elem);
                r1.data = pui32DataTx[1];
                Queue_put(myQ, &r1._elem);
            }
    
            // Define the DAC part
            //*****************************************************************************
            if (dac == 1)// pin in DACS
            {
                // Define the command to send
                //*****************************************************************************
                pui32DataTx[0] = 0|(65<<6); // six means that you shift it with 6 bits cfr unused bits in the datasheet //0b0100000100000001;
                pui32DataTx[1] = 0;
                pui32DataTx[2] = 0; // 0b0010000100000001;
                pui32DataTx[3] = 0;
    
                // Define the SSI configuration
                //*****************************************************************************
                SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
                GPIOPinConfigure(GPIO_PA2_SSI0CLK);
                GPIOPinConfigure(GPIO_PA3_SSI0FSS);
                GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
                GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
                GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
    
                SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 2000000, 16);
    
                SSIEnable(SSI0_BASE);
    
                // Manually trigger DACS: put it now high. Right before writing put it low
                //*****************************************************************************
                SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
                GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_1);
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, 2);
    
                //*****************************************************************************
                // Put it on the spi wire
                //*****************************************************************************
    
                // Put DACS low
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, 0);
    
                // Send 3 bytes of data.
                for(ui32Index = 0; ui32Index < 4 ; ui32Index++) //NUM_SSI_DATA
                {
                    // Send the data using the "blocking" put function.  This function
                    // will wait until there is room in the send FIFO before returning.
                    // This allows you to assure that all the data you send makes it into
                    // the send FIFO.
                    SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
                }
    
                // Wait until SSI0 is done transferring all the data in the transmit FIFO.
                while(SSIBusy(SSI0_BASE))
                {
                }
    
                // Receive 3 bytes of data.
                //SSIDataGet(SSI0_BASE, Test_Data);
    
                for(ui32Index = 0; ui32Index < 4; ui32Index++) //NUM_SSI_DATA
                {
                    // Receive the data using the "blocking" Get function. This function
                    // will wait until there is data in the receive FIFO before returning.
    
                    //SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
                    SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
    
                    // Since we are using 8-bit data, mask off the MSB.
                    //pui32DataRx[ui32Index] &= 0x00FF;
                }
    
                while(SSIBusy(SSI0_BASE))
                {
                }
    
                // Put DACS high
                GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, 2);
            }
            //*****************************************************************************
            // Define the ADC configuration
            //*****************************************************************************
            if (adc_config == 1) //pin in ADCS
            {
                pui32DataTx[0] = 0b0100000100000001; //const uint16_t
                pui32DataTx[1] = 0b0000000000000010;
                pui32DataTx[2] = 0b0010000100000001;
                pui32DataTx[3] = 0;
    
                // Send 3 bytes of data.
                for(ui32Index = 0; ui32Index < 4 ; ui32Index++) //NUM_SSI_DATA
                {
                    // Send the data using the "blocking" put function.  This function
                    // will wait until there is room in the send FIFO before returning.
                    // This allows you to assure that all the data you send makes it into
                    // the send FIFO.
                    SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
                }
    
                // Wait until SSI0 is done transferring all the data in the transmit FIFO.
                while(SSIBusy(SSI0_BASE))
                {
                }
                // Receive 3 bytes of data.
                //SSIDataGet(SSI0_BASE, Test_Data);
                for(ui32Index = 0; ui32Index < 4; ui32Index++) //NUM_SSI_DATA
                {
                    // Receive the data using the "blocking" Get function. This function
                    // will wait until there is data in the receive FIFO before returning.
                    //SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
                    SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
    
                    // Since we are using 8-bit data, mask off the MSB.
                    //pui32DataRx[ui32Index] &= 0x00FF;
                }
                while(SSIBusy(SSI0_BASE))
                {
                }
            }
    
            //*****************************************************************************
            // Start ADC Measurement
            //*****************************************************************************
            if (adc_meas == 1) //pin in ADCS
            {
                pui32DataTx[0] = 0b00001000; //const uint16_t
                pui32DataTx[1] = 0;
                pui32DataTx[2] = 0;
                pui32DataTx[3] = 0;
    
    //          //*****************************************************************************
    //          // GPIO Activate
    //          //*****************************************************************************
                GPIO_setCallback(EK_TM4C1294XL_PP3, gpioButtonFxn0);
                GPIO_enableInt(EK_TM4C1294XL_PP3);
                /*GPIOPinTypeGPIOInput(GPIO_PORTP_BASE, GPIO_PIN_3);             //define PP3 as an input
                GPIOIntClear(GPIO_PORTP_BASE,GPIO_PIN_3);                      //clear interrupt on PP
                GPIOIntRegister(GPIO_PORTP_BASE, Meas_Trig_IntHandler);        //registers interrupt handler for GPIO port
                GPIOIntTypeSet(GPIO_PORTP_BASE,GPIO_PIN_3,GPIO_RISING_EDGE);   //sets type of interrupt that is coupled to the pin
                //IntEnable(INT_GPIOP3);                                         //enables the interrupt
                GPIOIntEnable(GPIO_PORTP_BASE,GPIO_PIN_3);                     //enables the interrupt
                IntPrioritySet(INT_GPIOP3, 0);                                 //sets priority of interrupt*/
    //
    //          //*****************************************************************************
    //          // Send SSI start ADC Measurement
    //          //*****************************************************************************
    //          // Send 3 bytes of data.
                //
    //          for(ui32Index = 0; ui32Index < 4 ; ui32Index++) //NUM_SSI_DATA
    //          {
    //              // Send the data using the "blocking" put function.  This function
    //              // will wait until there is room in the send FIFO before returning.
    //              // This allows you to assure that all the data you send makes it into
    //              // the send FIFO.
    //              SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
    //          }
    //          // Wait until SSI0 is done transferring all the data in the transmit FIFO.
    //          while(SSIBusy(SSI0_BASE))
    //          {
    //          }
            }
    
            //*****************************************************************************
            // Increase loopindex
            //*****************************************************************************
            loopindex = loopindex + 1;
            //SysCtlDelay(460000);
         /*
         * ========== END IEPE BOARD
         */
            // Dequeue the records and print their data
            Queue_Empty = Queue_empty(myQ);
            Queue_Retr_Ind = 0;
    
            while (!Queue_empty(myQ)&& i<40)
            {
                // Implicit cast from (Queue_Elem *) to (Rec *)
                rp = Queue_dequeue(myQ);
                buffer3 = rp->data; //get data out of rp
    
                //Extract 4 chars from the 32bit buffer3
                bytes[0] = (buffer3 & 0xff000000UL) >> 24;
                bytes[1] = (buffer3 & 0x00ff0000UL) >> 16;
                bytes[2] = (buffer3 & 0x0000ff00UL) >>  8;
                bytes[3] = (buffer3 & 0x000000ffUL)      ;
                bytesSent = send(clientfd, bytes, 4, 0);
                memset(buffer,0, sizeof buffer);
                //free(rp);
                Rec jonas;
                jonas.data = i;
                Queue_put(myQ, &jonas._elem);
                i++;
            }
            System_printf("tcpWorker stop clientfd = 0x%x\n", clientfd);
            close(clientfd);
        }
    }
    
    /*
     *  ======== tcpHandler ========
     *  Creates new Task to handle new TCP connections.
     */
    Void MeasHandler(UArg arg0, UArg arg1)
    {
        int test;
        int iteration;
    
        iteration = 0;
        while(1)
        {
            if (iteration == 1)
            {
                iteration = 0;
            }
            else
            {
                iteration = 1;
            }
        }
    }
    /*
     *  ======== tcpHandler ========
     *  Creates new Task to handle new TCP connections.
     */
    Void tcpHandler(UArg arg0, UArg arg1)
    {
        int                status;
        int                clientfd;
        int                server;
        struct sockaddr_in localAddr;
        struct sockaddr_in clientAddr;
        int                optval;
        int                optlen = sizeof(optval);
        socklen_t          addrlen = sizeof(clientAddr);
        Task_Handle        taskHandle;
        Task_Handle        taskHandle2;
        Task_Params        taskParams;
        Task_Params        taskParams2;
        Error_Block        eb;
    
        server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if (server == -1) {
            System_printf("Error: socket not created.\n");
            goto shutdown;
        }
    
    
        memset(&localAddr, 0, sizeof(localAddr));
        localAddr.sin_family = AF_INET;
        localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
        localAddr.sin_port = htons(arg0);
    
        status = bind(server, (struct sockaddr *)&localAddr, sizeof(localAddr));
        if (status == -1) {
            System_printf("Error: bind failed.\n");
            goto shutdown;
        }
    
        status = listen(server, NUMTCPWORKERS);
        if (status == -1) {
            System_printf("Error: listen failed.\n");
            goto shutdown;
        }
    
        optval = 1;
        if (setsockopt(server, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
            System_printf("Error: setsockopt failed\n");
            goto shutdown;
        }
    
        while ((clientfd =
                accept(server, (struct sockaddr *)&clientAddr, &addrlen)) != -1) {
    
            System_printf("tcpHandler: Creating thread clientfd = %d\n", clientfd);
    
            /* Init the Error_Block */
            Error_init(&eb);
    
            /* Initialize the defaults and set the parameters. */
            Task_Params_init(&taskParams);
            taskParams.arg0 = (UArg)clientfd;
            taskParams.stackSize = 1280;
            //taskParams.priority = 15;
            taskHandle = Task_create((Task_FuncPtr)tcpWorker, &taskParams, &eb);
            if (taskHandle == NULL) {
                System_printf("Error: Failed to create new Task\n");
                close(clientfd);
            }
            /*
             * ============== Begin IEPE
             */
    
    //        /* Initialize the defaults and set the parameters. */
    //        Task_Params_init(&taskParams2);
    //        taskParams2.stackSize = 1280;
    //        taskParams2.priority = 15;
    //        taskHandle2 = Task_create((Task_FuncPtr)measWorker, &taskParams2, &eb);
    //        if (taskHandle2 == NULL) {
    //            System_printf("Error: Failed to create new Task\n");
    //        }
            /*
             * ============== End IEPE
             */
    
            /* addrlen is a value-result param, must reset for next accept call */
            addrlen = sizeof(clientAddr);
        }
        System_printf("Error: accept failed.\n");
    
    shutdown:
        if (server > 0) {
            close(server);
        }
    }
    /*
    * ======== reader ========
    */
    Void reader(UArg arg1, UArg arg2)
    {
        MsgObj msg;
        Int i;
        for (i=0; ;i++) {
            /* wait for mailbox to be posted by writer() */
            if (Mailbox_pend(mbx0, &msg, TIMEOUT) == 0) {
            System_printf("reader: timeout expired for Mailbox_pend()\n");
            break;
            }
            asm(" .global readerActive");
            asm("readerActive:");
            /* print value */
            System_printf("read '%d' from (%d).\n", msg.val, msg.id);
        }
        System_printf("reader done.\n");
        System_exit(0);
    }
    /*
    * ======== writer ========
    */
    Void writer(UArg id, UArg arg2)
    {
        MsgObj msg;
        Int i;
        for (i=0; i < NUMMSGS; i++) {
            /* fill in value */
            msg.id = id;
            msg.val = i;
            asm(" .global writerActive");
            asm("writerActive:");
            System_printf("(%d) writing '%d' ...\n", id, msg.val);
            /* enqueue message */
            Mailbox_post(mbx0, &msg, TIMEOUT);
        }
        System_printf("writer (%d) done.\n", id);
    }
    
    /*
     * ================== BEGIN IEPE
     */
    
    //*****************************************************************************
    // Interrupt for GPIO input
    //*****************************************************************************
    
    void Meas_Trig_IntHandler(void)
    {
    //  //*****************************************************************************
    //  // Define the command to send
    //  //*****************************************************************************
    //  pui32DataTx[0] = 0b00010010;
    //  pui32DataTx[1] = 0;
    //  pui32DataTx[2] = 0;
    //  pui32DataTx[3] = 0;
    
      // Send 3 bytes of data.
      /*for(ui32Index = 0; ui32Index <4 ; ui32Index++) //NUM_SSI_DATA
      {
          // Send the data using the "blocking" put function.  This function
          // will wait until there is room in the send FIFO before returning.
          // This allows you to assure that all the data you send makes it into
          // the send FIFO.
          //
          SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
      }
    
      // Wait until SSI0 is done transferring all the data in the transmit FIFO.
      while(SSIBusy(SSI0_BASE))
      {
      }
    
      // Receive 4 bytes of data.
      SSIDataGet(SSI0_BASE, Test_Data);
    
      for(ui32Index = 0; ui32Index < 4; ui32Index++) //NUM_SSI_DATA
      {
          // Receive the data using the "blocking" Get function. This function
          // will wait until there is data in the receive FIFO before returning.
    
          SSIDataGet(SSI0_BASE, &pui32DataRx[ui32Index]);
          SSIDataGet(SSI0_BASE, &pui32MeasData[meas_index]);
    
          // Increase the buffer index
          meas_index = meas_index + 1;
      }
    
      while(SSIBusy(SSI0_BASE))
      {
      }
        if (meas_index > 12000)
        {
        meas_index = 0;
        }*/
    }
    
    void gpioButtonFxn0(unsigned int index)
    {
        /* Clear the GPIO interrupt and toggle an LED */
        GPIO_toggle(Board_LED0);
    }
    /*
     * ================ END IEPE
     */
    
    /*
     *  ======== main ========
     */
    int main(Int argc, Char* argv[])
    {
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initEMAC();
    
        myQ = Queue_create(NULL, NULL);
    
        System_printf("Starting the TCP Echo example\nSystem provider is set to "
                      "SysMin. Halt the target to view any SysMin contents in"
                      " ROV.\n");
    
        GPIO_write(Board_LED0, Board_LED_OFF);
    
        /* SysMin will only print to the console when you call flush or exit */
        System_flush();
    
        GPIO_setCallback(EK_TM4C1294XL_PP3, gpioButtonFxn0);
        GPIO_enableInt(EK_TM4C1294XL_PP3);
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

  • Hi Jonas,

    You cannot use GPIOIntRegister. Please refer to the last post on this thread: e2e.ti.com/.../635201

    Different device, but the same issue.

    Todd
  • Hi Todd,

    I suppose you mean the GPIOIntRegister at line 382? This line is commented using /* and */ but did not come through when I posted the code in my previous post. 

  • Can you confirm IntRegister is not not being included by looking for it in the mapfile? Can you check for g_pfnRAMVectors also?
  • I checked the .map file in the debug folder of the project and I did not find IntRegister or g_pfnRAMVectors in the file.

  • While unlikely to be the cause of "today's expanded issue" your earlier code snippet:

    if (count++ == 100) {
    count = 0;
    }

    may be made more robust by substituting ... if (count++ >= 100) {

    (the "exactness of the "count match" gains you little - and should noise, spikes, ESD arrive - the "safety" afforded by that "broadened test" may "save the day.")

  • Jonas,

    Bummer. Okay, let's look a closer at the issue. When you say " but as soon as I try to generate an interrupt", which interrupt? How are you generating it?

    How you looked in Tools->ROV->Hwi->Exception to see if there was an exception? Hopefully there will be a call stack also (not guaranteed).

    Todd
  • I generate the interrupt by connecting pin PP3 (to which I attached the interrupt) to the +5V of the board. In the EK_TM4C1294XL.c file, I set the pin in PullDown mode and it should trigger when the pin becomes high.

    I don't find the "tools" directory yo are speaking of, where should I look?

    Jonas. 

  • If you are using CCS, the Tools menu is present when in the debug perspective. If you are using IAR, you need to plug it into IAR. Refer to the TI-RTOS Getting Started Guide for details.