Skip to content
Ankur Yadav edited this page Aug 9, 2015 · 8 revisions

#PWM API

This page contains native API functions for accessing PWMs of beaglebone black. Code of this API can be found in pwm.c. Sample JNI wrapper functions can be found here.

###PWM API functions description

  1. int pwmSetPeriod(unsigned int channel, unsigned int period_ns) : It takes channel and period to be assigned in nano seconds and sets period of that channel to specified value using file system. If pwmSetPeriod() is successful then 0 is returned otherwise -1 is returned.
  2. unsigned int pwmGetPeriod(unsigned int channel) : It takes channel number as input and returns the value of period of specified channel in nano seconds.
  3. int pwmSetDutyCycle(unsigned int channel, unsigned int duration_ns) : It takes channel and duty cycle to be assigned in nano seconds and sets duty cycle of that channel to specified value using file system. If pwmSetDutyCycle() is successful then 0 is returned otherwise -1 is returned.
  4. int pwmGetDutyCycle(unsigned int channel) : It takes channel number as input and returns the value of duty cycle of specified channel in nano seconds.
  5. int pwmSetPolarity(unsigned int channel, unsigned int polarity) : It takes channel and polarity to be assigned and sets polarity of that channel to the specified value using file system. If pwmSetPolarity() is successful then 0 is returned otherwise -1 is returned.
  6. int pwmGetPolarity(unsigned int channel) : It takes channel number as input and returns the value of polarity of specified channel.
  7. int pwmRun(unsigned int channel) : It takes channel number as input and sets run for that channel so that pwm starts running for that channel.
  8. int pwmStop(unsigned int channel) : It takes channel number as input and sets run to 0 for that channel so that pwm stops for that channel.
  9. int pwmRunCheck(unsigned int channel) : It takes channel number as input and returns the value of run for that channel.
Clone this wiki locally