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.

Unable to control GPIO Direction with GPIODirModeSet function on TMS320C6748 LCDK

I am a newby working with C6748 LCDK and testing below example code. However, I couldn't get the expected result and found that GPIO Direction is not correct. Every GPIO Direction register are indicating they are input in debug memory pane. So I wonder why? It is so weird that starterware function doesn't work as expected. Futhermore, if you look at the function declaration, pin number is limited to less than 32.  Am I missing something?

 /**
 * \file    gpioCardDetect.c
 *
 * \brief   This is a sample application file demonstrating the use of
 *          a GPIO pin to generate an interrupt whenever an MMC/SD card
 *          is inserted or ejected from the Evaluation Module(EVM).
 */

/*
* 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<stdio.h>
#include "gpio.h"
#include "psc.h"

#include "soc_C6748.h"
#include "lcdkC6748.h"
#include "hw_types.h"
#include "PinMuxC6748.h"
#include "hw_syscfg0_C6748.h"

/****************************************************************************/
/*              LOCAL FUNCTION PROTOTYPES                                   */
/****************************************************************************/
static void Delay(volatile unsigned int delay);

/****************************************************************************/
/*              GLOBAL VARIABLES                                            */
/****************************************************************************/

/****************************************************************************/
/*             LOCAL FUNCTION DEFINITIONS                                   */
/****************************************************************************/
void PinMuxSetup()
{
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(0)) |= PINMUX0_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(1)) |= PINMUX1_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(2)) |= PINMUX2_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(3)) |= PINMUX3_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(4)) |= PINMUX4_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(5)) |= PINMUX5_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(6)) |= PINMUX6_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(7)) |= PINMUX7_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(8)) |= PINMUX8_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(9)) |= PINMUX9_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(10)) |= PINMUX10_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(11)) |= PINMUX11_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(12)) |= PINMUX12_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(13)) |= PINMUX13_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(14)) |= PINMUX14_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(15)) |= PINMUX15_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(16)) |= PINMUX16_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(17)) |= PINMUX17_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(18)) |= PINMUX18_VALUE;
 HWREG(SOC_SYSCFG_0_REGS + SYSCFG0_PINMUX(19)) |= PINMUX19_VALUE;

}

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);

    /* Pin Multiplexing of pin 12, and 13 of GPIO Bank 6, Pin 1,2,3,4,and 9 of GPIO Bank 0, and Pin12 of GPIO Bank2 .*/
    PinMuxSetup();

    /* SWITCHEs SETUP */

        /* Sets the pin 2 (GP0[1]) as input.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 2, GPIO_DIR_INPUT);

        /* Sets the pin 3 (GP0[2]) as input.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 3, GPIO_DIR_INPUT);

        /* Sets the pin 4 (GP0[3]) as input.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 4, GPIO_DIR_INPUT);

        /* Sets the pin 5 (GP0[4]) as input.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 5, GPIO_DIR_INPUT);

    /* LEDs SETUP */

        /* Sets the pin 109 (GP6[12]) as output.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT);

        /* Sets the pin 110 (GP6[13]) as output.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 110, GPIO_DIR_OUTPUT);

        /* Sets the pin 45 (GP2[12]) as output.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 45, GPIO_DIR_OUTPUT);

        /* Sets the pin 10 (GP0[9]) as output.*/

        GPIODirModeSet(SOC_GPIO_0_REGS, 10, GPIO_DIR_OUTPUT);

    while(1)
    {
  GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_LOW);

  printf("LED toggle\n");

//  Delay(1000000);

  GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_HIGH);

//  Delay(1000000);
    }


}

/*
** \brief  This function checks the insertion status of the MMC/SD card
**         in the device and prints related statements on the serial
**         commuincation console of the external device.
**
*/

/*
** \brief   This function can be called to generate a delay.
*/

static void Delay(volatile unsigned int delay)
{
    while(delay--);
}


/*****************************END OF FILE************************************/