translator, wb_editors
4539
правок
(Новая страница: «Enable PWM output: <pre> echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable </pre>») |
Matveevrj (обсуждение | вклад) |
||
Строка 1: | Строка 1: | ||
Enable PWM output | To work with pwm through sysfs you need: | ||
< | #Export port <syntaxhighlight lang="bash">echo 0 > /sys/class/pwm/pwmchip0/export</syntaxhighlight>After that, the /sys/class/pwm/pwmchip0/pwm0 directory appears | ||
echo 1 > /sys/class/pwm/pwmchip0/ | # Write the pwm period in nanoseconds <syntaxhighlight lang="bash">echo 250000 > /sys/class/pwm/pwmchip0/pwm0/period # set the period to 250,000 ns, i.e. in 250µs, which corresponds to a frequency of 4kHz</syntaxhighlight> | ||
</ | #Record volume (calculated from duty-cycle) <syntaxhighlight lang="bash">echo 125000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle # maximum volume is reached when duty_cycle = period / 2 => set duty_cycle to 125,000 ns</syntaxhighlight> | ||
#Enable PWM output <syntaxhighlight lang="bash">echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable</syntaxhighlight> |