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.

GPIO interrupt

Other Parts Discussed in Thread: OMAPL138, OMAP-L138, OMAP-L137, SYSBIOS

 Hi All!

I want to get GPIO interrupt by external triger.


I configure McASP clk output for 12.8kHz on the pin, and it is works well. I routed by the wire McAsp clk pin to GP2[15].

Falling edge on GP2[15] should generate interrupt. In the interrupt routine should toggle GP2[12]. So finally I should see periodic signal on the GP2[12]. I read manual and investigated example projects.

On the GP2[15] I see 12.8kHz signal by the scope, but on the GP2[12] I see nothing.

Please look to my code of initialization bellow:

static void ConfigureIntGPIO(void)
{
	// Configure GPIO interrupts for ARM or DSP

	// Register the ISR in the Interrupt Vector Table
	IntRegister(C674X_MASK_INT4, GPIOIsr);

	// Map the system interrupt to the DSP maskable interrupt
	IntEventMap(C674X_MASK_INT4, SYS_INT_GPIO_B2INT);

	// Enable DSP maskable interrupt
	IntEnable(C674X_MASK_INT4);


}

static void GPIOIsr(void)
{
    /* Disable the interrupts for pins of bank 2 in GPIO.*/
    GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);

    unsigned int res;
    	res = GPIOPinRead(SOC_GPIO_0_REGS, 45);
    	if(res == GPIO_PIN_LOW)
    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);
    	else
    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);


    // Clear the system interrupt status in the DSPINTC
    IntEventClear(SYS_INT_GPIO_B2INT);


    /* Clears the Interrupt Status of GP2[15] in GPIO.*/
    GPIOPinIntClear(SOC_GPIO_0_REGS, 48);

    //GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);
}


static void SetUpInt(void)
{
	// Setup the ARM or DSP interrupt controller
	// Initialize DSP interrupt controller
	IntDSPINTCInit();

	// Enable DSP interrupts globally
	IntGlobalEnable();

}

void hardware_init(void)
{
	/* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/
	    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,
		     PSC_MDCTL_NEXT_ENABLE);

	/* Power up the McASP module */
	    PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_MCASP0, PSC_POWERDOMAIN_ALWAYS_ON,
			     PSC_MDCTL_NEXT_ENABLE);

    /* Pin Multiplexing of pin (GP2-10) 10 of GPIO Bank 2.*/
    GPIOBank2Pin15PinMuxSetup();
    GPIOBank2Pin12PinMuxSetup();
	
	    McASPPinMuxSetup();
	

	    McASPclk_start();

    /* Sets the pin 48(GP2[15]) as input for receive interrupt from external ADC.*/
    GPIODirModeSet(SOC_GPIO_0_REGS, 48, GPIO_DIR_INPUT);

    /* Sets the pin 45(GP2[12]) as output for CLK of external ADC.*/
   GPIODirModeSet(SOC_GPIO_0_REGS, 45, GPIO_DIR_OUTPUT);

    GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);

    /*
    ** Configure falling edge and falling edge triggers on pin 48 to generate
    ** an interrupt
    */
   GPIOIntTypeSet(SOC_GPIO_0_REGS, 48, GPIO_INT_TYPE_FALLEDGE);

    /* Enable interrupts for Bank 2.*/
   GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);

    /* Configuring the AINTC to handle interrupts.*/
    SetUpInt();

    /* Configure GPIO interrupts */
    ConfigureIntGPIO();

	   // spiInit();

	   // edmaInit();

}

hardware_init() called in the main.c

  • Looks to be a straight mod of StarterWare gpioCardDetect.c. Any reason for GPIOBankIntEnable(SOC_GPIO_0_REGS, 2) to be commented out in GPIOIsr()? The gpioCardDetect.c does it the mainline but that's not appropriate in your case.

  • Thanks, for respose!

    Now GPIOBankIntEnable(SOC_GPIO_0_REGS, 2) is not commented, but anyway project does not work. On the GP2[12] I see nothing.

     In same time I'm sure that program comes to ISR, but just once, because I see that GP2[12] after start has invert value of initialization value (after one call of ISR)

  • Not much to add. Your code looks good. GPIO numbers are good. Bank numbers are consistent with the gpioCardDetect.c example. Perhaps try without the McAsp and put a switch on the input GPIO. The McAsp code may startup the interrupts before your GPIO code is ready.

  • Hi Dmitriy1,

    Dmitriy1 says said:
     In same time I'm sure that program comes to ISR, but just once, because I see that GP2[12] after start has invert value of initialization value (after one call of ISR)

    If you read the value of the register, INSTAT23, ( particularly the bit position, GP2P15),  you will get the status of the GPIO interrupt events. By this we can check whether the interrupt is occured or not.

    As Norman suggested, as a first step, just have the code of falling edge interrupt generation through GPIO and make sure it works consistently and then include the code for GPIO toggling on GP2[12]  and then the code for McASP.

    Not able to identify any errors in the code. It seems to be OK for me. But, if needed, you can refer the tested CSL example code for "GPIO interrupt generation on rising edge" existing as a part of MCSDK 1.01 software package for OMAPl138 LCDK.

     

    Regards,

    Shankari

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.
    --------------------------------------------------------------------------------------------------------

  •  Thank you for response, Shankari!

    Shankari, I delete other functionality(McAsp and timer). Now my code consist only of GPIO initialization and ISR function (dummy function for the test case)


     I see that INSTAT23_GP2[15] is no toggled when I switch level on GP2[15].

  • Can you post the source for GPIOBank2Pin15PinMuxSetup() GPIOBank2Pin12PinMuxSetup()?

  •  Thank you for response, Norman!

    PinMux functions code bellow:

    /* Pin Multiplexing bit mask to select GP2[15] pin. */
    #define PINMUX5_GPIO2_15_ENABLE    (SYSCFG_PINMUX5_PINMUX5_3_0_GPIO2_15  << \
                                        SYSCFG_PINMUX5_PINMUX5_3_0_SHIFT)
    
    /* Pin Multiplexing bit mask to select GP2[12] pin. */
    #define PINMUX5_GPIO2_12_ENABLE    (SYSCFG_PINMUX5_PINMUX5_15_12_GPIO2_12  << \
                                        SYSCFG_PINMUX5_PINMUX5_15_12_SHIFT)
    
    void GPIOBank2Pin12PinMuxSetup(void)
    {
         unsigned int savePinmux = 0;
    
         /*
         ** Clearing the bit in context and retaining the other bit values
         ** in PINMUX5 register.
         */
         savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) &
                      ~(SYSCFG_PINMUX5_PINMUX5_15_12));
    
         /* Setting the pins corresponding to GP2[12] in PINMUX5 register.*/
         HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) = (PINMUX5_GPIO2_12_ENABLE | savePinmux);
    
    }
    
    /**
     * \brief   This function selects the Pin 15 of GPIO bank 2 for use.
     *          This GPIO pin is multiplexed with pins of other peripherals
     *          in the System on Chip(SoC).
     *
     * \return  None.
     *
     */
    
    void GPIOBank2Pin15PinMuxSetup(void)
    {
         unsigned int savePinmux = 0;
    
         /*
         ** Clearing the bit in context and retaining the other bit values
         ** in PINMUX5 register.
         */
         savePinmux = (HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) &
                      ~(SYSCFG_PINMUX5_PINMUX5_3_0));
    
         /* Setting the pins corresponding to GP2[15] in PINMUX5 register.*/
         HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) = (PINMUX5_GPIO2_15_ENABLE | savePinmux);
    
    }

    Norman, I think that project does not work maybe because something wrong from ARM side, however I use TIs Linux kernel for ARM side without modification.

  • Hi,

    Your pinmux configurations seems to be good.

    Are you using this project as a stand alone or with SYSLINK ?

  •  I use my project as standalone, but run it by the XDS100v3 on the target which is has launched Linux.

  • Okay...I'm confused. The DSP calls in your code gave me the impression this was DSP only. With an ARM in the picture, the ARM can see the interrupt and service it before the DSP can do so. I has been a while and I remember it was not much fun telling Linux to ignore DSP interrupts. The ignore list is confusing array in the board.c file. With GPIOs, I don't know if you can ignore specific GPIOS. Usually it is entire peripherals.

    EDIT: Oops. Checked my notes. The ignore list is for DMA interrupts only.

  • Hi Dimitry,

    DSP and ARM cannot access the same peripheral resource at same time, You need to disable resource in ARM end if DSP is in need.

    PS: GPIO peripheral is already busy with ARM.

    Please refer the below TI wiki.

    http://processors.wiki.ti.com/index.php/OMAP-L137_Audio_Drivers_in_the_DSP_%2B_Linux#Adapting_your_Linux_Kernel_to_avoid_conflicts

    Have you tried to load this DSP gpio interrupt app code in DSP core alone through emulator ?

    I'm sure it should work.

  •  Thanks, Titus

    I will stop kernel loading in u-boot and load application by the emulator. Is it correct?

  • Hi,

    Yes, You are right.

    Don't touch ARM (Disconnect the ARM core) and load your GPIO app directly to the DSP core.

    Let us know the results.

  •  how to disconnect ARM core? in u-boot till the load Linux kernel  ARM core are not disabled?

  • On the OMAP-L137 where the DSP boots first, I would have to start a debug session with the DSP then start another session on the ARM. On the OMAP-L138 where the ARM boots first, you should be able to start a debug session on the ARM and start a second session on the DSP. The ARM does not have to run any code. The GEL scripts handle any HW init.

  •  Thank you for response.

    I tried to debug my project on the DSP side when when u-boot is waiting command from the operator(I stopped seconds counter before Linux starting). In this case I'm sure that ARM does not use GPIO, but my project still does not working.

  • Not much to add. A remote possibility that the SYSCFG is locked by some other code. Can you check the pinmux registers after you have configured them for GPIO? To unlock, call SysCfgRegistersUnlock() first thing into main(). Hopefully no other code locks it back up before the pinmux config. That's all I got.

  • for the test, I added

    while(1)
        {
        	 unsigned int res;
        	    	res = GPIOPinRead(SOC_GPIO_0_REGS, 45);
        	    	if(res == GPIO_PIN_LOW)
        	    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);
        	    	else
        	    		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);
    
        }

    to the main.c

    and see that GP2[12] toggles with 1Mhz frequency.

    So, Norman, anyway, thanks!

  • Maybe try without interrupts. A this point, I wonder if GP2[15] is connected to a blown pad.

    while(1)
      {
        unsigned int res;
        res = GPIOPinRead(SOC_GPIO_0_REGS, 48);
        GPIOPinWrite(SOC_GPIO_0_REGS, 45, res);
      }

  • while(1)
      {
        unsigned int res;
        res = GPIOPinRead(SOC_GPIO_0_REGS, 48);
        GPIOPinWrite(SOC_GPIO_0_REGS, 45, res);
      }

    works well.


    So, pinmux configuration and GPIO register configuration is OK.

    I think trouble is hidden in the 

     /* Configuring the AINTC to handle interrupts.*/
        SetUpInt();
    
        /* Configure GPIO interrupts */
        ConfigureIntGPIO();

    functions. But I took them from gpioCardDetect.c

  • The gpioCardDetect.c interrupt setup functions should work as-is. The caveat is that you don't have some other interrupt code taking over INT4. I found merging StarterWare examples can be problematic due to this. More than one example uses C674X_MASK_INT4. You could try some other one like the highest possible C674X_MASK_INT15. I've seen 5 and 6 used for EDMA.

  • unfortunately, with C674X_MASK_INT15 also not working... it is look like mysticism :(

  • "It is a riddle, wrapped in a mystery, inside an enigma" - Winston Churchill.

    Perhaps IntDSPINTCInit() is called somewhere after ConfigureIntGPIO(). That would wipe out your ISR vector setting.

  • Hi Dimitry,

    This is the DSP code I have modified for interrupt generation for Switch S2 from OMAPL138 LCDK board.

    Please try this code alone and let us know the status.

    Modify the code for rising or falling or both interrupts.

    /**
     * \file    Titus : Modified from gpioCardDetect.c
     *
     * \brief   This is a sample application file demonstrating the use of
     *          a GPIO pin to generate an interrupt whenever a Switch S2 is pressed
     *          or released from the LCDK board.
     */
    
    /*
    * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
    *
    *  Redistribution and use in source and binary forms, with or without
    *  modification, are permitted provided that the following conditions
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the
    *    documentation and/or other materials provided with the
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */
    
    #include "interrupt.h"
    #include "uartStdio.h"
    #include "gpio.h"
    #include "psc.h"
    
    #include "soc_C6748.h"
    
    #include "lcdkC6748.h"
    
    
    #include "hw_syscfg0_C6748.h"
    
    
    #include<stdio.h>
    
    
    /****************************************************************************/
    /*              LOCAL FUNCTION PROTOTYPES                                   */
    /****************************************************************************/
    static void Delay(volatile unsigned int delay);
    static void ConfigureIntGPIO(void);
    static void CheckCardStatus(void);
    static void SetupInt(void);
    static void GPIOIsr(void);
    
    
    
    /****************************************************************************/
    /*              GLOBAL VARIABLES                                            */
    /****************************************************************************/
    volatile unsigned char flag = 0;
    
    /****************************************************************************/
    /*             LOCAL FUNCTION DEFINITIONS                                   */
    /****************************************************************************/
    
    int main(void)
    {
    
    
        /* The Local PSC number for GPIO is 3. GPIO belongs to PSC1 module.*/
        PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,
    		     PSC_MDCTL_NEXT_ENABLE);
    
        /* Initializes the UART instance.*/
        //UARTStdioInit();
    
        /* Pin Multiplexing of pin 4 of GPIO Bank 2.*/
        GPIOBank2Pin4PinMuxSetup();
    
        /* Sets the pin 37(GP2[4]) as input.*/
        GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_DIR_INPUT);
    
        /*
        ** Configure rising edge and falling edge triggers on pin 37 to generate
        ** an interrupt
        */
    
        //GPIOIntTypeSet(SOC_GPIO_0_REGS, 37, GPIO_INT_TYPE_FALLEDGE); //Switch release interrupt
        //GPIOIntTypeSet(SOC_GPIO_0_REGS, 37, GPIO_INT_TYPE_RISEDGE); //Switch press interrupt
        GPIOIntTypeSet(SOC_GPIO_0_REGS, 37, GPIO_INT_TYPE_BOTHEDGE); //Switch release & press interrupt
    
        /* Enable interrupts for Bank 2.*/
        GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);
    
        /* Configuring the AINTC to handle interrupts.*/
        SetupInt();
    
        /* Configure GPIO interrupts */
        ConfigureIntGPIO();
    
        printf("Configured.....Done!\n");
    
    
        while(1)
        {
            if(flag == 1)
            {
                CheckCardStatus();
            }
        }
    
    }
    
    
    /*
    ** \brief   This function invokes necessary functions to configure the DSP
    **          processor and DSP Interrupt Controller(DINTC) to receive and
    **          handle interrupts.
    */
    
    static void SetupInt(void)
    {
    	// Setup  DSP interrupt controller
    
    	// Initialize the DSP Interrupt Controller
    	IntDSPINTCInit();
    
    	// Enable DSP Interrupts Globally
    	IntGlobalEnable();
    
    }
    
    
    /*
    ** \brief  This function configures the AINTC to receive the GPIO interrupt.
    */
    
    static void ConfigureIntGPIO(void)
    {
    	// Configure GPIO interrupts for DSP
    
    	// Register the ISR in the Interrupt Vector Table
    	IntRegister(C674X_MASK_INT4, GPIOIsr);
    
    	// Map the system interrupt to the DSP maskable interrupt
    	IntEventMap(C674X_MASK_INT4, SYS_INT_GPIO_B2INT);
    
    	// Enable DSP maskable interrupt
    	IntEnable(C674X_MASK_INT4);
    }
    
    
    /*
    ** \brief   Interrupt Service Routine to be executed on GPIO interrupts.
    **          This disables the bank interrupts, clears the system interrupt
    **          status and pin interrupt status. This also sets flag as 1.
    */
    static void GPIOIsr(void)
    {
        /* Disable the interrupts for pins of bank 2 in GPIO.*/
        GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);
    
        // Clear the system interrupt status in the DSPINTC
        IntEventClear(SYS_INT_GPIO_B2INT);
    
    
        /* Clears the Interrupt Status of GP2[4] in GPIO.*/
        GPIOPinIntClear(SOC_GPIO_0_REGS, 37);
    
        flag = 1;
    }
    
    /*
    ** \brief  This function checks the status of the Switch S2
    **         in the device and prints related statements on the serial
    **         communication console of the external device.
    **
    */
    
    static void CheckCardStatus(void)
    {
        Delay(0x1FFF);
    
        // Clear the system interrupt status in the DSPINTC
        IntEventClear(SYS_INT_GPIO_B2INT);
    
        /* Clears the Interrupt Status of GP2[4] in GPIO.*/
        GPIOPinIntClear(SOC_GPIO_0_REGS, 37);
    
        /*
        ** 'GPIOPinRead' here returns the value on the GP2[4].
        ** If value returned is 1, it implies the Switch S2 is released.
        ** If value returned is 0, it implies the Switch S2 is pressed.
        */
    
        if (GPIOPinRead(SOC_GPIO_0_REGS, 37))
        {
        	printf("Switch S2 is released.\n");
        }
        else
        {
        	printf("Switch S2 is pressed.\n");
        }
    
        flag = 0;
    
        /* Enable interrupts for pins of bank 2.*/
        GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);
    }
    
    /*
    ** \brief   This function can be called to generate a delay.
    */
    
    static void Delay(volatile unsigned int delay)
    {
        while(delay--);
    }
    
    
    /*****************************END OF FILE************************************/
    

     

  • Hi Dmitry,

    Is it possible to upload your complete source code?. We will look into it and get back if there is any mismatch in the programming sequence.

     

    Regards,

    Shankari

     

  •  Thanks Titus!

    So, Your code works well.

    But I use sysbios

    Now I trying to find what is wrong in my code. I attached my project which is work incorrect.1537.DSP_test.zip

  •  I see if my project has no while(1) function interrupt does not working. So, that means that SYSBIOS after initialization goes to Idle loop mode, where GPIO interrupts does not working. Is it correct?

  • Some guesses. I think that StarterWare code does not play well with SYS/BIOS. I do not believe the StarterWare interrupt code is even hooked in. SYS/BIO interrupt code likely overrides the StarterWare. I suggest looking at the gpio driver in BIOSPSP. I assume you have reasons for not using BIOSPSP itself. And I assume you reasons for keeping SYSBIOS instead of going with a plain bare-metal StarterWare project. A guess at what the code mods might look like:

    /* Based on biospsp_03_00_01_00\drivers\gpio\src\Gpio.c:Gpio_regIntHandler() */
    #include <ti/sysbios/family/c64p/Hwi.h>
    #include <ti/sysbios/family/c64p/EventCombiner.h>

    /* Based on biospsp_03_00_01_00\drivers\gpio\src\Gpio.c:Gpio_regIntHandler() */
    static void ConfigureIntGPIO(void)
    {
      Int8 evtNum  = SYS_INT_GPIO_B2INT; /* Same as CSL_INTC_EVENTID_GPIO_BNK2_INT? */
      Int32 hwiNum = C674X_MASK_INT10;
      Gpio_Isr isrHandler;

      /* Map the eventid to the ECM Dispatch of the SYS/BIOS */
      EventCombiner_dispatchPlug(evtNum, GPIOIsr, NULL, TRUE);

      /* Enabling the event */
      EventCombiner_enableEvent(bankInfo->evtNum);

      /* Enabling the HWI_ID */
      Hwi_enableIER(1 << bankInfo->hwiNum);
    }
    static void GPIOIsr(void *p) /* Add argument */
    {
      ...
    }
    static void SetUpInt(void)
    {
      /* Let SYS/BIOS handle DSP interrupt enable? */
    }

  •  Thanks Norman!

    Sorry for my ignorance.


    Finally I need GPIO even just as interrupt event for start EDMA transaction.

  • Just noticed a few cut'n'paste errors. Again:

    /* Based on biospsp_03_00_01_00\drivers\gpio\src\Gpio.c:Gpio_regIntHandler() */
    #include <ti/sysbios/family/c64p/Hwi.h>
    #include <ti/sysbios/family/c64p/EventCombiner.h>
    static void ConfigureIntGPIO(void)
    {
      Int8 evtNum  = SYS_INT_GPIO_B2INT; /* Same as CSL_INTC_EVENTID_GPIO_BNK2_INT? */
      Int32 hwiNum = C674X_MASK_INT10;
      EventCombiner_dispatchPlug(evtNum, GPIOIsr, NULL, TRUE);
      EventCombiner_enableEvent(evtNum);
      Hwi_enableIER(1 << hwiNum);
    }
    static void GPIOIsr(void *p) /* Add argument */
    {
      ...
    }
    static void SetUpInt(void)
    {
      /* Let SYS/BIOS handle DSP interrupt enable? */
    }

    StarterWare EDMA uses interrupts as well. I'd suggest using the EDMA LLD package. I last used it a few years back with DSP/BIOS. I assume there is one now for SYS/BIOS.

  • Hi Dimitry,

    I don't know about RTOS app (SYSBIOS)

    Any way, I have checked your code and got some doubts from that.

    Why did you read GPIO no 45  why not GPIO no 48 which is already configured as INPUT ?

    What are you trying to do?

    Try to use the INTERRUPT part code alone in starterware before combining with SYSBIOS

    static void GPIOIsr(void)
    {
        /* Disable the interrupts for pins of bank 2 in GPIO.*/
       GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);

        unsigned int res;
            res = GPIOPinRead(SOC_GPIO_0_REGS, 45);
            if(res == GPIO_PIN_LOW)
                GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);
            else
                GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);


        // Clear the system interrupt status in the DSPINTC
        IntEventClear(SYS_INT_GPIO_B2INT);


        // Clears the Interrupt Status of GP2[15] in GPIO
        GPIOPinIntClear(SOC_GPIO_0_REGS, 45);
       // HWREG(SOC_GPIO_0_REGS + GPIO_INTSTAT_STAT23) |= (1 << 15);

        GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);

    }

    Try this and let us know the status.

    static void GPIOIsr(void)
    {
        /* Disable the interrupts for pins of bank 2 in GPIO.*/
       GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);
    
        unsigned int res;
    
        // Clear the system interrupt status in the DSPINTC
        IntEventClear(SYS_INT_GPIO_B2INT);
    
    
        // Clears the Interrupt Status of GP2[15] in GPIO
        GPIOPinIntClear(SOC_GPIO_0_REGS, 45);
       // HWREG(SOC_GPIO_0_REGS + GPIO_INTSTAT_STAT23) |= (1 << 15);
    
        GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);
    
    
        	res = GPIOPinRead(SOC_GPIO_0_REGS, 48);	//Titus :     GPIODirModeSet(SOC_GPIO_0_REGS, 48, GPIO_DIR_INPUT);
        	if(res == GPIO_PIN_LOW)
    		{
    		printf("I'm in if condn\n");
        		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_HIGH);
    		}
        	else
    		{
    		printf("I'm in else condn\n");
        		GPIOPinWrite(SOC_GPIO_0_REGS, 45, GPIO_PIN_LOW);
    		}
    
    }

  •  Tnanks for the question!

    I read GPIO2[12] in ISR because I want just invert GPIO2[12] in the each invoke of ISR. It was only for the test.

    Anyway, I found what is wrong with help of TI's community. 

    I should use psp driver adn HWI in my case for use GPIO interrupt in SYS/BIOS

  •  Hello again!


    I looked to biospsp_03_00_01_00 GPIO example.

    In demonstration project creates Task with while() function for waiting GPIO interrupt. It is look like the same as was before in my project. And in .cfg file of demonsrtation GPIO project of biospsp HWI is missing.


    part of .cfg file

    var task0Params = new Task.Params();
    task0Params.priority = 5;
    task0Params.instance.name = "task0";
    Program.global.task0 = Task.create("&gpioExampleTask", task0Params);
    
    ECM.eventGroupHwiNum[0] = 7;
    ECM.eventGroupHwiNum[1] = 8;
    ECM.eventGroupHwiNum[2] = 9;
    ECM.eventGroupHwiNum[3] = 10;

    Can I use only HWI for GPIO interrupt (without Task) if yes, how to do it? Finally I need GPIO interrupt not for GPIO toggling, but only for EDMA transaction starting.

    I tried to create HWI in cfg file in my project:

    System.SupportProxy = SysMin;
    var hwi0Params = new Hwi.Params();
    hwi0Params.instance.name = "hwi0";
    hwi0Params.eventId = 49;
    hwi0Params.maskSetting = xdc.module("ti.sysbios.interfaces.IHwi").MaskingOption_NONE;
    Program.global.hwi0 = Hwi.create(4, "&GPIOIsr", hwi0Params);

    But it is does not work.

  • My background is with StarterWare (aka "Bare Metal") and a bit of DSPBIOS. SYSBIOS is quite a bit different. Maybe Titus can comment. Or you might have to ask in the TI-RTOS forum.

    Just the clarify...does the BIOSPSP GPIO example (with the extra task) work?

  •  Thanks, Norman!

    Yes, BIOSPSP GPIO example works well.


    I saw that in BIOSPSP GPIO example HWI is missing in .cfg file, but in .cfg mentioned Task. Before, I tried to use HWI GPIO and Idle, but it not worked. I still  don't understood why...


     In my first project (which is not working well) I tried to use HWI from Timer with same ISR, It worked well. With HWI GPIO it doesn't works.