• sales

    +86-0755-88291180

Luckfox Pico RV1103【Tutorial on how to use PWM】

Due to pin multiplexing on the LuckFox Pico and LuckFox Pico Plus, there may be conflicts in pin functionality, so PWM functionality cannot be enabled by default for all pins.


】Use the GPIO sysfs interface to control PWM:


1] View the default enabled PWM interfaces:

# ls -l /sys/class/pwm

lrwxrwxrwx    1 root     root             0 pwmchip10 -> ../../devices/platform/ff490020.pwm/pwm/pwmchip10

lrwxrwxrwx    1 root     root             0 pwmchip1 -> ../../devices/platform/ff350010.pwm/pwm/pwmchip1

lrwxrwxrwx    1 root     root             0 pwmchip11 -> ../../devices/platform/ff490030.pwm/pwm/pwmchip11

lrwxrwxrwx    1 root     root             0 pwmchip0 -> ../../devices/platform/ff350000.pwm/pwm/pwmchip0


2] Test PWM. Export PWM1_M0 (GPIO0_A4_d) to the user space:

echo 0 > /sys/class/pwm/pwmchip1/export


3] Set the PWM period unit to ns. For example, the period of a 1KHz frequency is 1000000ns:

echo 1000000 > /sys/class/pwm/pwmchip1/pwm0/period


4] Set the duty cycle:

 #Set the duty cycle to 10% (with a period of 100,000 nanoseconds and a duration of 10,000 nanoseconds).

echo 100000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle  

echo 200000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 300000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 400000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 500000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 600000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 700000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 800000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

echo 900000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

 # Set the duty cycle to 100% (with a period of 1,000,000 nanoseconds and a duration of 1,000,000 nanoseconds).

echo 1000000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle

#Set the duty cycle to 0, which is equivalent to stopping the duty cycle output.

echo 0 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle


5]  Set the normal PWM polarity:

#Set the normal PWM polarity:

echo "normal" > /sys/class/pwm/pwmchip1/pwm0/polarity

#Set the inverted PWM polarity:

echo "inversed" > /sys/class/pwm/pwmchip1/pwm0/polarity


6] Enable PWM :

echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable




7] Disable PWM :

echo 0 > /sys/class/pwm/pwmchip1/pwm0/enable



8] Disable exporting PWM to user space:

echo 0 > /sys/class/pwm/pwmchip1/unexport


9] Screenshot of the operation process:



】Test the built-in sample program of the official SDK:


(The following operations need to be performed in the terminal of the Pico development board)

3] Run the test sample program: 
chmod 777 ./luckfox_pwm_test
## Grant executable permissions to the file
./luckfox_pwm_test 3


4] Running result:

TAG: ESP32-S3 1.69inch Touchscreen LCD Round Display WiFi Bluetooth With QST Attitude Gyro Sensor QMI8658 Jetson Nano Cooler X1011 Raspberry Pi 5 PCIe to M.2 NVMe 4-Ports SSD Board HAT Pi5 Four-Times 2280 Raspberry Pi Pico 2 RP2350 GEEK 1.14 inch LCD 240x135 65K SWD/UART/I2C For OpenOCD/CMSIS-DAP luckfox-pico-ultra-w-gpio Use USB TO 4CH RS485 User Guide Raspberry Pi 5 PCIe to M.2 NVME SSD And Gigabit Ethernet RJ45 HAT RTL8111H M_KEY For 2230/2242/2260/2280 Industrial Isolated RS485 TO ETH (C) RJ45 Converter Wall/Rail-Mount For Modbus RP2040 UGV Rover ROS2 PT AI OpenCV Robot Car MediaPipe For Jetson Orin Nano WIFI Configuration ESP32 S3 Development Board 1.85 inch Round LCD Display 360×360 QMI8658 Sensor / MIC / SD /MP3 Audio /Battery Port LVGL/HMI For Arduino ESP32-S3 GEEK Development Board Camera STLINK DeepSeek AI Voice Chat ESP32 S3 Development Board 1.8 inch AMOLED Display 368×448 1.8inch TouchScreen Programmable Watch QMI8658 /MIC /Audio /Battery Sipeed NanoKVM-USB Finger-sized 4K USB KVM for Server/SBCs Arduino Thermal imaging Program Raspberry Pi display