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 not working

Other Parts Discussed in Thread: SYSBIOS, OMAPL138

Hi,

I am just trying to run GPIO port with 30 MHz external oscillator on c6746 based custom board. I am using CCSv5.

I configured the PINMUX19 as 0x00000008 and also configured the GPIO reg as output and the set the value on that pin.

But when I looked at the value of registers in CCSv5, I get the value of PINMUX19 which I set while in case of GPIO, every registers value is0x00000000. It seems GPIO registers is not getting accessed. Even I checked the value of GPIO pin with multimeterm, I don't get desired value.

Can somebody, let me know what exactly is the problem?

Thanks in Advance..!!

  • Hi,

    What type of code are running on your board ?

    ie starterware or SYSBIOS or CSL package ?

    Is this your own code or TI provided ?

  • Hi Ujala Gupta,

    For C6746 device, the GPIO sample example already exist as a part of StarterWare 01.20.01.01. and you can download it from http://processors.wiki.ti.com/index.php/StarterWare_OldReleases

    You can download the source code and check how the programming  sequences are done for GPIO. Alternatively you can even check the same at http://processors.wiki.ti.com/index.php/StarterWare_GPIO

    If possible, you can even post your code here.

     

    Regards,

    Shankari

     

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

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

  • Actually, I am just trying to run a very code to verify that my board is working or not. So I write a code for GPIO as below:

    int main()

    {

          PINMUX19 =  PINMUX19 | 0x00000008;    //  Configuring it as  GPIO pins

    //  Setting direction of GPIO 

        GPIO_DIR8 = GPIO_DIR8 & (~(1<<8)) ;

          GPIO_DIR8 = GPIO_DIR8 & (~(1<<9)) ; 

    // Setting the value

    GPIO_SET_DATA  =  GPIO_SET_DATA  | ( 1 << 8 );

    GPIO_SET_DATA  =  GPIO_SET_DATA  | ( 1 << 9 );

     }

    Now when I see the value of registers in the CCSv5, I can see the value of PINMUX19 as expected while in case of GPIO, every register has value 0x00000000.

    It seems GPIO registers are not accessable.

    I also checked the voltage at test point of GPIO pins, but it was same in all the case(set or reset).

    Let me know what should I do.

  • Hi Rahul Shah,

    In your code, enabling the GPIO by PSC power domain is missing. That's why I suggested you to have a look at the programming sequence of GPIO.

    Try the following code and update us.  You can modify the required PIn number. You will find the header files at the above mentioned package.

    #include "gpio.h"
    #include "psc.h"
    
    #include "soc_C6748.h"
    #include "lcdkC6748.h"
    
    /****************************************************************************/
    /*              LOCAL FUNCTION PROTOTYPES                                   */
    /****************************************************************************/
    static void Delay(volatile unsigned int delay);
    
    /****************************************************************************/
    /*              GLOBAL VARIABLES                                            */
    /****************************************************************************/
    
    /****************************************************************************/
    /*             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);
    
        /* Pin Multiplexing of pin 12 of GPIO Bank 6.*/
        GPIOBank6Pin12PinMuxSetup();
    
        /* Sets the pin 109 (GP6[12]) as input.*/
        GPIODirModeSet(SOC_GPIO_0_REGS, 109, GPIO_DIR_OUTPUT);
    
        while(1)
        {
    		GPIOPinWrite(SOC_GPIO_0_REGS, 109, GPIO_PIN_LOW);
    
    		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--);
    }

    Regards,

    Shankari

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

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

  • Dear Shankari,

    Thanks for your reply, but I want to use my own API's and coding. Please let me if there is any problem in that.

    I was missing PSC configuration earlier. Now I configured it as below:

    int main()

    {

          PINMUX19 =  PINMUX19 | 0x00000008;    //  Configuring it as  GPIO pins

          while(PTSTAT & 0x02)

          {}

           MDCTL | = 0

                       | = (3 << 0)   

                       | = (1 << 31);

          PTCMD | = 0x1;

          while(PTSTAT & 0x02)
           {}

    //  Setting direction of GPIO 

        GPIO_DIR8 = GPIO_DIR8 & (~(1<<8)) ;

          GPIO_DIR8 = GPIO_DIR8 & (~(1<<9)) ; 

    // Setting the value

    GPIO_SET_DATA  =  GPIO_SET_DATA  | ( 1 << 8 );

    GPIO_SET_DATA  =  GPIO_SET_DATA  | ( 1 << 9 );

     }

    Now when I see the value of registers in the CCSv5, I can see the value of PINMUX19 as expected while in case of GPIO and PSC registers like PTCMD and MDCTL, I don't get expected values in CCSV5

    Why it's not showing what is expected, I also checked the address of various registers used, but they are alright.

    Please explain something to resolve this issue.

    Thanks in Advance..

  • Hi,

    Please refer the chapter 9.3 of OMAPL138 TRM  to know about PSC transitions and steps involved.

    The below code some what detailed code, So please take this as reference.

    /*
     * \brief    Function to power on the GPIO module in the power sleep controller.
     *
     * \param    None
     * \return   None
     *
     *  Note: This function causes the program to abort in case it is unable to   *
     *        enable the GPIO module.
     */
    static void gpioPowerOn(void)
    {
        volatile Uint32 pscTimeoutCount = 10240u;
        Uint32          temp            = 0;
    
        /* we will now power on the GPIO module in the PSC.                       *
         * Configure the GPIO Module to Enable state                              */
        psc1Regs->MDCTL[CSL_PSC_GPIO] = ((psc1Regs->MDCTL[CSL_PSC_GPIO]
                                            & 0xFFFFFFE0)
                                         | CSL_PSC_MDSTAT_STATE_ENABLE);
    
        /* Kick start the Enable Command                                          */
        temp = psc1Regs->PTCMD;
        temp = ((temp & CSL_PSC_PTCMD_GO0_MASK)
                | (CSL_PSC_PTCMD_GO0_SET << CSL_PSC_PTCMD_GO0_SHIFT));
    
        psc1Regs->PTCMD |= temp;
    
        /* Wait for the power state transition to occur                           */
        while (((psc1Regs->PTSTAT & (CSL_PSC_PTSTAT_GOSTAT0_IN_TRANSITION)) != 0)
            && (pscTimeoutCount>0))
        {
            pscTimeoutCount--;
        }
    
        /* Check if PSC state transition timed out                                */
        if (0 == pscTimeoutCount)
        {
            printf("GPIO PSC transition to ON state timed out\n");
        }
        else
        {
            printf("Gpio enabled in PSC\n");
        }
    }