Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PWMA - Pulse Width Modulation A

The Pulse Width Modulation A Controller (PWMA) controls several pulse width modulation (PWM) channels.

This driver provides an API to get access to the main features of the PWMA controller.

Modules

 

Macros

#define PWMA_CHANNEL_LIMIT   4
 

Functions

void pwma_config_and_enable (volatile avr32_pwma_t *pwma, unsigned long long int channel_mask, int period_cycles, int duty_cycles)
 Configure and enable the PWMA. More...
 
bool pwma_config_enable (volatile avr32_pwma_t *pwma, uint32_t pwma_freq_hz, uint32_t gclk_freq_hz, uint16_t spread)
 Configure and enable the PWMA. More...
 
static void pwma_disable (volatile avr32_pwma_t *pwma)
 Disable a PWMA module. More...
 
bool pwma_set_channels_value (volatile avr32_pwma_t *pwma, uint64_t channel_mask, uint16_t duty_cycle)
 Load the duty cycle value to the channels. This function uses Interlinked Single Value Mode where several channels are interlinked to allow multiple channels to be updated simultaneously with the same duty cycle value. More...
 
bool pwma_set_multiple_values (volatile avr32_pwma_t *pwma, uint32_t channel_mask, uint16_t *channel_duty_cycles)
 Load multiple duty cycle values to multiple channels. This function uses Interlinked Multi Value Mode where 4 channels can be updated simultaneously with 4 different duty cycle values. More...
 
static void pwma_wait_for_ready (volatile avr32_pwma_t *pwma)
 Wait for PWMA Module to be ready for writing. More...
 
bool pwma_write_top_value (volatile avr32_pwma_t *pwma, uint16_t top_value)
 Load TOP value. More...
 

#define PWMA_CHANNEL_LIMIT   4

void pwma_config_and_enable ( volatile avr32_pwma_t *  pwma,
unsigned long long int  channel_mask,
int  period_cycles,
int  duty_cycles 
)

Configure and enable the PWMA.

This function will enable the PWMA module and configure a mask of channels.

Parameters
pwmaPointer to the PWMA module.
channel_maskBit mask of channels to set period_cycles for.
period_cyclesPeriod cycles for the PWMA module, i.e. the TOP value (and eventually the SPREAD value).
duty_cyclesNumber of cycles for the active period for the channels provided by channel_mask.
Warning
This function is deprecated, please rather use pwma_config_enable() function.

References pwma_set_channels_value().

bool pwma_config_enable ( volatile avr32_pwma_t *  pwma,
uint32_t  pwma_freq_hz,
uint32_t  gclk_freq_hz,
uint16_t  spread 
)

Configure and enable the PWMA.

This function will enable the PWMA module and configure a mask of channels.

Parameters
pwmaPointer to the PWMA module.
pwma_freq_hzRequired PWMA frequency in hertz.
gclk_freq_hzGCLK_PWMA frequency in hertz.
spreadSpread value to be loaded.
Return values
PASSif configuration is successfully done.
FAILfor invalid arguments i.e. TOP or SPREAD exceed the limit value.

References div_ceil, FAIL, PASS, and pwma_wait_for_ready().

Referenced by demo_init_pwma(), init_pwm(), main(), and pwma_init().

static void pwma_disable ( volatile avr32_pwma_t *  pwma)
inlinestatic

Disable a PWMA module.

Parameters
pwmaPointer to the PWMA module.
bool pwma_set_channels_value ( volatile avr32_pwma_t *  pwma,
uint64_t  channel_mask,
uint16_t  duty_cycle 
)

Load the duty cycle value to the channels. This function uses Interlinked Single Value Mode where several channels are interlinked to allow multiple channels to be updated simultaneously with the same duty cycle value.

Parameters
pwmaPointer to the PWMA module.
channel_maskChannels for which the value should be loaded.
duty_cyclesNumber of cycles for the active period for the channels provided by channel_mask.
Return values
PASSif the duty cycle value is with in the limit.
FAILif the duty cycle value exceeds TOP [or] TOP-SPREAD.
Warning
The duty cycle value should be less than the TOP value(normal mode). If spread value is loaded, the duty cycle value should not exceed TOP-SPREAD.

References FAIL, PASS, and pwma_wait_for_ready().

Referenced by demo_automatic_ledshow_play(), demo_init_pwma(), emulate_light_switch(), init_pwm(), ISR(), pwma_config_and_enable(), pwma_init(), reset_leds(), set_all_leds(), and touch_handler().

bool pwma_set_multiple_values ( volatile avr32_pwma_t *  pwma,
uint32_t  channel_mask,
uint16_t *  channel_duty_cycles 
)

Load multiple duty cycle values to multiple channels. This function uses Interlinked Multi Value Mode where 4 channels can be updated simultaneously with 4 different duty cycle values.

Parameters
pwmaPointer to the PWMA module.
channel_maskChannels for which the value should be loaded.
channel_duty_cyclesPointer to an array of duty cycle values.
Return values
PASSif the duty cycle value is with in the limit.
FAILif the duty cycle value exceeds TOP [or] TOP-SPREAD.
Warning
The duty cycle value should be less than the TOP value(normal mode). If spread value is loaded, the duty cycle value should not exceed TOP-SPREAD.

References count, FAIL, PASS, PWMA_CHANNEL_LIMIT, and pwma_wait_for_ready().

Referenced by main(), play_auto_running_lights(), play_level_bar(), and process_wheel().

static void pwma_wait_for_ready ( volatile avr32_pwma_t *  pwma)
inlinestatic

Wait for PWMA Module to be ready for writing.

Parameters
pwmaPointer to the PWMA module.

Referenced by pwma_config_enable(), pwma_set_channels_value(), pwma_set_multiple_values(), and pwma_write_top_value().

bool pwma_write_top_value ( volatile avr32_pwma_t *  pwma,
uint16_t  top_value 
)

Load TOP value.

Parameters
pwmaPointer to the PWMA Module.
top_valueTOP value to be loaded.
Return values
PASSif the TOP value is within the limit.
FAILif the TOP value exceeds its maximum limit.

References FAIL, PASS, and pwma_wait_for_ready().