Issues with PWN when running python file

I am running a python program to control the speed of a dc motor on the jetson nano and trying to use PWN however, I am receiving an error when I run the code saying “Attribute Error: ‘module’ object has no attribute ‘PWN’”. I have the import statement “import RPi.GPIO as GPIO” in my program. I am not sure what the issue. Does anyone know a solution for this error or know another way to control the speed of dc motors?

Have you tried PWM as is Mary

Thank you. That spelling mistake was the error. However, even though my there are no errors, when I run my program, nothing happens to the motor.

import RPi.GPIO as GPIO
import time

for 1st Motor on ENA

ENA = 33
IN1 = 35
IN2 = 37

set pin numbers to the board’s


initialize EnA, In1 and In2

GPIO.setup(IN1, GPIO.OUT, initial=GPIO.LOW)
GPIO.setup(IN2, GPIO.OUT, initial=GPIO.LOW)

pwm= GPIO.PWM(ENA,100)


GPIO.output(IN2, GPIO.LOW)


GPIO.output(IN1, GPIO.LOW)


GPIO.output(IN1, GPIO.LOW)
GPIO.output(IN2, GPIO.LOW)


Could someone help me find out why?

Have you configured the pinmux for PWM?

$ cd /opt/nvidia/jetson-io
$ sudo

Configure 40-pin expansion header, Select pwm2 (33), Save and exit, reboot.

and see:
jetson-gpio/ at master · NVIDIA/jetson-gpio (

Yes I already selected pwm2(33) in the pin configuration when I was running my program.

I have a feeling you haven’t tried the jetson-io tool. Configuring the pins in python isn’t enough. CHeck the documentation again.

  1. PWM

See samples/ for details on how to use PWM channels.

The Jetson.GPIO library supports PWM only on pins with attached hardware PWM controllers. Unlike the RPi.GPIO library, the Jetson.GPIO library does not implement Software emulated PWM. Jetson Nano supports 2 PWM channels, and Jetson AGX Xavier supports 3 PWM channels. Jetson TX1 and TX2 do not support any PWM channels.

The Jetson.GPIO library does not dynamically modify the pinmux configuration to achieve this. Read the L4T documentation for details on how to configure the pinmux.

This is the only way I was able to get it to work. Also if you are connected via SSH, “Save and exit without rebooting” then reboot. I tried “Save and reboot” before and it wouldn’t boot again.

$ cd /opt/nvidia/jetson-io
$ sudo

I have already configure the pwm pins with jetson-io. This is what is currently says after save and reboot. Do I need to do anything else?

That’s all. Test the code I linked earlier.

I tried running the code you sent for 2 dc motors but the motors aren’t doing anything. I was little confused on how the motors are wired to the input pins. Are the pwm pins being connected to enable on a motor driver or are they connected to the to the motors directly? If possible, could you explain the schematic to run that code?

I think the 2 motor example is using this 10Amp 6V-24V DC Motor Driver HAT for RPI (2 Channels) (

Your use case might be different.

Yes I am using a PChero L298N Motor Drive Controller Board Module, Dual H Bridge DC Stepper for Arduino. Do you know if theres an issue with the code I sent earlier?

I’m not familiar with that motor driver. Can you scope the PWM pin(s) to make sure they’re working?

Does this help?
Building a Custom JetBot with Jetson Nano -

I check the pin with a scope and found that the pin didn’t generate a pulse.

hello akashsivapalanspam,

may I know what’s the results by checking debug node. $ cat /sys/kernel/debug/pwm

platform/70110000.pwm, 1 PWM device
pwm-0 (pwm-regulator ): requested enabled period: 2500 ns duty: 0 ns po larity: normal

platform/7000a000.pwm, 4 PWM devices
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-1 (pwm-regulator ): requested period: 8000 ns duty: 1440 ns polarit y: normal
pwm-2 ((null) ): period: 0 ns duty: 0 ns polarity: normal
pwm-3 (pwm-fan ): requested enabled period: 45334 ns duty: 0 ns p olarity: normal

hello akashsivapalanspam,

please note that, you can only access pwmchip0 (@7000a000); pwmchip4(@70110000) is not expected to be used by user.
so, you may use pwm@pwmchip0 by exporting them. i.e. $ echo '<0/1/2/3>' > /sys/class/pwm/pwmchip0/export

according to above, there’s already a PWM enabled.
could you please also running with devmem tool is to read/write register.
when you have enabled Pin 32 as PWM, you must see bit 0 of register 0x700031fc to be set.
for example, $ sudo busybox devmem 0x700031fc

Do i just enter the echo command like that in the terminal. I get an error saying echo write error: Invalid argument. Also when i enter the devmem line, the output i get is 0x00000001

hello akashsivapalanspam,

you might using incorrect commands, please share the command-line for reference.