MAE 3185 - Introduction to Mechatronics

Logo

View the Project on GitHub Abhiricky1992/UTA-MAE3185-Notes

hardware_pwm Library Functions

To use this library, add following to the C/C++ file,

#include <hardware/pwm.h>

and following to the CMakeLists.txt file.

target_link_libraries(projectName pico_stdlib hardware_gpio hardware_pwm)

Following are some of the most commonly used functions for configuring the PWM peripheral.

uint8_t pwm_gpio_to_slice_num(uint8_t pinNo)

Get the PWM slice number for a GPIO number.

uint8_t pwm_gpio_to_channel(uint8_t pinNo)

Get the PWM channel number for a GPIO number.

pwm_set_clkdiv_int_frac(uint8_t sliceNum, uint8_t divInt, uint8_t divFrc)

Configure the clock divider integer and fractional values.

pwm_set_wrap(uint8_t sliceNum, uint16_t top)

Configure the counter wrap value.

pwm_set_chan_level(uint8_t sliceNum, uint8_t chanNum, uint16_t cc)

Configure the counter compare value.

pwm_set_enabled(uint8_t sliceNum, bool enabled)

Enable or disable the PWM output.

Next

Code Examples

Back

Working of a PWM