8,367
edits
Changes
→PWM test method
# As can be seen from the table below, Orange Pi CM4 has two channels of pwm available pwm11 and pwm15
::[[File:cm4-img278.png]]
<ol start="2" style="list-style-type: decimal;">
<li><p>In the linux system, the PWM in the 40 pin is turned off by default, and it needs to be turned on manually before it can be used. The detailed steps are as follows:</p>
<ol style="list-style-type: lower-alpha;">
<li>First run '''orangepi-config''', common users remember to add '''sudo''' permission</li></ol></li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''sudo orangepi-config'''
|}</ol>
<ol start="2" style="list-style-type: lower-alpha;">
<li>Then select'''System'''</li></ol>
[[File:cm4-img279.png]]
</ol>
<ol start="3" style="list-style-type: lower-alpha;">
<li>Then select '''Hardware'''</li></ol>
[[File:cm4-img264.png]]
</ol>
<ol start="4" style="list-style-type: lower-alpha;">
<li>Then use the arrow keys on the keyboard to navigate to the position shown in the figure below, and then use the space to select the PWM configuration you want to open</li></ol>
[[File:cm4-img280.png]]
</ol>
<ol start="5" style="list-style-type: lower-alpha;">
<li>Then select '''<Save>''' Save</li></ol>
[[File:cm4-img266.png]]
</ol>
<ol start="6" style="list-style-type: lower-alpha;">
<li>Then select '''<Back>'''</li></ol>
[[File:cm4-img267.png]]
</ol>
<ol start="7" style="list-style-type: lower-alpha;">
<li>Then select '''<Reboot>''' Restart the system for the configuration to take effect</li></ol>
[[File:cm4-img268.png]]
</ol></li></ol>
<ol start="3" style="list-style-type: decimal;">
<li>After opening a pwm, there will be an extra pwmchipX in /sys/class/pwm/ (X is a specific number), for example, after opening pwm11, check the pwmchipX under /sys/class/pwm/ one becomes two</li></ol>{| class="wikitable" style="width:800px;" |-|
orangepi@orangepi:~$ '''ls /sys/class/pwm/'''
pwmchip0 pwmchip1|}</ol>
<ol start="4" style="list-style-type: decimal;">
<li>Which of the above pwmchips corresponds to pwm11? Let’s first check the output of the '''ls /sys/class/pwm/ -l''' command, as shown below:</li></ol>
[[File:cm4-img281.png]]
</ol>
<ol start="5" style="list-style-type: decimal;">
<li>Then it can be known from the table below that the base address of the pwm11 register is fe6f0030, and then look at the output of the '''ls /sys/class/pwm/ -l''' command, you can see that pwmchip1 is linked to fe6f0030.pwm, so pwm11 corresponds to pwmchip as pwmchip1</li></ol>
[[File:cm4-img282.png]]
</ol>
<ol start="6" style="list-style-type: decimal;">
<li>Then use the following command to make pwm11 output a 50Hz square wave (please switch to the root user first, and then execute the following command)</li></ol>{| class="wikitable" style="width:800px;" |-|
root@orangepi:~# '''echo 0 > /sys/class/pwm/pwmchip1/export'''
root@orangepi:~# '''echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable'''
|}
[[File:cm4-img283.png]]
</ol>
<ol start="7" style="list-style-type: decimal;">
<li>The test method of pwm11 demonstrated above is similar to other pwm test methods.</li></ol>