This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
products:sbc:edge-2l:applications:gpio:pwm [2025/11/25 04:30] gray created |
products:sbc:edge-2l:applications:gpio:pwm [2026/05/11 02:08] (current) nick ↷ Page moved from local:users:gray:products:sbc:edge-2l:applications:gpio:pwm to products:sbc:edge-2l:applications:gpio:pwm |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| ===== Introduction ===== | ===== Introduction ===== | ||
| - | This page introduces | + | This page explains how to use the hardware PWM (Pulse Width Modulation) |
| <WRAP important > | <WRAP important > | ||
| - | For Edge-2L, in order to use the PWM function, you need to attach the IO extension | + | To use the PWM functionality on the Edge-2L, you must attach the Edge-2L |
| </ | </ | ||
| - | ===== PWM Information | + | ===== PWM information |
| | | | | ||
| - | ^ Edge-2L | + | ^ Edge-2L |
| ===== Enable PWM ===== | ===== Enable PWM ===== | ||
| - | In order to use the PWM, you need to enable | + | To use the hardware |
| - | + | Edit the file ''/ | |
| - | Edit ''/ | + | |
| - | + | ||
| - | + | ||
| - | You need to add '' | + | |
| ```shell | ```shell | ||
| fdt_overlays=edge-2l-io-pwm | fdt_overlays=edge-2l-io-pwm | ||
| - | |||
| ``` | ``` | ||
| - | After reboot, you will see the pwm device node. | + | Reboot the system for the change to take effect. |
| ```shell | ```shell | ||
| - | $ ls / | + | $ ls / |
| device | device | ||
| ``` | ``` | ||
| - | ===== Disable PWM to Use GPIO ===== | + | ===== Disable PWM to use as GPIO ===== |
| - | If you want to use normal | + | If you wish to use the pin as a standard |
| - | ===== Control PWM ===== | + | ===== Control PWM via sysfs===== |
| - | **Enable PWM: | + | **Enable |
| + | The following sequence enables PWM channel 0, sets a period of 1,000,000 nanoseconds (1 kHz), a duty cycle of 500,000 nanoseconds (50% duty), and starts the output: | ||
| ```shell | ```shell | ||
| - | echo 0 | sudo tee / | + | # Export PWM channel 0 |
| - | echo 1000000 | sudo tee / | + | $ echo 0 | sudo tee / |
| - | echo 500000 | sudo tee / | + | |
| - | echo 1 | sudo tee / | + | # Set period to 1,000,000 ns (1 kHz) |
| + | $ echo 1000000 | sudo tee / | ||
| + | |||
| + | # Set duty cycle to 500,000 ns (50%) | ||
| + | $ echo 500000 | sudo tee / | ||
| + | |||
| + | # Enable PWM output | ||
| + | $ echo 1 | sudo tee / | ||
| ``` | ``` | ||
| - | Use an oscilloscope to check if the pins have been successfully enabled. | + | Use an oscilloscope to verify |
| {{products: | {{products: | ||
| - | <WRAP info > | + | <WRAP info > |
| - | If you use an oscilloscope to view the PWM waveform, | + | When using an oscilloscope to measure |
| </ | </ | ||
| **Disable PWM:** | **Disable PWM:** | ||
| + | To stop the PWM signal: | ||
| ```shell | ```shell | ||
| - | echo 0 | sudo tee / | + | echo 0 | sudo tee / |
| ``` | ``` | ||