PWM(8)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

✨ PWM(8) β€” the pwm girlies' field guide ✨

okay so real talk: pwm(8) is a System Manager's Manual page and it's genuinely iconic β€” it's your whole entire guide to poking at PWM (Pulse Width Modulation) hardware from the command line. no cap, this is the good stuff πŸ’…


πŸŽ€ NAME πŸŽ€

pwm β€” configure PWM (Pulse Width Modulation) hardware. that's it. that's the vibe. literally the entire point of this little guy πŸ¦‹


🌸 SYNOPSIS 🌸

pwm [-f device] -C
pwm [-f device] [-D | -E] [-I] [-p period] [-d duty]

two whole forms bestie, pick your fighter 🫢


πŸ’– DESCRIPTION πŸ’–

So pwm is the utility you use to configure pwm hardware ✨ and the way it talks to said hardware is through a pwmc(4) device β€” that's the middleman, the connection, the bridge πŸ”₯

okay listen, here's a thing that's lowkey important: some PWM hardware supports multiple output channels within a single controller block. but each pwmc(4) instance controls a single PWM channel. one instance = one channel. no sharing, no drama πŸ™ˆ

and these pwmc(4) devices are named like this:

/dev/pwm/pwmcX.Y

where X is the controller unit number and Y is the channel number within that unit. so like, X = which controller, Y = which channel on it. super cute, super logical πŸ’œ

The options are as follows:

  • -f device β€” the device you wanna operate on πŸ’« If you don't specify one, /dev/pwm/pwmc0.0 is used (the default, the fallback, the main character). And if you give it an unqualified name, /dev/pwm gets automatically prepended for you β€” so you don't have to type the whole path, she's got you 🫢
  • -C β€” show the configuration of the PWM channel. like a vibe check, but for your PWM ✨
  • -D β€” disable the PWM channel 😴 turn it off, she's resting now
  • -d duty β€” configure the duty cycle of the PWM channel. the value can be in nanoseconds or percentage. and for the record: duty is the portion of the period during which the signal is asserted. iykyk πŸ’…
  • -E β€” enable the PWM channel πŸ”₯ wake up bestie, we're going live
  • -p period β€” configure the period (in nanoseconds) of the PWM channel ⏱️
  • -I β€” Invert PWM signal polarity 🌈 flip it, reverse it, make it opposite

🧚 EXAMPLES 🧚

these are the actual real examples, copy them exactly, don't freestyle, i'm begging 😭
  • Show the configuration of the PWM channel:
pwm -f /dev/pwm/pwmc0.1 -C
  • Configure a 50000 ns period and a 25000 ns duty cycle and enable the channel:
pwm -f pwmc1.1 -E -p 50000 -d 25000
  • Configure a 50% duty cycle on the device and channel which were configured in pwmc(4) to have the label backlight:
pwm -f backlight -d 50%

like?? the label thing?? obsessed. no full paths needed, just vibe with the label πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

pwm(9), pwmbus(9) β€” go read these next, they're the supporting cast and they ate πŸ’œ


⭐ HISTORY ⭐

The pwm utility appeared in FreeBSD 13.0. a classic, a legend, an era 🌟


🌈 AUTHORS 🌈

The pwm utility and this manual page were written by Emmanuel Vadot <manu@FreeBSD.org> β€” ty for your service king 🫢


aaaand that's the whole page bestie, you're officially pwm-pilled πŸ’–

okay so the very last bits, the sign-off tea: this one comes from Debian, dated June 17, 2019, and it's the PWM(8) page of the System Manager's Manual. mwah, go configure something πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from