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.

C674x GPIO Bank3 Input Enable

Other Parts Discussed in Thread: OMAPL138

Hi , I'm developing on C674x

I try to enable GPIO3[0] , GPIO3[1].  But I failed.

My configuration:

1. PSC1_3  enbale  

PSC1_lPSC_enable(0, 3); //GPIO

2.  PINMUX10 config

PINMUX10 = 0x88888881; 

3. Set GPIO bank23 direction 0x01E26038

0x01E26038    =  0xFFFFFFFF

4. Watch CCS Memory Browser

When I pull GP3[0],GP3[1] high/low, the bit16 and 17 of  0x01E26048(GPIO Banks 2 and 3 Input Data Register) keep being "0"

What did I miss to config???  Please help to advice. Thx!

CCS Memory Browser

PSC1_3  --> control GPIO

PinMUX10  config GPIO Bank3

GPIO Bank 2 and 3 Register Address

  • Hi Hakeen,

    Have you installed the starterware package on your machine ?

    In starterware, you can find interrupt example for EVM board to detect the SD card status.

    I've modified that code for switch S2 on LCDK board.

    You can take this as reference and modify it.

    Try it let me know.

    /**
     * \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 Titus 

    Thx!  Will test it.

    BTW,  in my previous way,  GPIO Bank 0 work normally.

  • Hi Hakeen,

    I've modified GPIO0 to GPIO4 bank too.

  • Hi Titus 

    Not work.

    I used the code gpioCardDetect.c  in C6748StartWare.

    I traced the code....  

    1.PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,

    PSC_MDCTL_NEXT_ENABLE);

    ==> power on PSC1_3

    2.In gpioCardDetect.c,  GPIOBank4Pin0PinMuxSetup();

    In gpioCardDetect.c  , it's Bank4

    But, PINMUX10 bit 31-28 is for GP3[6] C6747

    3.  In gpioCardDetect.c, GPIODirModeSet(SOC_GPIO_0_REGS, 65, GPIO_DIR_INPUT);

    According to C6747 datasheet SPRUH91B, GP3[6] should be 55

    So, I add GPIODirModeSet(SOC_GPIO_0_REGS, 55, GPIO_DIR_INPUT);

    4.Watch Memory browser in CCS6

    GP3[6] should be bit 22 of 0x01E26038

    The value won't change when I pull GP3[6] high/low 

      

    After you installed CCS6 , you will have evmc6747_dsp.gel file.

    This gel file have the similar code.   gpioCardDetect.c and evmc6747_dsp.gel config GPIO in the same steps.

    Step One : PSC1_3

    Step Two : PinMUX

    Step There : GPIO Direction

    But, GPIO bank 3 of C6747 can't work. (Utilize CCS memory browser to watch GPIO Bank 3 values)

    How to enable GPIO bank3 Input ????

    PINMUX10 Definition

  • Hi Hakeen,

    Ohh. You are using OMAPL137/C6747 right.

    Okay, TI didn't release any starterware for OMAPL137/C6747 devices but only for OMAPL138/C6748 processors.

    Have you checked in CCS registers for the PINMUX and required appropriate configuration registers ?

    Could you attach or send your project to me.

    E-mail -> x0213399@ti.com

  • Hi Titus 

    Thx!  We changed the resistor value of GPIO.

    Then, it work normally.  Thanks for the advise :)

  • Hi Hakeen,

    Sounds good.

    Thanks for your update.