PWM devices in Linux
Let's use the BeagleBone Black to see how a PWM device works (the steps that follow are almost the same for the SAMA5D3 Xplained and other GNU/Linux supporting these devices). We saw earlier that for each PWM generator, we have a well-defined directory in /sys/class/pwm/
. In our case, we have the directory named pwmchip0
. Then, by taking a look at its contents, we can find the following items:
root@bbb:~# ls /sys/class/pwm/pwmchip0/ device/ export npwm power/ subsystem/ uevent unexport
You can notice that this representation is quite similar to the GPIO controllers we saw in the GPIOs in Linux section, in Chapter 6, General Purposes Input Output signals – GPIO
. So, the export
and unexport
files are used to export and unexport the PWMs, respectively, while in npwm
, we have the number of PWM lines we can manage within the PWM chip. As expected, in the command line here, we see that we can manage two PWM signals within the pwmchip0...