Hello,
I’m trying to make use of two PWM output lines from the BBB however, I am confused on how to properly enable them. I’ve looked at several resources and some are using capes/overlays and the subdirectories also look different from my BBB.
Here’s how I am currently approaching the PWM:
Export the pwm:
int fd, len;
char buf[MAX_BUF];
fd = open("/sys/class/pwm/pwmchip0/export", O_WRONLY);
len = snprintf(buf, sizeof(buf), "%d", 1);
write(fd, buf, len);
close(fd);
Set the Period, duty cycle:
fd = open("/sys/class/pwm/pwm-0:0/period", O_WRONLY);
Start PWM:
int fd, len;
char buf[MAX_BUF];
fd = open("/sys/class/pwm/pwm-0:0/enable", O_WRONLY);
len = snprintf(buf, sizeof(buf), "%d", 1);
write(fd, buf, len);
close(fd);
However, I get no output on Pin P9.21/22
What is further confusing is the maping of the pinouts and the directory of the PWM folders. Looking in /sys/class/pwm I see folders: pwm-0:0, pwm-1:1 … pwm-7:1, pwmchip0, pwmchip 1, … pwmchip7. However when I go into /sys/class/pwm/pwmchip0 I also see another folder pwm-0:0. So which folder do I have to write to in order to correctly initialize and start the PWM modulation. Also which Pin does pwm-0:0 correspond to versus pwm-1:0 and pwm-1:1. I’ve googled around and have come to the conclusion that:
P8.13 corresponds to folder: /sys/class/pwm/pwm-6:1
P8.19 corresponds to folder: /sys/class/pwm/pwm-6:0
P9.14 corresponds to folder: /sys/class/pwm/pwm-3:0
P9.16 corresponds to folder: /sys/class/pwm/pwm-3:1
P9.21 corresponds to folder: /sys/class/pwm/pwm-1:1
P9.22 corresponds to folder: /sys/class/pwm/pwm-1:0
I am unsure if that is indeed accurate