Pulse-Width Modulation Function Documentation

 

Sys_PWM_GPIOConfig

void Sys_PWM_GPIOConfig(uint8_t gpio, uint8_t channel, uint32_t cfg, uint8_t inverted)

 

Configure a GPIO pad for the PWM interface.

 

Location: pwm.h:60

 

Parameters

Direction Name Description

in

gpio

Pad to configure as the output for the specified PWM channel

in

channel

PWM channel

in

cfg

Configuration of the GPIO pad

in

inverted

Output PWM interface signal inverted

 

 

Example Code for Sys_PWM_GPIOConfig

    // Enable PWM channel 0 on GPIO5. Use a non-inverted waveform

    Sys_PWM_GPIOConfig(PWM0_GPIO5, PWM_CH0,

                       GPIO_6X_DRIVE | GPIO_LPF_DISABLE | GPIO_STRONG_PULL_UP,

                       PWM_NON_INVERTED);

 

Sys_PWM_Config

void Sys_PWM_Config(uint8_t channel, uint32_t period, float duty_cycle, uint32_t offset)

 

Set length of PWM period and number of high cycles within a PWM period.

 

Location: pwm.h:85

 

Parameters

Direction Name Description

in

channel

PWM channel

in

period

Length of a PWM period

in

duty_cycle

Duty cycle value (expressed in percentage)

in

offset

Cycles between the rising edge of the specified PWM channel and the rising edge of PWM channel 0

 

 

Example Code for Sys_PWM_Config

    // Configure PWM channel 0 to a period of 2, with 50% duty cycle an no offset

    Sys_PWM_Config(PWM_CH0, 2, 50, 0);

 

Sys_PWM_Enable

void Sys_PWM_Enable(uint32_t enable)

 

Enable a set of PWM channels.

 

Location: pwm.h:113

 

Parameters

Direction Name Description

in

enable

PWM channel

 

 

Example Code for Sys_PWM_Enable

    // Enable output of PWM channel 0

    Sys_PWM_Enable(PWM0_ENABLE);

 

Sys_PWM_Disable

void Sys_PWM_Disable(uint32_t disable)

 

Disable the PWM[4:0] channel Disabling the PWM channel will set the counter and prescaler to zero.

 

Location: pwm.h:125

 

Parameters

Direction Name Description

in

disable

PWM channel

 

 

Example Code for Sys_PWM_Disable

    // Disable output of PWM channel 0, clear the counter and prescaler

    Sys_PWM_Disable(PWM0_ENABLE);

 

Sys_PWM_Reset_Channel

void Sys_PWM_Reset_Channel(uint32_t reset)

 

Reset the PWM[4:0] channel Disable the PWM[4:0] channel, reset the PWM_CFG[4:0] and PWM_OFFSET[4:1] registers and the related counter.

 

Location: pwm.h:137

 

Parameters

Direction Name Description

in

reset

PWM channel

 

 

Example Code for Sys_PWM_Reset_Channel

    // Reset PWM channel 0

    Sys_PWM_Reset_Channel(PWM0_RESET);