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.

AM335x Starter Kit GPIO pins Functionality

Other Parts Discussed in Thread: SYSCONFIG

Hello,

I have a TMDSSK AM335x Starter Kit with the NUCLEUS RTOS running over it. But right now ,Nucleus don't have support for GPIO drivers for starter Kit  but I need GPIO pins to work for my own application.Below are my some queries regarding GPIO..

1)What's the Memory Map Address(Base Address ) of GPIO?(offset address is given to GPIO registers but no base address is given).

2)How to output the USER LED's present on the starter kit i.e.  which register i need to access to output GPIO1?

3) I need an Interrupt to one of GPIO pins to my own ISR function,also need information on this.

       Please provide solutions for the above queries as soon as possible...

Thanks

Kamal Negi

  • Hi,

    Please check Table 2-2. L4_WKUP Peripheral Memory Map in Section 2 - Memory Map from the AM335x TRM (spruh73h): http://www.ti.com/lit/ug/spruh73h/spruh73h.pdf

    The Start and End addresses of each GPIO port can be found there.

    More info on interrupts can be found in section 25.3.3 Interrupt Features.

    Best regards,
    Miroslav

  • Hi Miroslav ,

    Thanks for quick reply..

    I am trying to write a "LED Blink" Program  and getting some exception in debugging..Program is running on Nucleus RTOS but doing BareMetal work for GPIO functionality. Below is my program..

    #define  WriteDWord(reg,data)      ((*((volatile UINT32 *)(reg)))=(UINT32)(data))         //macro to write DATA data to REGISTER reg 

    #define  ReadDWord(reg,data)      ((*((volatile UINT32 *)(reg)))                                      ////macro to  read data from REGISTER reg 

    #define GPIO0_Base_Addr       0x44E07000                                                                 //Base Address of GPIO0  found in the manual

    #define GPIO1_Base_addr       0x4804C000                                                                  //Base Address of GPIO0  found in the manual

    #define GPIO_OE                     0x134                                                                             //Offset of GPIO Output Enable Register

    #define GPIO_SetDataOut       0x194                                                                              //Offset of SET_GPIO_Output_DATA Register

    #define GPIO_ClearDataOut    0x190                                                                              //Offset of CLEAR_GPIO_Output_Data  Register

    static VOID Main_Task_Entry()                                                                      //This is starting of main function

    {

    WriteDWord(GPIO1_Base_addr +GPIO_OE,0x00000000 );                            //Enabling GPIO1 pins as OUTPUT PINs     ///Getting UNHADLED EXCEPTION 

    while(1)                                                                                                          //BLINKING LED's while 1

    {

                         

    WriteDWord(GPIO1_Base_addr +GPIO_SetDataOut,0xFFFFFFFF);                //Writing 1/HIGH to all GPIO1 pins  

    WriteDWord(GPIO1_Base_addr +GPIO_ClearDataOut,0xFFFFFFFF);             //Writing 0/LOW to all GPIO1 pins 

    }

    }

    Getting Unhandle exception    in main in 1st Instruction(Enabling GPIO1 Pins as OUTput Pins)..

    Please Advise..


    Thanks

    Kamal Negi

  • Hi,

    You need to first enable and configure the clocks for the GPIO module you are going to be using, the pinmux the GPIO pin you wish to use and then set it as output.

    Here is an excerpt from the gpioLEDBlink example from the StarterWare package:

        /* Enabling functional clocks for GPIO1 instance. */
        GPIO1ModuleClkConfig();

        /* Selecting GPIO1[23] pin for use. */
        GPIO1Pin23PinMuxSetup();
        
        /* Enabling the GPIO module. */
        GPIOModuleEnable(GPIO_INSTANCE_ADDRESS);

        /* Resetting the GPIO module. */
        GPIOModuleReset(GPIO_INSTANCE_ADDRESS);

        /* Setting the GPIO pin as an output pin. */
        GPIODirModeSet(GPIO_INSTANCE_ADDRESS,
                       GPIO_INSTANCE_PIN_NUMBER,
                       GPIO_DIR_OUTPUT);

    Please download the StarterWare package and explore the gpioLEDBlink example as well as the gpio library. It is written in C and it is easily understandable.

    You can download the StarterWare package from here: http://software-dl.ti.com/dsps/dsps_public_sw/am_bu/starterware/latest/index_FDS.html

    Best regards,
    Miroslav

  • Hi,

    Thanks for reply.. :)

    Now i want to communicate my starter kit to the another controller through SPI Communications, for that i need a GPIO pin for taking an Interrupt from controller. But there is no extra GPIO pin header on the Starter Kit, so i think i need to add an extra pin to the board. Can you confirm me where can i add another GPIO pin for taking  Interrupt, where on the BOARD(name of the pin) i can fix it and that pin is at which GPIO PORT and PIN No.?

    Thanks

  • Hi,

    You can find the AM335x StarterKit board design files here: http://processors.wiki.ti.com/index.php/AM335x_StarterKit_Board_Design_Files

    Take a look at the schematic and see where the most appropriate place to solder a new pin is.

    Best regards,
    Miroslav

  • Hello, 

    I am trying to configure GPIO0[2] pin as an output pin but the module GPIO0 is not getting RESET but when i am configuring GPIO1 module it will get reset and work properly. Below  is the code for GPIO0[2] as an output..

    void GPIO0ModuleClkConfig(void)
    {
    /* Writing to MODULEMODE field of CM_WKUP_GPIO0_CLKCTRL register. */
    HWREG(SOC_CM_WKUP_REGS + CM_WKUP_GPIO0_CLKCTRL) |=
    CM_WKUP_GPIO0_CLKCTRL_MODULEMODE_ENABLE;

    /* Waiting for MODULEMODE field to reflect the written value. */
    while(CM_WKUP_GPIO0_CLKCTRL_MODULEMODE_ENABLE !=
    (HWREG(SOC_CM_WKUP_REGS + CM_WKUP_GPIO0_CLKCTRL) &
    CM_WKUP_GPIO0_CLKCTRL_MODULEMODE));

    /*
    ** Writing to OPTFCLKEN_GPIO0_GDBCLK field of CM_WKUP_GPIO0_CLKCTRL
    ** register.
    */
    HWREG(SOC_CM_WKUP_REGS + CM_WKUP_GPIO0_CLKCTRL) |=
    CM_WKUP_GPIO0_CLKCTRL_OPTFCLKEN_GPIO0_GDBCLK;

    /* Waiting for OPTFCLKEN_GPIO0_GDBCLK field to reflect the written value. */
    while(CM_WKUP_GPIO0_CLKCTRL_OPTFCLKEN_GPIO0_GDBCLK !=
    (HWREG(SOC_CM_WKUP_REGS + CM_WKUP_GPIO0_CLKCTRL) &
    CM_WKUP_GPIO0_CLKCTRL_OPTFCLKEN_GPIO0_GDBCLK));

    /* Writing to IDLEST field in CM_WKUP_GPIO0_CLKCTRL register. */
    while((CM_WKUP_GPIO0_CLKCTRL_IDLEST_FUNC <<
    CM_WKUP_GPIO0_CLKCTRL_IDLEST_SHIFT) !=
    (HWREG(SOC_CM_WKUP_REGS + CM_WKUP_GPIO0_CLKCTRL) &
    CM_WKUP_GPIO0_CLKCTRL_IDLEST));

    /*
    ** Waiting for CLKACTIVITY_GPIO0_GDBCLK field in CM_WKUP_GPIO0_CLKCTRL
    ** register to attain desired value.
    */
    while(CM_WKUP_CLKSTCTRL_CLKACTIVITY_GPIO0_GDBCLK !=
    (HWREG(SOC_CM_WKUP_REGS + CM_WKUP_CLKSTCTRL) &
    CM_WKUP_CLKSTCTRL_CLKACTIVITY_GPIO0_GDBCLK));
    }

    void GPIO0Pin2PinMuxSetup(void)
    {
    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI0_SCLK) =
    ((CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_RXACTIVE |
    CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUDEN |
    CONTROL_CONF_MUXMODE(7)) &
    (~CONTROL_CONF_SPI0_SCLK_CONF_SPI0_SCLK_PUTYPESEL));
    }

    void GPIOModuleEnable(unsigned int baseAdd)
    {
    /* Clearing the DISABLEMODULE bit in the Control(CTRL) register. */
    HWREG(baseAdd + GPIO_CTRL) &= ~(GPIO_CTRL_DISABLEMODULE);
    }

    void GPIOModuleReset(unsigned int baseAdd)
    {
    /*
    ** Setting the SOFTRESET bit in System Configuration register.
    ** Doing so would reset the GPIO module.
    */
    HWREG(baseAdd + GPIO_SYSCONFIG) |= (GPIO_SYSCONFIG_SOFTRESET);

    /* Waiting until the GPIO Module is reset.*/
    while(!(HWREG(baseAdd + GPIO_SYSSTATUS) & GPIO_SYSSTATUS_RESETDONE));
    }

    #define GPIO_0_INSTANCE_ADDRESS               0x44E07000

    void  main()

    {

    GPIO0ModuleClkConfig();

    GPIO0Pin2PinMuxSetup();


    GPIOModuleEnable(GPIO_0_INSTANCE_ADDRESS);

    GPIOModuleReset(GPIO_0_INSTANCE_ADDRESS);

    .......

    }

     

    In the GPIOModuleReset()  function its not getting out of it, as GPIO0 module is not getting reset.

    Please help with the problem.

    Thanks

  • Hello 

    Can you please help me out with the above written problem( initialization of GPIO0 Module  )?????

    Thanks

  • Hi,

    This is really strange. I can't figure out what might be causing the reset to hang. Here is an excerpt from the AM335x TRM regarding the GPIO module reset:

    25.3.2.4 Reset
    The OCP hardware Reset signal has a global reset action on the GPIO. All configuration registers, all DFFs clocked with the Interface clock or Debouncing clock and all internal state machines are reset when the OCP hardware Reset is active (low level). The RESETDONE bit in the system status register (GPIO_SYSSTATUS) monitors the internal reset status: it is set when the Reset is completed on both OCP and Debouncing clock domains. The software Reset (SOFTRESET bit in the system configuration register) has the same effect as the OCP hardware Reset signal, and the RESETDONE bit in GPIO_SYSSTATUS is updated in the same condition.

    It seems like you are doing everything right... You can try and also ask in the StarterWare forum: http://e2e.ti.com/support/embedded/starterware/f/790.aspx

    Best regards,
    Miroslav

  • Hello,

    Can this thing is possible that another module is conflicting with the GPIO0 module and because of that its not getting reset or something??

    or i am missing any configuration to initialize or any other dependent module for GPIO0 is need to be initialize??

    Thanks

  • Hi,

    I am also trying a GPIO program to set a Pin as output and set any value to the pin.

    I am able to do it in the sysfs style, however I require it to be done using the GPIO registers. I am unable to get the required header files for the same.

    Request you to give some inputs on that.

  • Hi Harsha,

    Please take a look at the GPIO Driver Guide.

    Best regards,
    Miroslav