Updated: 2022/Sep/29

Please read Privacy Policy. It's for your privacy.

GPIOPWM(4)                   Device Drivers Manual                  GPIOPWM(4)

     gpiopwm - support for pulsing GPIO pins in software

     gpiopwm* at gpio? offset ? mask 1
     gpiopwm* at gpio?

     The gpiopwm driver allows for pulsing GPIO pins in software using the
     callout(9) facility.  The pulse frequency and duty cycle are specified
     indirectly by setting an "on" and "off" period, in ticks.  Both values
     are accessible as sysctl(3) variables.

     The following sysctl(3) variables are used to define the pulsing:

     hw.gpiopwmN.off  Define the "off" period in ticks.

     hw.gpiopwmN.on   Define the "on" period in ticks.

     Only when both the "on" and the "off" period are set to values higher
     than zero pulsing will start.  To stop the pulsing, set either value to

     To pulse a pin on a machine with 100 ticks/second with a frequency of 1Hz
     and a duty cycle of 20%, the "on" period must be set to 20 and the "off"
     period must be set to 80.  The following example will pulse the error LED
     of a Soekris net4801 with a frequency of 1 Hz and a duty cycle of 20%:

     # gpioctl gpio0 20 set pp
     # gpioctl gpio0 attach gpiopwm 20 1
     # sysctl -w hw.gpiopwm0.off=80
     # sysctl -w hw.gpiopwm0.on=20

     gpio(4), intro(4), gpioctl(8), sysctl(8)

     The gpiopwm driver first appeared in NetBSD 6.0.

     The gpiopwm driver was written by Marc Balmer <marc@msys.ch>.

NetBSD 10.99                   November 13, 2011                  NetBSD 10.99