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.

How to find GPIO number to enable from user space

Part Number: PROCESSOR-SDK-AM437X
Other Parts Discussed in Thread: AM4378, SN75HVD12

Tool/software: Linux

Hi friends,

I am working on a custom board based on AM4378. I am using SDK ti-processor-sdk-linux-am437x-evm-02.00.00.00. UART5 is using for RS485 communication in half duplex mode  and D24 pin  for  rts and dts pins.. 

 I am trying to enable /disable the gpio0-19(D24) from user space, with the following commands

 

echo 19 > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio19/direction

echo "in" > /sys/class/gpio/gpio19/direction

echo 1 > /sys/class/gpio/gpio19/value

echo 0 > /sys/class/gpio/gpio19/value.

I could see the GPIO19 toggling (from terminal), but the voltage levels at pin D24 pin is still low only even if i set high. 

I have used the formula( (32*M+N)) to calculate gpio number for gpio0-19, so i tried with echo 19 > /sys/class/gpio/export. Is that formula correct ? if so why i amunable to see voltage changes at D24 pin.? I have changed the dts files also 

....

....

....

gpio0_pins_default: gpio0_pins_default {

                   pinctrl-single,pins = <

                             0x270 (PIN_OUTPUT_PULLUP | MUX_MODE7) /*(D24) xdma_event_intr0.gpio0[19]*/

                   >;

          };

          gpio0_pins_sleep: gpio0_pins_sleep {

                pinctrl-single,pins = <

                        0x270 (PIN_OUTPUT_PULLUP | MUX_MODE7) /*(D24) xdma_event_intr0.gpio0[19]*/

                >;

        };

 

.......

........

........

&gpio0 {

          status = "okay";

          pinctrl-names = "default","sleep";

          pinctrl-0 = <&gpio0_pins_default>;

          pincntrl-1 = <&gpio0_pins_sleep>;

          gpios = <&gpio0 19 GPIO_ACTIVE_HIGH>;

 

};

....

....

 

Thanks in advance.

  • Hi Bhagya,

    When a pin (D24 for example) is configured for MUX_MODE7 (UART5) it is not correct to try to use it as GPIO.

    BR
    Tsvetolin Shulev
  • Hi Tsvetolin Shulev,
    Thank you so much for your quick reply.
    D24 pin is used as gpio only to send 1 or 0 to the converter SN75HVD12(rs485) where RTS and CTS pins are connected together to operate it in half duplex mode. if we send 1 from D24 , then its acts as transmitter and 0 as receiver. so what i want here is how can i set 1 or 0 for D24 which i have configured as GPIO. in mode7 its name is gpio0-19. I would like to know its equivalent gpio number so that i can use this commands from userspace.
    echo XX > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpioXX/direction
    echo "in" > /sys/class/gpio/gpioXX/direction
    echo 1 > /sys/class/gpio/gpioXX/value
    echo 0 > /sys/class/gpio/gpioXX/value.


    what is XX value for gpio0-19 signal ???
  • Hello,

    If you are setting the pin as input you wont see a transition you need to supply voltage levels.
    Firstly set the GPIO pin as output and when you set value 0/1 scope the pins and you should see it.

    echo 19 > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/19/direction
    echo 1 > /sys/class/gpio/19/value
    After doing this scope value
    echo 0 > /sys/class/gpio/19value
    After doing this scope value

    Cheers,
    --Prabhakar Lad
  • Hi Prabhakar,
    Thanks for you time. I want to know gpio number for GPIO0_19 pin for am437x board. I have seen the formula to calculate the gpio number for (GPIOm_n = 32*m+n) for am437x. Thats y i have used "19" for GPIO0_19. i set it in output and send 1.But i could not see the voltage changes on the board. Is that formula correct? or do i need to change anything on pinmux and device tree files in am437x-gp-evm.dts file ??
  • Hello,

    Yes the gpio numbering is correct GP0[19] if what you want. even from the formulae you can get (GPIOm_n = 32*m+n) ((GPIO0_19 = 32*0+19) = 19). Yes you need to configure the pinmux to behave the pin as GPIO.

    Cheers,
    --Prabhakar Lad