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.

Toggling a GPIO pin in OALI2C?



Hi,

I'd like to toggle a GPIO pin from  OALI2C module; however, my code hangs at bootloader time after I added GPIOOpen() call in either OALI2CInit() or I2COpen() in source file OALI2C.c.  Would you please tell me what I am doing wrong?

Thanks,

Luan

  • check if GPIOInit() is called by bootloader before GPIOOpen() is called from any other module. Also, GPIO clocks/pinmuxes must be enabled before you toggle the GPIO. Do you know where the bootloader is getting stuck?

    -Madhvi

  • Hi Madhvi,

    Thanks for a quick response.

    In main.c of the bootloader, I moved GPIOInit() from after to right before

    OALI2CInit(OMAP_DEVICE_I2C1);
    OALI2CInit(OMAP_DEVICE_I2C2);
    OALI2CInit(OMAP_DEVICE_I2C3);

    I don't know where exactly the bootloader is getting stuck.  All I did was adding the code below in OALI2CInit() and it hangs everytime.

    if(!hGPIO)
        hGPIO = GPIOOpen();

    If I remove it, it works fine so I think it must be stuck in GPIOOpen().  I have not done any toggling yet.

    I appeciate your advice,

    Luan

  • Luan

    There maybe someother code in your BSP which may be preventing you from doing this. I just added similar code to 01.02.00 BSP and I dont see the issue. The SD bootloader comes up fine.

    -Madhvi

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

    main.c

    // Enable device clocks used by the bootloader
        EnableDeviceClocks(OMAP_DEVICE_GPIO1,TRUE);
        EnableDeviceClocks(OMAP_DEVICE_GPIO2,TRUE);
        EnableDeviceClocks(OMAP_DEVICE_GPIO3,TRUE);
        EnableDeviceClocks(OMAP_DEVICE_GPIO4,TRUE);
        EnableDeviceClocks(OMAP_DEVICE_GPIO5,TRUE);
        EnableDeviceClocks(OMAP_DEVICE_GPIO6,TRUE);

       
        GPIOInit();
       
        // configure i2c devices
        OALI2CInit(OMAP_DEVICE_I2C1);
        OALI2CInit(OMAP_DEVICE_I2C2);
        OALI2CInit(OMAP_DEVICE_I2C3);

        // Note that T2 accesses must occur after I2C initialization
        hTwl = TWLOpen();
        hGPIO = GPIOOpen();

     

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

     

    OalI2CInit()

    _rgI2CDevice[idI2C].fifoSize = INREG32(&pI2CRegs->BUFSTAT);
        _rgI2CDevice[idI2C].fifoSize &= I2C_BUFSTAT_FIFODEPTH_MASK;
        _rgI2CDevice[idI2C].fifoSize >>= I2C_BUFSTAT_FIFODEPTH_SHIFT;
        _rgI2CDevice[idI2C].fifoSize = s_fifoLookup[_rgI2CDevice[idI2C].fifoSize];

        if (!hGPIO) hGPIO = GPIOOpen();

     OALLog(
            L"hGPIO 0x%x \r\n",
            hGPIO       
            );


        // release clocks
        EnableDeviceClocks(devId, FALSE);

        return TRUE;
    }

     

    ==========

    bootup log

     

    Texas Instruments Windows CE SD X-Loader for EVM 3730
    Built May  4 2011 at 18:48:49
    Version BSP_WINCE_ARM_A8 1.02.00.02
    open ebootsd.nb0 file
    Init HW: controller RST
    SDCARD: reqested speed 1000000, actual speed 1000000
    SDCARD: reqested speed 25000000, actual speed 19200000
    jumping to ebootsd image

    Microsoft Windows CE Bootloader Common Library Version 1.4 Built Sep  6 2011 18:16:33

    Texas Instruments Windows CE EBOOT for OMAP35xx/37xx, Built Sep 13 2011 at 18:34:33
    EBOOT Version 0.0, BSP BSP_WINCE_ARM_A8 1.02.00.02
    hGPIO 0x87e80d2c
    hGPIO 0x87e80d2c
    hGPIO 0x87e80d2c


    TI OMAP3730 Version 0x00000012 (ES1.2)
    TPS659XX Version 0x30 (ES1.3)
    System ready!
    Preparing for download...
    INFO: Predownload....
    Checking bootloader blocks are marked as reserved (Num = 14)

    INFO: Boot configuration found

    >>> Forcing cold boot (non-persistent registry and other data will be wiped) <<<
    Hit space to enter configuration menu 5...
    Hit space to enter configuration menu 4...
    Hit space to enter configuration menu 3...

  • Sorry, Madhvi, I was confused.  I retested and the above code works as you said.  However, it does not work if I have it like this in OALI2CInit()

    if(!hGPIO)
    {
        hGPIO = GPIOOpen();
        if(hGPIO)
            GPIOSetMode(hGPIO, 94,GPIO_DIR_OUTPUT);    // also not working for GPIO_138
    }

    In bsp_padcfg.h, I have GPIO_94 and GPIO_138 configured as below,

    PAD_ENTRY(CAM_HS, INPUT_ENABLED | PULL_RESISTOR_ENABLED | PULLUP_RESISTOR | MUXMODE(4))    /* GPIO_94 */    \

    PAD_ENTRY(MMC2_DAT6, MUXMODE(4))    /* GPIO_138 */    \

    Would you please try adding GPIOSetMode() as above to see if it is working for you?

    Thanks very much for your help,

    Luan

  • Luan,

    Are you trying to set this GPIO line to be output?

    In GPIOSetMode() function call, it is OUTPUT, however the Pin mux configuration has "INPUT_ENABLED".

    Thanks,

    Tao

  • Luan

    Where have you added the pinmux config in bsp_padcfg.h? in which structure? I added it in GPIO_PADS_37XX and I can do GPIOsetMode() for GPIO 138 in i2c without any issues. If using OMAP35xx, then you should add the pinmux config in GPIO_PADS.

    Here is what I suggest - first add/test this GPIO code to BSP 01.02.00 and see if it works. If it does, then that will help you debug your BSP.

    -Madhvi