This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:common:applications:gpio:pwm [2022/12/01 06:08] ivan [Table] |
products:sbc:common:applications:gpio:pwm [2026/09/15 03:25] (current) nick [Control PWM] |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| This page introduces the usage of hardware PWM, and leads you to control the hardware PWM on the [[products: | This page introduces the usage of hardware PWM, and leads you to control the hardware PWM on the [[products: | ||
| - | ===== PWM Information | + | ===== PWM Reference Table ===== |
| - | | | + | | |
| - | ^ VIM1 | + | ^ VIM1 |
| - | ^ VIM2 | + | ^ VIM2 |
| - | ^ VIM3/ | + | ^ VIM3 |
| - | ^ | + | ^ |
| - | ^ VIM1S | PWM_F | + | ^ VIM4 | |
| - | ^ | + | ^ VIM1S | |
| + | ^ | ||
| + | |||
| + | **VIM 5:** | ||
| + | ```shell | ||
| + | $ set -- /sys/bus/ | ||
| + | $ PWM_J=$1 | ||
| + | $ echo $PWM_J | ||
| + | ``` | ||
| - | <WRAP important > | ||
| - | For Edge2, in order to use the PWM function, you need to attach the IO extension board. | ||
| - | </ | ||
| ===== Enable PWM ===== | ===== Enable PWM ===== | ||
| + | |||
| + | ==== Linux ==== | ||
| + | |||
| In order to use the PWM, you need to enable the PWM function via [[products: | In order to use the PWM, you need to enable the PWM function via [[products: | ||
| - | <tabbox VIM1/2/3/3L/Edge1> | + | <tabbox VIM1/ |
| Edit ''/ | Edit ''/ | ||
| Line 31: | Line 39: | ||
| ```shell | ```shell | ||
| - | overlays=uart4 pwm_ao_a | + | overlays=uart3 pwm_f i2c3 i2s os08a10 watchdog |
| ``` | ``` | ||
| Line 40: | Line 48: | ||
| device | device | ||
| ``` | ``` | ||
| + | |||
| + | <tabbox VIM3L> | ||
| + | |||
| + | Edit ''/ | ||
| + | |||
| + | Take VIM3L as an example to enable '' | ||
| + | |||
| + | ```shell | ||
| + | overlays=uart3 pwm_f i2c3 i2s watchdog | ||
| + | ``` | ||
| + | |||
| + | After reboot, you will see the pwm device node. | ||
| + | |||
| + | ```shell | ||
| + | $ ls / | ||
| + | device | ||
| + | ``` | ||
| + | |||
| + | |||
| + | <tabbox VIM3 with 5.15 kernel> | ||
| + | |||
| + | Edit ''/ | ||
| + | |||
| + | |||
| + | You need to add '' | ||
| + | |||
| + | ```shell | ||
| + | fdt_overlays=pwm_f | ||
| + | |||
| + | ``` | ||
| + | |||
| + | After reboot, you will see the pwm device node. | ||
| + | |||
| + | <tabbox VIM3L with 5.15 kernel> | ||
| + | |||
| + | Edit ''/ | ||
| + | |||
| + | |||
| + | You need to add '' | ||
| + | |||
| + | ```shell | ||
| + | fdt_overlays=pwm_f | ||
| + | |||
| + | ``` | ||
| + | |||
| + | After reboot, you will see the pwm device node. | ||
| <tabbox VIM4> | <tabbox VIM4> | ||
| Line 78: | Line 132: | ||
| device | device | ||
| ``` | ``` | ||
| + | <tabbox VIM-5> | ||
| - | <tabbox Edge2> | + | Edit ''/ |
| - | Edit ''/ | + | You need to add '' |
| - | + | ||
| - | + | ||
| - | You need to add '' | + | |
| ```shell | ```shell | ||
| - | fdt_overlays=pwm14 | + | fdt_overlays=pwm_j |
| ``` | ``` | ||
| Line 94: | Line 146: | ||
| ```shell | ```shell | ||
| - | $ ls /sys/class/pwm/pwmchip2 | + | $ set -- /sys/bus/platform/ |
| + | $ PWM_J=$1 | ||
| + | $ ls $PWM_J | ||
| device | device | ||
| ``` | ``` | ||
| Line 100: | Line 154: | ||
| </ | </ | ||
| - | ===== Disable PWM to Use GPIO ===== | ||
| - | If you want to use normal GPIO instead of PWM, you can remove | + | ==== Android ==== |
| + | |||
| + | <tabbox VIM4> | ||
| + | |||
| + | The '' | ||
| + | |||
| + | ```diff | ||
| + | diff --git a/ | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | & | ||
| + | + pinctrl-names = " | ||
| + | + pinctrl-0 = <& | ||
| + | status = " | ||
| + | }; | ||
| + | |||
| + | diff --git a/ | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | & | ||
| + | + pinctrl-names = " | ||
| + | + pinctrl-0 = <& | ||
| + | status = " | ||
| + | }; | ||
| + | |||
| + | diff --git a/ | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -1442,13 +1442,13 @@ | ||
| + | |||
| + | backlight1{ | ||
| + | compatible = " | ||
| + | - | ||
| + | + | ||
| + | index = < | ||
| + | key_valid = < | ||
| + | pinctrl-names = " | ||
| + | " | ||
| + | - | ||
| + | - | ||
| + | pinctrl_version = <2>; /* for uboot */ | ||
| + | interrupts = <0 197 1 | ||
| + | |||
| + | ``` | ||
| + | |||
| + | <tabbox VIM1S> | ||
| + | |||
| + | The '' | ||
| + | |||
| + | ```diff | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -1411,8 +1411,8 @@ | ||
| + | }; | ||
| + | |||
| + | & | ||
| + | - / | ||
| + | - / | ||
| + | + | ||
| + | + | ||
| + | status = " | ||
| + | }; | ||
| + | |||
| + | ``` | ||
| + | </ | ||
| ===== Control PWM ===== | ===== Control PWM ===== | ||
| Line 108: | Line 225: | ||
| **Enable PWM:** | **Enable PWM:** | ||
| - | <tabbox VIM1/3/3L/ | + | <tabbox VIM1/ |
| ```shell | ```shell | ||
| Line 116: | Line 233: | ||
| echo 1 | sudo tee / | echo 1 | sudo tee / | ||
| ``` | ``` | ||
| + | |||
| <tabbox VIM2> | <tabbox VIM2> | ||
| Line 125: | Line 243: | ||
| ``` | ``` | ||
| - | < | + | < |
| ```shell | ```shell | ||
| Line 133: | Line 251: | ||
| echo 1 | sudo tee / | echo 1 | sudo tee / | ||
| ``` | ``` | ||
| - | < | + | |
| + | < | ||
| ```shell | ```shell | ||
| - | echo 0 | sudo tee /sys/class/pwm/pwmchip2/export | + | set -- /sys/bus/ |
| - | echo 1000000 | sudo tee / | + | PWM_J=$1 |
| - | echo 500000 | sudo tee / | + | echo 0 | sudo tee " |
| - | echo 1 | sudo tee / | + | echo 1000000 | sudo tee " |
| + | echo 500000 | sudo tee " | ||
| + | echo 1 | sudo tee " | ||
| ``` | ``` | ||
| Line 154: | Line 275: | ||
| **Disable PWM:** | **Disable PWM:** | ||
| - | <tabbox VIM1/3/3L/ | + | <tabbox VIM1/ |
| ```shell | ```shell | ||
| echo 0 | sudo tee / | echo 0 | sudo tee / | ||
| Line 162: | Line 283: | ||
| echo 0 | sudo tee / | echo 0 | sudo tee / | ||
| ``` | ``` | ||
| - | < | + | < |
| ```shell | ```shell | ||
| echo 0 | sudo tee / | echo 0 | sudo tee / | ||
| ``` | ``` | ||
| - | < | + | < |
| ```shell | ```shell | ||
| - | echo 0 | sudo tee /sys/class/pwm/pwmchip2/ | + | set -- /sys/bus/platform/ |
| + | PWM_J=$1 | ||
| + | echo 0 | sudo tee " | ||
| ``` | ``` | ||
| + | <tabbox VIM3L/ | ||
| + | ```shell | ||
| + | echo 0 | sudo tee / | ||
| + | ``` | ||
| + | |||
| </ | </ | ||
| + | |||
| + | ===== Disable PWM to Use GPIO ===== | ||
| + | |||
| + | If you want to use normal GPIO instead of PWM, you can remove the PWM node in [[products: | ||
| + | |||