Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6037

C/C++ • Re: PWM with C++

$
0
0
you could use the sysfs '/sys/class/pwm'


First you need to add the overlay into the config.txt (/boot/firmware/config.txt)

Code:

dtoverlay=pwm
After you need to set the pin12 to alternate function a0

Code:

daniel@Pi4home:~ $ pinctrl 1212: ip    pd | lo // GPIO12 = inputdaniel@Pi4home:~ $ pinctrl 12 a0daniel@Pi4home:~ $ pinctrl 1212: a0    pd | lo // GPIO12 = PWM0_0daniel@Pi4home:~ $ 
Now the PWM should work!
You can set the alt function in the dtoverlay

Code:

dtoverlay=pwm,pin=12,func=4
Function 4 is Alt 0.

Statistics: Posted by rpdom — Tue Oct 08, 2024 8:50 pm



Viewing all articles
Browse latest Browse all 6037

Latest Images

Trending Articles



Latest Images