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.

PROCESSOR-SDK-AM335X: GPIO example

Part Number: PROCESSOR-SDK-AM335X

Hi,

Can you provide me any GPIO sample code? Actually I used GPIO skAM335x LED Blink code from RTOS SDK but it is very difficult to understand for me. 

I created my own project and included all header files and same contents I copied from main_LED_blink.c to my project main.c,  which are used in driver code then also my project is not working.

Regards

Gaurav

  • Hi,

    Which SDK are you using? Linux, Linux-RT, TI-RTOS, other? Which version?
  • Hi,

    I am using TI-RTOS SDK for Windows.

    Regards

    Gaurav

  • Gaurav,

    GPIO_LedBlink is the only sample code we have regarding RTOS GPIO:

    software-dl.ti.com/.../index_device_drv.html

    You might also check how GPIO code is included and used in the RTOS Template Application Workshop:

    software-dl.ti.com/.../index_examples_demos.html

    Regards,
    Pavel
  • Part Number: PROCESSOR-SDK-AM335X

    Tool/software: TI-RTOS

    Hi,

    I added two lines for making a LED 2 high  in GPIO LED_Blink skAM3358 driver code but LED 2 is not glowing.  I am using TI-RTOS SDK.

    Lines which I wrote for LED 2 

    *(volatile unsigned int *)0x4804C134 = 0<<6;
    *(volatile unsigned int *)0x4804C13C = 1<<6;

    Please suggest me any solution.

  • Part Number: PROCESSOR-SDK-AM335X

    Hi,

    I want to write a LED Blink code from a scratch. What do I need for this? 

    Regards

    Gaurav

  • Gaurav Aggarwal1 said:

    I added two lines for making a LED 2 high  in GPIO LED_Blink skAM3358 driver code but LED 2 is not glowing.  I am using TI-RTOS SDK.

    Lines which I wrote for LED 2 

    *(volatile unsigned int *)0x4804C134 = 0<<6;
    *(volatile unsigned int *)0x4804C13C = 1<<6;

    Please suggest me any solution.

    Which file exactly you are modifying?

    I would suggest you instead of direct GPIO1 registers write, to use functions as GPIO_write() or GPIO_toggle(). Check below two files for details:

    pdk_am335x/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c

    pdk_am335x/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    Regards,
    Pavel

  • Gaurav Aggarwal1 said:
    I want to write a LED Blink code from a scratch. What do I need for this? 

    The RTOS Template Application is intended for customers to use as a starting point during software development using Processor SDK RTOS software. The Template Application can be quickly brought up by importing the included Code Composer Studio (CCS) project into the CCS development environment. The application currently includes the typical low level drivers such as UART, GPIO, and I2C, the OSAL layer, and Board Library.

    Please check section 9.1

    Check also below e2e pointers:

    Regards,
    Pavel

  • Part Number: PROCESSOR-SDK-AM335X

    Hi,

    I am using skAM335x board and Processor SDK RTOS. I import GPIO_Led Blink skAM335x_Test Example project in CCS. In this project LED D1 is glowing and I want to glow LED D2. Please tell where do I need to change the example project.

    Regards

    Gaurav

  • Gaurav Aggarwal1 said:
    I am using skAM335x board and Processor SDK RTOS. I import GPIO_Led Blink skAM335x_Test Example project in CCS. In this project LED D1 is glowing and I want to glow LED D2. Please tell where do I need to change the example project.

    Gaurav,

    Do you mean that LED D1 (GPIO_LED4, pin U8 gpmc_ad4.gpio1_4) is glowing and you need to glow LED D2 (GPIO_LED3, pin V8 gpmc_ad5.gpio1_5)?

    The source code that is handling skAM35x led_blink test is below. You need to modify this code and adjust per your custom use case.

    pdk_am335x/packages/ti/drv/gpio/test/led_blink/src/main_led_blink.c

    pdk_am335x/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    Regards,
    Pavel

  • Yes I  mean that LED D1 (GPIO_LED4, pin U8 gpmc_ad4.gpio1_4) is glowing and you need to glow LED D2 (GPIO_LED3, pin V8 gpmc_ad5.gpio1_5)

    I changed macro #define GPIO_USER0_LED_PIN_NUM    (0x04) to #define GPIO_USER0_LED_PIN_NUM    (0x05)

    in pdk_am335x/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c, but it is not working.

    Is somwhere also I have to change? Please tell me specific.

    Regards

    Gaurav

  • Hi Gaurav,

    I tested on my AM335x StarterKit board and I am able to glow LED D2 (instead D1) with below code update:

    pdk_am335x_1_0_14/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    -  #define GPIO_USER0_LED_PIN_NUM    (0x04)  //gpio1_4
    + #define GPIO_USER0_LED_PIN_NUM    (0x05) //gpio1_5
    #define GPIO_USER0_LED_PORT_NUM   (0x01) //gpio1

    pdk_am335x_1_0_14/packages/ti/board/src/skAM335x/include/board_cfg.h

    - #define GPIO_LED_PIN_NUM             (0x04U)

    + #define GPIO_LED_PIN_NUM             (0x05U)

    Regards,
    Pavel

  • Hi,

    Yes LED D2 is blinking.

    Please check for LED D3 and D4 those are not blinking by making changes given below.

    pdk_am335x_1_0_14/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    -  #define GPIO_USER0_LED_PIN_NUM    (0x06)  //gpio1_6
    + #define GPIO_USER0_LED_PIN_NUM    (0x07) //gpio1_7

    pdk_am335x_1_0_14/packages/ti/board/src/skAM335x/include/board_cfg.h

    - #define GPIO_LED_PIN_NUM             (0x06U)

    + #define GPIO_LED_PIN_NUM             (0x07U)

    Regards

    Gaurav

  • Gaurav,

    I made LED D4 (gpio1_6) to blink on my AM335x StarterKit, by making below changes:

    pdk_am335x_1_0_14/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    -  #define GPIO_USER0_LED_PIN_NUM    (0x04)  //gpio1_4
    + #define GPIO_USER0_LED_PIN_NUM    (0x06) //gpio1_6
    #define GPIO_USER0_LED_PORT_NUM   (0x01) //gpio1

    pdk_am335x_1_0_14/packages/ti/board/src/skAM335x/include/board_cfg.h

    - #define GPIO_LED_PIN_NUM             (0x04U)

    + #define GPIO_LED_PIN_NUM             (0x06U)

    Regards,
    Pavel

  • Gaurav,

    I made LED D3 (gpio1_7) to blink on my AM335x StarterKit, by making below changes:

    pdk_am335x_1_0_14/packages/ti/drv/gpio/test/led_blink/src/am335x/GPIO_skAM335x_board.c

    -  #define GPIO_USER0_LED_PIN_NUM    (0x04)  //gpio1_4
    + #define GPIO_USER0_LED_PIN_NUM    (0x07) //gpio1_7
    #define GPIO_USER0_LED_PORT_NUM   (0x01) //gpio1

    pdk_am335x_1_0_14/packages/ti/board/src/skAM335x/include/board_cfg.h

    - #define GPIO_LED_PIN_NUM             (0x04U)

    + #define GPIO_LED_PIN_NUM             (0x07U)

    This code is working fine on my side, I can see LED D3 blinking.

    Regards,
    Pavel

  • I also did same changes but LED D3 and D4 are not blinking.

    Another problem is that sometimes when I changed value for blinking LED D2 and after that I changed back to LED D1 then LED D1 is blinking only one time.

    Yeterday LED D2 was blinking but today LED D2 is blinking only one time in the same program.

    Regards

    Gaurav

  • Gaurav,

    This modification of the code is working fine and stable on my AM335x StarterKit. Sorry, I am not sure how to help you further on this. The only thing I can think of is to make a fresh start (everything from beginning) or try with other AM335x StarterKit board.

    Regards,
    Pavel

  • Part Number: PROCESSOR-SDK-AM335X

    Hi,

    I want to know where is the definition of GPIO_write((USER_LED1), GPIO_PIN_VAL_HIGH) function and how you are linking to main_led_blink.c file.

    Regards

    Gaurav

  • Gaurav Aggarwal1 said:
    I want to know where is the definition of GPIO_write((USER_LED1), GPIO_PIN_VAL_HIGH) function and how you are linking to main_led_blink.c file.

    The definition of GPIO_write() function is in below file:

    pdk_am335x_1_0_14/packages/ti/drv/gpio/src/GPIO_drv.c

    The declaration of this GPIO_write() function is in below header file:

    pdk_am335x_1_0_14/packages/ti/drv/gpio/GPIO.h

    This GPIO.h header file is included in main_led_blink.c, thus main_led_blink.c is linking to GPIO_write()

    /* TI-RTOS Header files */
    #include <ti/drv/gpio/GPIO.h>

    Regards,
    Pavel