How to set PWM IO initial state to high level?

Hi

We are configuring the SODIMM Pin 228 (GPIO13/PWM2) on a customer board based on the Jetson Orin NX to PWM mode, and the PWM signal can be output normally.
However, we want to set the initial state of this PWM signal to a high level but have not been successful.

We tried setting the “Req Initial State” in the Pinmap config to “Drive 1,” but it was also unsuccessful.

Could you please advise how to set the initial state of this pin to a high level in PWM mode?

3

Best Regards!

*** Please note that this reply is generated by LLM automatically ***

To set the initial state of the PWM signal to a high level on the Jetson Orin NX, you need to configure the pinmux settings and the PWM controller. Here’s a step-by-step guide to help you achieve this:

  1. Pinmux Configuration: As you’ve already done, set the Req Initial State in the Pinmap config to Drive 1. This will configure the pin to output a high level when the PWM signal is not active.

  2. PWM Controller Configuration: The PWM controller on the Jetson Orin NX is controlled by the Linux kernel’s PWM subsystem. To set the initial state of the PWM signal to a high level, you need to configure the PWM controller to output a high level when the PWM signal is not active.

You can do this by setting the pwm_polarity attribute of the PWM device to 1 (active high). You can use the devmem command to set this attribute.

For example, if the PWM device is /sys/class/pwm/pwmchip0/pwm0, you can set the pwm_polarity attribute to 1 using the following command:

echo 1 > /sys/class/pwm/pwmchip0/pwm0/pwm_polarity

Alternatively, you can use the pwmconfig command to configure the PWM controller. For example:

pwmconfig pwmchip0 pwm0 polarity 1
  1. PWM Signal Configuration: Once you’ve configured the PWM controller, you need to configure the PWM signal to output a high level when the PWM signal is not active. You can do this by setting the pwm_duty_cycle attribute of the PWM device to 100% (maximum duty cycle).

For example, if the PWM device is /sys/class/pwm/pwmchip0/pwm0, you can set the pwm_duty_cycle attribute to 100% using the following command:

echo 100 > /sys/class/pwm/pwmchip0/pwm0/pwm_duty_cycle

Alternatively, you can use the pwmconfig command to configure the PWM signal. For example:

pwmconfig pwmchip0 pwm0 duty_cycle 100
  1. Verify the PWM Signal: Once you’ve configured the PWM controller and the PWM signal, you can verify that the PWM signal is outputting a high level when the PWM signal is not active. You can use a logic analyzer or an oscilloscope to verify the PWM signal.

Comparison with Other Methods:

  • Using the gpio command: You can also use the gpio command to set the initial state of the PWM signal to a high level. For example:
gpio -g pwm 13 1

However, this method only sets the initial state of the PWM signal and does not configure the PWM controller or the PWM signal.

  • Using the pwmconfig command: The pwmconfig command is a more comprehensive way to configure the PWM controller and the PWM signal. It allows you to set the PWM frequency, duty cycle, and polarity, as well as configure the PWM controller to output a high level when the PWM signal is not active.

In summary, to set the initial state of the PWM signal to a high level on the Jetson Orin NX, you need to configure the pinmux settings, the PWM controller, and the PWM signal. You can use the devmem command, the pwmconfig command, or the gpio command to achieve this. However, the pwmconfig command is the most comprehensive way to configure the PWM controller and the PWM signal.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

Hi tank.xue,

Could you try configuring Int PU for Req-initial State to check if it could meet your requirement?
Please also configure Pin Direction as Bidirectional so the configuration will be valid.

Hi KevinFFF

Thank you for your reply.

I have tried setting the “Req-initial state” of this pin to “Int PU”, but the initial state of the PWM output remains at a low voltage level

I also attempted to configure the “Pin Direction” to “Bidirectional”, but this configuration results in an error, with the spreadsheet displaying the message: “Error: GP_PWM5 should not be set as Bidirectional.”

May I know the reason for the requirement?

The pin state is determined by PWM controller if you configured it as GP_PWMx.
For the SW workaround to get the default HIGH state, you can try to configure it as GPIO3_PH.00/Output/Drive 1 in pinmux spreadsheet and update the kernel DTB to configure it as PWM instead of GPIO. pinctrl driver should re-configure its pinmux during kernel boot to work with PWM.

This PWM pin is used to drive a PWM LED. There is a level shifter, an external pull-up resistor, and a GMSL deserializer on this signal.

However, the initial state of the PWM pin does not seem to be determined by an external device, as we have already tried removing resistor R2566, which disconnects the external device. Even after removing R2566, the initial state of the PWM signal remains low.

Therefore, I believe that the initial state of this signal is determined by the internal PWM controller of the Jetson.

The reason why we hope the initial state of this PWM IO is high level is to meet the requirement for the initial state of the LED—LED off.

Are there other ways to achieve this requirement?

Have you considered this approach as workaround?

It should configure the default HIGH state for GPIO to make your LED-Off in initial state.