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_SetPin, no output

Hardware:      Evm6748

Software:       CCS4,  BIOS 5, PSP 1.30.01. 

Application:   The application started as the UPP EvmB example combined with a NDK example.  UPP channel B was removed from the tci file, and it was removerd from the source code.

Problem description:

See the following code snippett.  After calling gioOpen(),  gpioReadPin(  GPIOPIN(7,1) ) works, but  gpioSetPin( GPIOPIN(7,0), value ) does not.  The output is monitored by oscilloscope bewteen  pins 21 (GPIO7[0]) and pin 29 (DGND).

 

#define GPIOPIN( bank, pin) ( bank*16 + pin + 1 )

 

#include <std.h>

#include <pwrm.h>
#include <pwrm6748.h>

#include "ti/pspiom/cslr/soc_C6748.h"

#include "ti/pspiom/cslr/cslr_gpio.h"
#include "ti/pspiom/gpio/Gpio.h"

Gpio_Handle     gpio0 = 0x0u;

int testgpio( int value )
{
  gpioOpen(Void);

  gpioSetPin( GPIOPIN(7,0), value );

  return( gpioReadPin( GPIOPIN(7,1) ) );
}

int gpioOpen(Void)
{
    Gpio_PinCmdArg  pinCmdArg;
    Gpio_IntrCmdArg intrCmdArg;

 

 

    Gpio_Params     gpioParams = Gpio_PARAMS;

    int n;

    gpioParams.instNum = 0;

    gpioParams.BankParams[7].inUse = Gpio_InUse_No;
    for ( n = 0; n < 16; n++ ) {
      gpioParams.BankParams[7].PinConfInfo[n].inUse = Gpio_InUse_No; // test input
    }

    gpio0 = Gpio_open(&gpioParams);
 
    PWRM_setDependency(PWRM_RSRC_GPIO);

    // Bank 7, Pin 0 as output
    pinCmdArg.pin   = GPIOPIN(7,0);
    pinCmdArg.value = Gpio_Direction_Output;
    Gpio_setPinDir(gpio0, &pinCmdArg);

    // Bank 7, Pins 1-15 as input
    for ( n = 1; n < 16; n++ ) {
      pinCmdArg.pin   = GPIOPIN(7,n);
      pinCmdArg.value = Gpio_Direction_Input;
      Gpio_setPinDir(gpio0, &pinCmdArg);
    }

    return 0;
}

void gpioClose()
{
  if ( gpio0 ) Gpio_close(gpio0);

  gpio0 = 0x0;
 
  return;
}

int gpioSetPin( Uint32 pinspec, int val )
{
  Gpio_PinCmdArg  pinCmdArg;

  pinCmdArg.pin   = pinspec;
  pinCmdArg.value = val;

  return( Gpio_setPinVal(gpio0, &pinCmdArg) );
}

int gpioReadPin( Uint32 pinspec )
{
  Gpio_PinCmdArg  pinCmdArg;

  pinCmdArg.pin   = pinspec;
  pinCmdArg.value = 0;

  if ( Gpio_getPinVal(gpio0, &pinCmdArg) )
    return( -1 );

  return( (int) pinCmdArg.value );
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • Hi Mitch,

    With the available setup, I did a couple of tests to verify the Gpio_setPinVal API and it works fine for me.. here are the details:

    In my test, I configured GPIO bank 1 - 0th pin (pin number: 17) as Output pin.

    1. PINMUX - 

    Inside configureGpio() function in gpio_evmInit.c file,

    sysCfgRegs->PINMUX4 = 0x80000000u;

    2. Before opening GPIO driver - 

    Inside main()

         gpioParams.BankParams[1].inUse = Gpio_InUse_No; gpioParams.BankParams[1].PinConfInfo[0].inUse = Gpio_InUse_No;

    3. In gpioSample_io.c file I have -

     

    Void gpioExampleTask(Void)

    {

        Gpio_PinCmdArg  pinCmdArg;

    configureGpio();

         pinCmdArg.pin = 17u;

            pinCmdArg.value = Gpio_Direction_Output;

    Gpio_setPinDir(gpio0, &pinCmdArg); /*************************************************/ pinCmdArg.pin = 17u; pinCmdArg.value = 1u; Gpio_setPinVal(gpio0, &pinCmdArg);

    Gpio_getPinVal(gpio0, &pinCmdArg); printf("pinVal = %x",pinCmdArg.value);

    /*************************************************/ pinCmdArg.pin = 17u; pinCmdArg.value = 0u; Gpio_setPinVal(gpio0, &pinCmdArg); Gpio_getPinVal(gpio0, &pinCmdArg); printf("pinVal = %x",pinCmdArg.value);

    /*************************************************/ pinCmdArg.pin = 17u; pinCmdArg.value = 1u; Gpio_setPinVal(gpio0, &pinCmdArg); Gpio_getPinVal(gpio0, &pinCmdArg); printf("pinVal = %x",pinCmdArg.value);

    /*************************************************/ pinCmdArg.pin = 17u; pinCmdArg.value = 0u; Gpio_setPinVal(gpio0, &pinCmdArg); Gpio_getPinVal(gpio0, &pinCmdArg); printf("pinVal = %x",pinCmdArg.value);

    /*************************************************/

    Gpio_close(gpio0); LOG_printf(&trace, "End of GPIO sample application!\n"); }

    Placing breapoint at each "printf" statement and executing, I could see the pin toggling on the oscilloscope. Please verify if you have missed something. 

    In the meanwhile I will try to debug further/check with your settings. 

    Hope this helps..

     

    Thanks & regards,

    Raghavendra

  • I solved this myself a week ago.

    What you listed is nice, but that's the easy part and it does not address the main part of the question.

    Notice that my question stipulated that i am using parts of the UPP example and NDK example.  Setting a single pin mux register is not going to work for that. 

    What you are missing is the pinmux utility and a description of how to use it.  At the time that i posted the question i was vaguely aware of the pin mux utility but had no clue as to what do with the output from the pin mux utility.   With some grepping around in the source code tree i was able to figure out that part.

    So, the bottom line to this exercise is that there needs to be a better more complete description of how to use the pin mux utility and its output.

     

  • Hi Mitch Nelson,

    I am sorry to hear that you had to struggle because of lack of documentation for pinmux utility. We will give this feedback to the team maintaining it so that it is documented better.

    regards,

    Shanmuga

  • Shanmuga

    One more thing:

    In the GPIO user's guide it says only that pin multiplexing needs to be considered.  That is about as useless a paragraph as there can be in any document.  It needs to either give complete instructions or give a specific document number and url where the user can find specific instructions.

    The same has to appear in any description of any interface that needs the pin mux.

    Moreover, you need to review all of the examples (that means every one of them) and make sure that there are no conflicts in pin mux, interrupts, memory usage, etc. (or as few conflcts as is possible), and that their tcf's can be combimed easily and transparently.