PWM Interface
PWM Platform interface
PWM Overview
Pulse Width Modulation (PWM) is a powerful technique used to control the amount of power delivered to electrical devices, including motors, LEDs, and other components. PWM achieves this by varying the duty cycle of a periodic digital signal, effectively simulating an analog output.
PWM Modes
The following PWM modes are supported:
RS_PWM_MODE_ONE_SHOT : The PWM signal is generated once and stops after completing a single cycle.
RS_PWM_MODE_CONTINUOUS : The PWM signal is continuously generated, repeating the cycle indefinitely.
These modes allow flexibility in controlling the duration and repetition of the PWM signal based on the application requirements.
Application Interface
The below table captures the functions that are to be called from the application layer.
Function |
Description |
|---|---|
rs_pwm_open |
To open the pwm interface. |
rs_pwm_configure_channel |
To configure the pwm interface. |
rs_pwm_start_channel |
To start the pwm channel interface. |
rs_pwm_stop_channel |
To stop the pwm channel interface. |
rs_pwm_on_channel |
To on the pwm channel interface. |
rs_pwm_off_channel |
To off the pwm channel interface. |
rs_pwm_set_channel_duty_cycle |
To set the pwm channel dutycycle. |
rs_pwm_set_channel_frequency |
To set the pwm channel frequency. |
rs_pwm_get_channel_config |
To get the updated pwm channel config |
rs_pwm_close |
To close the pwm interface |
Implementation Guide
Flint provide the PWM unit configuration and Channel configuration. Flint can have Digital Output Bridge to drive the PWM value.
Initialize the PWM unit
Configure the PWM channel under the unit
Register the callback function
Start the PWM conversion
Callback gets called where the next value can be updated
Stop the conversion once work is done
Un-Initialize the PWM unit
Error Code
Every API’s for the PWM returns some success or failure values. Please refer below section,
Documentation from the relevant header as follows:
Warning
doxygenfile: Cannot find file “rs_pwm.h