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.

Why sample PSP code not initializing PINMUX for GPIO?

Other Parts Discussed in Thread: OMAPL138, SYSCONFIG

Hello there,

I am trying to understand the sample code for OMAPL138 GPIO that came with PSP 1.30.00.06. As far as I can see, it is not initializing the PINMUX for enabling the GPIO pins that are being used. However, similar code that is written for OMAPL137 makes a call 'configureGPIO()' inside gpioSample_io.c that sets the appropriate PINMUX.

Am I missing something?

Also, why are the GPIO banks addressed from '0' while the pins are addressed from '1' in the PSP driver? I find this a bit confusing, and could not find any documentation. In fact, I had to dig through the driver source code to figure out this addressing scheme.

Thanks,

Joe

BIOS: 5.41.10.36

CGT: 6.1.19

PSP: 1.30.00.06 

  • Adding to my previous post:

    I tried calling 'configureGpio()' from gpioSample_io.c before the GPIO pins are configured as input pins. However, while stepping through the code and looking at the registers, it appears that neither the KICK0/KICK1 nor the PINMUX registers are being updated. Even though the GPIO registers are updated correctly, the pins are effectively inactive since the PINMUX is not setup as required.

    Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\examples\evmOMAPL138\gpio\src\gpioSample_io.c

    Void gpioExampleTask(Void)
    {
        Gpio_PinCmdArg  pinCmdArg;
        Gpio_IntrCmdArg intrCmdArg;
       
        /* Added by JC for GPIO initialization */
        configureGpio();   /* doesnt seem to be working / sysconfig registers are NOT updated */

        /* Configure GPIO(GPIO4_0_PIN) as an input                                */
        pinCmdArg.pin   = GPIO4_0_PIN;
        pinCmdArg.value = Gpio_Direction_Input;
        Gpio_setPinDir(gpio0, &pinCmdArg);    /* Seems to be working / GPIO registers are updated */
       

        /* Enable GPIO Bank interrupt for bank GPIO_BANK_4                        */
        Gpio_bankInterruptEnable(gpio0, GPIO_BANK_4);

        /* Configure GPIO(GPIO4_0_PIN) to generate interrupt on rising edge       */
        Gpio_setRisingEdgeTrigger(gpio0, GPIO4_0_PIN);

        /* Configure GPIO(GPIO4_0_PIN) to generate interrupt on falling edge      */
        Gpio_setFallingEdgeTrigger(gpio0, GPIO4_0_PIN);

        /* Set the interrupt handler for GPIO4_0_PIN. However we cannot register
         * interrupts for individual pins in OMAPL138, therefore  register interrupt
         * for the associated bank(BANK4) as a whole
         */
        intrCmdArg.value = GPIO_BANK_4;
        intrCmdArg.bankOrPin = Gpio_BankOrPin_isBank;
        intrCmdArg.isrHandler = (Gpio_Isr)gpioInputIsr;
        Gpio_regIntHandler(gpio0, &intrCmdArg);

        /*At GPIO4_0_PIN bit value of 1 at the input reg represents that the card
        is removed and 0 means it is inserted*/

        LOG_printf(&trace, "Waiting for GPIO Interrupt\n");
        while( 0 == flag)
        {
            TSK_sleep(2000);
            LOG_printf(&trace, "Waiting for user to Insert MMCSD card\n"); 

    /* Not workeeeee. The GPIO never sees the interrupt, ISR not called and flag never set to 1.

    This results in an infinite loop no matter if SD card is inserted or not */
        }

        LOG_printf(&trace, "GPIO Interrupt occured !\n");

        /* close the GPIO driver handle */
        Gpio_close(gpio0);

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

    What could be wrong?

    Thanks for any help,

    Joe

  • Hi Joseph,

    One quick suggestion: Please try executing the sample application binaries that comes readily with the PSP release.. just to confirm all is good with the board/related stuff!..

    Output Console:

    Waiting for GPIO Interrupt

    Waiting for user to Insert MMCSD card

    Waiting for user to Insert MMCSD card

    Waiting for user to Insert MMCSD card

    GPIO Interrupt occured !

    End of GPIO sample application!

     

    If you refer section 2.5 of the GPIO User guide Table 1 lists all the GPIO pins (1-144) divided into 9 banks (0-8). I understand few things are missing in the Userguide, I request you to look into the following thread for more details regarding them: http://e2e.ti.com/support/embedded/f/355/p/122176/436096.aspx#436096

    Hope this helps..

     

    Thanks & regards,

    Raghavendra 

  • Hi Raghavendra,

    Thank you for your reply.

    [1] I did load the release version of the binary file (date of creation: 9/29/2009) that came with the PSP 1.30.00.06 package (attached is the original binary. Remove txt extension). But it did not work. The following is a copy of the log file

    "30,883",0,Waiting for GPIO Interrupt,trace
    "600,046,595",1,Waiting for user to Insert MMCSD card,trace
    "1,200,071,195",2,Waiting for user to Insert MMCSD card,trace
    "1,800,096,195",3,Waiting for user to Insert MMCSD card,trace
    "2,400,121,197",4,Waiting for user to Insert MMCSD card,trace
    "3,000,146,195",5,Waiting for user to Insert MMCSD card,trace
    "3,600,171,197",6,Waiting for user to Insert MMCSD card,trace
    "4,200,196,200",7,Waiting for user to Insert MMCSD card,trace
    "4,800,221,195",8,Waiting for user to Insert MMCSD card,trace
    "5,400,246,197",9,Waiting for user to Insert MMCSD card,trace
    "6,000,271,197",10,Waiting for user to Insert MMCSD card,trace
    "6,600,296,199",11,Waiting for user to Insert MMCSD card,trace
    "7,200,321,195",12,Waiting for user to Insert MMCSD card,trace
    "7,800,346,195",13,Waiting for user to Insert MMCSD card,trace
    "8,400,371,199",14,Waiting for user to Insert MMCSD card,trace
    "9,000,396,195",15,Waiting for user to Insert MMCSD card,trace
    "9,600,421,195",16,Waiting for user to Insert MMCSD card,trace
    "10,200,446,197",17,Waiting for user to Insert MMCSD card,trace
    "10,800,471,194",18,Waiting for user to Insert MMCSD card,trace
    "11,400,496,200",19,Waiting for user to Insert MMCSD card,trace
    "12,000,521,195",20,Waiting for user to Insert MMCSD card,trace
    "12,600,546,197",21,Waiting for user to Insert MMCSD card,trace
    "13,200,571,197",22,Waiting for user to Insert MMCSD card,trace
    "13,800,596,194",23,Waiting for user to Insert MMCSD card,trace
    "14,400,621,197",24,Waiting for user to Insert MMCSD card,trace
    "15,000,646,195",25,Waiting for user to Insert MMCSD card,trace
    "15,600,671,194",26,Waiting for user to Insert MMCSD card,trace
    "16,200,696,197",27,Waiting for user to Insert MMCSD card,trace
    "16,800,721,195",28,Waiting for user to Insert MMCSD card,trace
    "17,400,746,196",29,Waiting for user to Insert MMCSD card,trace
    "18,000,771,194",30,Waiting for user to Insert MMCSD card,trace
    "18,600,796,195",31,Waiting for user to Insert MMCSD card,trace
    "19,200,821,195",32,Waiting for user to Insert MMCSD card,trace
    "19,800,846,199",33,Waiting for user to Insert MMCSD card,trace
    "20,400,871,194",34,Waiting for user to Insert MMCSD card,trace
    "21,000,896,194",35,Waiting for user to Insert MMCSD card,trace
    "21,600,921,195",36,Waiting for user to Insert MMCSD card,trace

    .......

    The SD card was inserted and removed multiple times.

    [2] Thanks for that forum thread link. I dont know how I missed that while I was searching for information.

    [3] I was able to successfully make the same GPIO code work with SYS/BIOS 6.21.03.21 and PSP 2.10.01. I was also able to write my own code and make other GPIO banks/pins work. But I am looking to use DSP/BIOS and PSP 1.30.00.06 since I want to port the code to OMAPL137 later.

    Thanks

    Joe
    8130.gpioSample.out.txt

  • Hi Joe,

    I did try executing the binary you shared on my EVM OMAPL138 REV 4 board, and it is working fine without any problems. I am getting the GPIO interrupt, and the sample application is completed successfully.. Not very sure why you are not getting a interrupt. Are you using a custom board?. or can you please check with the settings?. Also, can you please share the GEL file you are using?.

    Thanks & regards,

    Raghavendra

     

  • Hi Raghavendra,

    Thanks for the quick reply.

    [a] I am using OMAPL138 experimenter (the older board without the builtin LCD, not the latest one)

    [b] Similar sample code that came with PSP 2.10.01 worked perfectly

    [c] I am using a target configuration file defined by me to connect to the board. The xml file is given below. Am I doing this incorreclty?

    ===================OMAPL138Experimenter.ccxml================

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

    <configurations XML_version="1.2" id="configurations_0">

     

    <configuration XML_version="1.2" id="Texas Instruments XDS100v2 USB Emulator_0">

    <instance XML_version="1.2" desc="Texas Instruments XDS100v2 USB Emulator_0" href="connections\TIXDS100v2_Connection.xml" id="Texas Instruments XDS100v2 USB Emulator_0" xml="TIXDS100v2_Connection.xml" xmlpath="connections"/>

    <connection XML_version="1.2" id="Texas Instruments XDS100v2 USB Emulator_0">

    <instance XML_version="1.2" href="drivers\tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>

    <instance XML_version="1.2" href="drivers\tixds100v2c674x.xml" id="drivers" xml="tixds100v2c674x.xml" xmlpath="drivers"/>

    <instance XML_version="1.2" href="drivers\tixds100v2arm9.xml" id="drivers" xml="tixds100v2arm9.xml" xmlpath="drivers"/>

    <instance XML_version="1.2" href="drivers\tixds100v2etb11.xml" id="drivers" xml="tixds100v2etb11.xml" xmlpath="drivers"/>

    <platform XML_version="1.2" id="platform_0">

    <instance XML_version="1.2" desc="OMAPL138 - ARM9 and C674x Floating point DSP_0" href="Devices\OMAPL138.xml" id="OMAPL138 - ARM9 and C674x Floating point DSP_0" xml="OMAPL138.xml" xmlpath="Devices"/>

    </platform>

    </connection>

    </configuration>

    </configurations>

    ===========================================================

    Thanks

    Joe

  • Hi Raghavendra,

    There is a bug in the OMAPL138 platform init file that comes with the PSP 1.30.00.06 driver.

    File: C:\Program Files\Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\platforms\evmOMAPL138\src\gpio_evmInit.c

    void configureGpio(void)
    {
        /* Unlock BOOTCFG module before pinmux configuration                      */
        KICK0 = KICK0_ENABLE_KEY;
        KICK1 = KICK0_ENABLE_KEY;

        /* enable the pinmux registers for GPIO                                   */
        /* enable GPIO4_2 and GPIO4_1 for CD and INS support                      */
        sysCfgRegs->PINMUX10 &= PINMUX10_GPIO4_MASK;
        sysCfgRegs->PINMUX10 |= PINMUX10_GPIO4_ENABLE;                       
      
        return;
    }

    The highlighted should be: KICK1 = KICK1_ENABLE_KEY;

    Also, inside the sample file: Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\examples\evmOMAPL138\gpio\src\gpioSample_io.c, there should be a call to "configureGpio()" to setup PINMUX. Not having this function call will result in a non working GPIO.

    Best,

    Joe

  • Hi Joseph,

     

    Thanks for highlighting us on this. Yes, it is a bug in the gpio_evmInit.c file. And also in the application, the configureGpio() function is never called. 

    Joseph CJ said:

    void configureGpio(void)
    {
        /* Unlock BOOTCFG module before pinmux configuration                      */
        KICK0 = KICK0_ENABLE_KEY;
        KICK1 = KICK0_ENABLE_KEY;

        /* enable the pinmux registers for GPIO                                   */
        /* enable GPIO4_2 and GPIO4_1 for CD and INS support                      */
        sysCfgRegs->PINMUX10 &= PINMUX10_GPIO4_MASK;                  
      
        return;
    }

    The highlighted should be: KICK1 = KICK1_ENABLE_KEY;

     

    So, after making the above change(only change), you are able to execute your sample application right?.  Or have you done any other modification?. Upon your confirmation, we will go ahead and raise an IR to keep in track of this issue. This will be fixed in the future release.

     

    Thanks & regards,

    Raghavendra 

  • Hi Raghavendra,

    Yes, with those changes, I was able to run my code successfully. Now I am moving to my next hurdle (hopefully an easy one) - learn the SPI driver :)

    Best,

    Joe

  • I forgot to mention one more issue that I ran into in my last message - when I tried to rebuild the platform library, it gave me an error due to missing "mcaspDit_evmInit.c" file. I removed the entry for this file from the project and everything worked. To reiterate, I did the following

    - Fixed the bug (KICK1 = KICK1_ENABLE_KEY) in "Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\platforms\evmOMAPL138\src\gpio_evmInit.c"

    - Removed "mcaspDit_evmInit.c" from "Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\platforms\evmOMAPL138\build\ccs4\.project"

    - Rebuild the library and generated new "Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\platforms\evmOMAPL138\lib\Debug\ti.pspiom.platforms.evmOMAPL138.evmInit.a674"

    - Added the function call configureGpio() in "Texas Instruments\pspdrivers_01_30_00_06\packages\ti\pspiom\examples\evmOMAPL138\gpio\src\gpioSample_io.c"

    - Rebuilt the GPIO sample project and successfully ran the program

    I hope that helps.

    Best,

    Joe

  • Thank you Joseph.. Will go ahead and raise an IR.

     

    Regards,

    Raghavendra