Pulse-Width Modulation Function Documentation

 

Sys_PWM_GPIOConfig

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

 

Location: pwm.h:60

 

Configure a GPIO pad for the PWM interface.

 

 

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);

 

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

 

Sys_PWM_Config

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

 

Location: pwm.h:85

 

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

 

 

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);

 

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

 

Sys_PWM_Enable

void Sys_PWM_Enable(uint32_t enable)

 

Location: pwm.h:113

 

Enable a set of PWM channels.

 

 

Example Code for Sys_PWM_Enable

    // Enable output of PWM channel 0

    Sys_PWM_Enable(PWM0_ENABLE);

 

Parameters

Direction Name Description

in

enable

PWM channel

 

Sys_PWM_Disable

void Sys_PWM_Disable(uint32_t disable)

 

Location: pwm.h:125

 

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

 

 

Example Code for Sys_PWM_Disable

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

    Sys_PWM_Disable(PWM0_ENABLE);

 

Parameters

Direction Name Description

in

disable

PWM channel

 

Sys_PWM_Reset_Channel

void Sys_PWM_Reset_Channel(uint32_t reset)

 

Location: pwm.h:137

 

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.

 

 

Example Code for Sys_PWM_Reset_Channel

    // Reset PWM channel 0

    Sys_PWM_Reset_Channel(PWM0_RESET);

 

Parameters

Direction Name Description

in

reset

PWM channel