Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

PWM Example#

Introduction#

This example is a PWM HAL functional test program, focusing on verifying multi-channel simultaneous output, dynamic adjustment of frequency/duty cycle, and readback verification.

Source location: src/rtsmart/examples/peripheral/pwm/test_pwm.c

Example Behavior#

  • Map PWM0/PWM1 to PIN42/PIN43 respectively

  • Perform dual-channel synchronous output test after PWM initialization

  • Dynamically adjust frequency and duty cycle at runtime

  • Execute frequency test scenarios such as synchronous/independent/rapid switching

  • Finally disable the channel and deinitialize

Key Interfaces#

  • drv_pwm_init() / drv_pwm_deinit()

  • drv_pwm_set_freq() / drv_pwm_get_freq()

  • drv_pwm_set_duty() / drv_pwm_get_duty()

  • drv_pwm_enable() / drv_pwm_disable()

  • drv_fpioa_set_pin_func()

Build and Run#

cd src/rtsmart/examples/peripheral/pwm
make
./test_pwm

This example has no command-line arguments.

Hint

For PWM interface details, please refer to PWM API Documentation.

Comments list
Comments
Log in