Overview

This module contains functions for accessing the PWM (Pulse Width Modulation) modules of the eLua CPU.

Functions

frequency = pwm.setup( id, frequency, duty )

Setup the PWM modules.

Arguments:

  • id - the ID of the PWM module.
  • frequency - the frequency of the PWM module (in Hz).
  • duty - the duty cycle of the PWM module given in percents. This must be an integer between 0 and 100. NOTE: depending on the hardware, some duty cycles (particulary 0 and 100) might not be achievable.

Returns: The actual frequenct set on the PWM module. Depending on the hardware, this might have a different value than the frequency argument.

pwm.start( id )

Start the PWM signal on the given module.

Arguments: id - the ID of the PWM module.

Returns: nothing.

pwm.stop( id )

Stop the PWM signal on the given module.

Arguments: id - the ID of the PWM module.

Returns: nothing.

clock = pwm.setclock( id, clock )

Set the base clock of the given PWM module.

Arguments:

  • id - the ID of the PWM module.
  • clock - the desired base clock.

Returns: The actual base clock set on the PWM module. Depending on the hardware, this might have a different value than the clock argument.

clock = pwm.getclock( id )

Get the base clock of the given PWM module.

Arguments: id - the ID of the PWM module.

Returns: The base clock of the PWM module.