Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PWM on H3 (and H2+) with mainline kernel

Featured Replies

Requirements

  • Fresh enough nighly or manually built image
  • Latest kernel and dtb packages (26.03.2017 or newer)

 

Limitations

As stated in other PWM related threads, hardware PWM output is supported only on pin PA5 which is also UART0 ("debug" serial console) RX pin, so enabling PWM will disable this console.

 

Activation

Add "pwm" to "overlays" line in /boot/armbianEnv.txt

Example:

overlays=pwm

Reboot is required to apply the changes

Armbian overlays documentation: https://docs.armbian.com/User-Guide_Allwinner_overlays/

 

PWM sysfs interface

Official documentation: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/Documentation/ABI/testing/sysfs-class-pwm?h=v4.10

Please note that this ABI is considered "testing" so it may change in the future.

 

Sysfs interface example

# activate the PWM. On H3 only 1 PWM is supported, so exporting PWM 0
echo 0 > /sys/class/pwm/pwmchip0/export
# set period to 10ms
echo 10000000 > /sys/class/pwm/pwmchip0/pwm0/period
# set normal polarity. needs to be reset explicitly. Bug?
echo "inversed" > /sys/class/pwm/pwmchip0/pwm0/polarity
echo "normal" > /sys/class/pwm/pwmchip0/pwm0/polarity
# enable the PWM
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
# set duty cycle to 1ms
echo 1000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle

Result:

 

 


20170130_275659.png.8dcd6c0448989dba6e1c1d52cd5d28b2.png
 

 

# set duty cycle to 2ms
echo 2000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle

Result:

 

 


20170130_275735.png.252ef389ef0a6d067fa2ce05bf4482cc.png
 

 

 

# set duty cycle to 1us, period to 2us
echo 1000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
echo 2000 > /sys/class/pwm/pwmchip0/pwm0/period

Result:

 

 


20170130_280026.png.f5dc9cb48435da58136752e0413c98f3.png
 

 

 

Please note that some settings needs to be changed in a correct sequence, i.e. you can't set duty cycle higher than period

root@orangepiplus2e:~# echo 1000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
root@orangepiplus2e:~# echo 500 > /sys/class/pwm/pwmchip0/pwm0/period
-bash: echo: write error: Invalid argument
root@orangepiplus2e:~#

 

  • Igor unpinned this topic
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.