This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
products:sbc:common:applications:gpio:pwm [2022/06/29 21:51] 127.0.0.1 external edit |
products:sbc:common:applications:gpio:pwm [2023/03/30 23:54] nick [Table] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | # PWM | + | ====== |
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | This page introduces the usage of hardware PWM, and leads you to control the hardware PWM on the [[products: | ||
+ | |||
+ | ===== PWM Reference Table ===== | ||
+ | |||
+ | | | ||
+ | ^ VIM1 | ||
+ | ^ VIM2 | ||
+ | ^ VIM3 | ||
+ | ^ VIM3L | '' | ||
+ | ^ VIM4 | ||
+ | ^ VIM1S | '' | ||
+ | |||
+ | |||
+ | ===== Enable PWM ===== | ||
+ | |||
+ | In order to use the PWM, you need to enable the PWM function via [[products: | ||
+ | |||
+ | <tabbox VIM1/ | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | Take VIM3 as an example to enable '' | ||
+ | |||
+ | ```shell | ||
+ | overlays=uart3 pwm_f i2c3 i2s os08a10 watchdog | ||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the pwm device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | 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 VIM4> | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | |||
+ | You need to add '' | ||
+ | |||
+ | ```shell | ||
+ | fdt_overlays=pwm_f | ||
+ | |||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the pwm device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | device | ||
+ | ``` | ||
+ | |||
+ | <tabbox VIM1S> | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | |||
+ | You need to add '' | ||
+ | |||
+ | ```shell | ||
+ | fdt_overlays=pwm_f | ||
+ | |||
+ | ``` | ||
+ | |||
+ | After reboot, you will see the pwm device node. | ||
+ | |||
+ | ```shell | ||
+ | $ ls / | ||
+ | device | ||
+ | ``` | ||
+ | </ | ||
+ | |||
+ | ===== Disable PWM to Use GPIO ===== | ||
+ | |||
+ | If you want to use normal GPIO instead of PWM, you can remove the PWM node in [[products: | ||
+ | |||
+ | ===== Control PWM ===== | ||
+ | |||
+ | **Enable PWM:** | ||
+ | |||
+ | <tabbox VIM1/ | ||
+ | |||
+ | ```shell | ||
+ | echo 1 | sudo tee / | ||
+ | echo 1000000 | sudo tee / | ||
+ | echo 500000 | sudo tee / | ||
+ | echo 1 | sudo tee / | ||
+ | ``` | ||
+ | |||
+ | <tabbox VIM3L> | ||
+ | |||
+ | ```shell | ||
+ | echo 1 | sudo tee / | ||
+ | echo 1000000 | sudo tee / | ||
+ | echo 500000 | sudo tee / | ||
+ | echo 1 | sudo tee / | ||
+ | ``` | ||
+ | |||
+ | <tabbox VIM2> | ||
+ | |||
+ | ```shell | ||
+ | echo 1 | sudo tee / | ||
+ | echo 1000000 | sudo tee / | ||
+ | echo 500000 | sudo tee / | ||
+ | echo 1 | sudo tee / | ||
+ | ``` | ||
+ | |||
+ | <tabbox VIM1S> | ||
+ | |||
+ | ```shell | ||
+ | echo 1 | sudo tee / | ||
+ | echo 1000000 | sudo tee / | ||
+ | echo 500000 | sudo tee / | ||
+ | echo 1 | sudo tee / | ||
+ | ``` | ||
+ | </ | ||
+ | |||
+ | Use an oscilloscope to check if the pins have been successfully enabled. | ||
+ | |||
+ | {{products: | ||
+ | |||
+ | <WRAP info > | ||
+ | If you use an oscilloscope to view the PWM waveform, remember that the SBC and the oscilloscope need to share the same GND (ground). | ||
+ | </ | ||
+ | |||
+ | **Disable PWM:** | ||
+ | |||
+ | <tabbox VIM1/ | ||
+ | ```shell | ||
+ | echo 0 | sudo tee / | ||
+ | ``` | ||
+ | <tabbox VIM3L> | ||
+ | ```shell | ||
+ | echo 0 | sudo tee / | ||
+ | ``` | ||
+ | <tabbox VIM2> | ||
+ | ```shell | ||
+ | echo 0 | sudo tee / | ||
+ | ``` | ||
+ | <tabbox VIM1S> | ||
+ | ```shell | ||
+ | echo 0 | sudo tee / | ||
+ | ``` | ||
+ | </ | ||
+ |