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 Handle

Hello,

I am using the gpioExample that comes with the Evaluation Module. I'm trying to configure other ports as outputs and set them to 1 but I don't know why it doesn't works.

Correct me if I am wrong or I forgot something:

#include <stdio.h>
#include <string.h>
#include <std.h>
#include <log.h>
#include <tsk.h>
#include <idl.h>
#include <ecm.h>
#include <iom.h>
#include <sio.h>
#include <ti/pspiom/gpio/Gpio.h>

Gpio_Handle gpio0;

#define LOW 0x0
#define HIGH 0x1

#define GPIO0_12_PIN 13
#define GPIO0_13_PIN 14

void main (void)

{

Gpio_Params gpioParams = Gpio_PARAMS;
Gpio_PinCmdArg UserPinCmdArg;

gpioParams.instNum = 0;
gpioParams.BankParams[0].inUse = Gpio_InUse_No;

gpioParams.BankParams[0].PinConfInfo[12].inUse = Gpio_InUse_No;
gpioParams.BankParams[0].PinConfInfo[13].inUse = Gpio_InUse_No;

/* open the GPIO driver to get a handle to it */
gpio0 = Gpio_open(&gpioParams);

/* make sure our driver instance is ok */
if (NULL == gpio0)
{
    SYS_abort("Gpio_open() failed to create Gpio driver instance!\n");
}

/* Call the EVM specific initialization function                          */
configureGpio();

/* Configure GPIO0_12 as an output        */
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio0,&UserPinCmdArg);

/* Configure GPIO0_13 as an output */
UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = Gpio_Direction_Output;
Gpio_setPinDir(gpio0,&UserPinCmdArg);

// Set Data ow in SET_DATA register for GPIO(GPIO0_12_PIN).           
// This turns the LED on
UserPinCmdArg.pin = GPIO0_12_PIN;
UserPinCmdArg.value = LOW;
Gpio_setPinVal(gpio0,&UserPinCmdArg);

// Set Data low in SET_DATA register for GPIO(GPIO0_13_PIN)

// This turns the LED on

UserPinCmdArg.pin = GPIO0_13_PIN;
UserPinCmdArg.value = LOW;
Gpio_setPinVal(gpio0,&UserPinCmdArg);

return;

}

This program only turn on USER_LED_1 wich is connected to GPIO0_12_PIN but not USER_LED_2 connected to GPIO0_13_PIN. What I am forgetting?

Thank you!

  • it is a pinmux issue.

    Please open the project:

    C:\Program Files\Texas Instruments\pspdrivers_01_30_00_05\packages\ti\pspiom\platforms\evm6747\build\evmInit.pjt

    Open the source file gpio_evminit.c

    Add the following line to the end of the configureGpio function:

        sysRegs->PINMUX15 |= ( (CSL_SYSCFG_PINMUX15_PINMUX15_15_12_GPIO0_13) << \
                            (CSL_SYSCFG_PINMUX15_PINMUX15_15_12_SHIFT)  );

     

    Rebuild the evmInit.pjt.

    Then open your project and "Rebuild ALL".

     

  • Thank you Mariana! I am a newby in DSP and I am a bit lost in this but with your help I am improving every day.

    Thanks again!

    Cerilet.

  • I have more problems.

    Now I'm trying to set GPIO5[10] and GPIO5[11].

    I add those rows at the end of the gpio_evminit.c file:

    sysRegs->PINMUX8 |= ( (CSL_SYSCFG_PINMUX8_PINMUX8_23_20_GPIO5_10) << \
                            (CSL_SYSCFG_PINMUX8_PINMUX8_23_20_SHIFT)  );

    sysRegs->PINMUX8 |= ( (CSL_SYSCFG_PINMUX8_PINMUX8_27_24_GPIO5_11) << \
                            (CSL_SYSCFG_PINMUX8_PINMUX8_27_24_SHIFT)  );

    Rebuilded the evmInit.pjt I open my project and modify it, but it does not work. What is wrong?

    Gpio_Handle gpio0;

    void main(void)
    {
       
        Gpio_Params gpioParams = Gpio_PARAMS;
        Gpio_PinCmdArg UserPinCmdArg;

        gpioParams.instNum = 0;
        gpioParams.BankParams[5].inUse = Gpio_InUse_No;
       
        gpioParams.BankParams[5].PinConfInfo[10].inUse = Gpio_InUse_No;
        gpioParams.BankParams[5].PinConfInfo[11].inUse = Gpio_InUse_No;

        /* open the GPIO driver to get a handle to it */
        gpio0 = Gpio_open(&gpioParams);

        /* Call the EVM specific initialization function                          */
        configureGpio();

        /* Configure GPIO5_10 and GPIO5_11 as an output */
        UserPinCmdArg.pin = 11;
        UserPinCmdArg.value = Gpio_Direction_Output;
        Gpio_setPinDir(gpio0,&UserPinCmdArg);
        UserPinCmdArg.pin = 12;
        UserPinCmdArg.value = Gpio_Direction_Output;
        Gpio_setPinDir(gpio0,&UserPinCmdArg);

        // Setting GPIO5[10] to LOW
        UserPinCmdArg.pin = 11;
        UserPinCmdArg.value = LOW;
        Gpio_setPinVal(gpio0,&UserPinCmdArg);

        // Setting GPIO5[11] to HIGH
        UserPinCmdArg.pin = 12;
        UserPinCmdArg.value = HIGH;
        Gpio_setPinVal(gpio0,&UserPinCmdArg);

        Gpio_close(gpio0);

        return;
    }

     

    I was looking for more information and only found in the cslr_gpio.h was:

    // Bank registers and Pin tokens

    #define GP5  2

    #define GP5P10 (1 << 26)
    #define GP5P11 (1 << 27)

    I thing somewhere I have to select the bank register 2 and bits 26th and 27th but I don't know how.

    Where can I find more information about how works all that?