Перейти к содержанию

Навигация

Translations:Buzzer/10/en: различия между версиями

Нет описания правки
(Новая страница: «Enable PWM output: <pre> echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable </pre>»)
 
 
Строка 1: Строка 1:
Enable PWM output:
To work with pwm through sysfs you need:
<pre>
#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/pwm2/enable
# 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>
</pre>
#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>
translator, wb_editors
4433

правки