Actions

EmSys

Tm4clib-pwm-functions

From EdWiki

Revision as of 06:23, 27 December 2018 by Jshankar (Talk | contribs) (pwm_gen_get_fault_status())

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PWM API Functions

Detailed Description

These functions perform high-level operations on PWM modules.

The following functions provide the user with a way to configure the PWM for the most common operations, such as setting the period, generating left- and center-aligned pulses, modifying the pulse width, and controlling interrupts, triggers, and output characteristics. However, the PWM module is very versatile and can be configured in a number of different ways, many of which are beyond the scope of this API. In order to fully exploit the many features of the PWM module, users are advised to use register access macros.

When discussing the various components of a PWM module, this API uses the following labeling convention:

  • The generator blocks are called Gen0, Gen1, Gen2 and Gen3.
  • The two PWM output signals associated with each generator block are called OutA and OutB.
  • The output signals are called PWM0, PWM1, PWM2, PWM3, PWM4, PWM5, PWM6 and PWM7.
  • PWM0 and PWM1 are associated with Gen0, PWM2 and PWM3 are associated with Gen1, PWM4 and PWM5 are associated with Gen2 and PWM6 and PWM7 are associated with Gen3.

Also, as a simplifying assumption for this API, comparator A for each generator block is used exclusively to adjust the pulse width of the even numbered PWM outputs (PWM0, PWM2, PWM4 and PWM6). In addition, comparator B is used exclusively for the odd numbered PWM outputs (PWM1, PWM3, PWM5 and PWM7).

Note that the number of generators and PWM outputs supported varies depending upon the Tiva part in use. Please consult the datasheet for the part you are using to determine whether it supports 1 or 2 modules with 3 or 4 generators each and 6 or 8 outputs each.

pwm_gen_enable()

Enables the timer/counter for a PWM generator block.

Prototype:
void pwm_gen_enable(uint32_t ui32Base, uint32_t ui32Gen)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to be enabled. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
Description:
This function allows the PWM clock to drive the timer/counter for the specified generator block.
Returns: None.

pwm_gen_disable()

Disables the timer/counter for a PWM generator block.

Prototype:
void pwm_gen_disable(uint32_t ui32Base, uint32_t ui32Gen)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to be disabled. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
Description:
This function blocks the PWM clock from driving the timer/counter for the specified generator block.
Returns: None.

pwm_dead_band_disable()

Disables the PWM dead band output.

Prototype:
void pwm_dead_band_disable(uint32_t ui32Base, uint32_t ui32Gen)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to modify. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
Description:
This function disables the dead band mode for the specified PWM generator. Doing so decouples the OutA and OutB signals.
Returns: None.

pwm_sync_update()

Synchronizes all pending updates.

Prototype:
void pwm_sync_update(uint32_t ui32Base, uint32_t ui32GenBits)
Parameters:
ui32Base is the base address of the PWM module. ui32GenBits are the PWM generator blocks to be updated. This parameter must be the logical OR of any of PWM_GEN_0_BIT, PWM_GEN_1_BIT, PWM_GEN_2_BIT, or PWM_GEN_3_BIT.
Description:
For the selected PWM generators, this function causes all queued updates to the period or pulse width to be applied the next time the corresponding counter becomes zero.
Returns: None.

pwm_sync_time_base()

Synchronizes the counters in one or multiple PWM generator blocks.

Prototype:
void pwm_sync_time_base(uint32_t ui32Base, uint32_t ui32GenBits)
Parameters:
ui32Base is the base address of the PWM module.
ui32GenBits are the PWM generator blocks to be synchronized. This parameter must be the logical OR of any of PWM_GEN_0_BIT, PWM_GEN_1_BIT, PWM_GEN_2_BIT, or PWM_GEN_3_BIT. Description:
For the selected PWM module, this function synchronizes the time base of the generator blocks by causing the specified generator counters to be reset to zero.
Returns: None.

pwm_gen_enable_int_trig()

Enables interrupts and triggers for the specified PWM generator block.

Prototype: void pwm_gen_enable_int_trig(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to have interrupts and triggers enabled. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32IntTrig specifies the interrupts and triggers to be enabled.
Description:
This function unmasks the specified interrupt(s) and trigger(s) by setting the specified bits of the interrupt/trigger enable register for the specified PWM generator. The ui32IntTrig parameter is the logical OR of PWM_INT_CNT_ZERO, PWM_INT_CNT_LOAD, PWM_INT_CNT_AU, PWM_INT_CNT_AD, PWM_INT_CNT_BU, PWM_INT_CNT_BD, PWM_TR_CNT_ZERO, PWM_TR_CNT_LOAD, PWM_TR_CNT_AU, PWM_TR_CNT_AD, PWM_TR_CNT_BU, or PWM_TR_CNT_BD.
Returns: None.

pwm_gen_disable_int_trig()

Disables interrupts for the specified PWM generator block.

Prototype: void pwm_gen_disable_int_trig(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32IntTrig)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to have interrupts and triggers disabled. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32IntTrig specifies the interrupts and triggers to be disabled.
Description:
This function masks the specified interrupt(s) and trigger(s) by clearing the specified bits of the interrupt/trigger enable register for the specified PWM generator. The ui32IntTrig parameter is the logical OR of PWM_INT_CNT_ZERO, PWM_INT_CNT_LOAD, PWM_INT_CNT_AU, PWM_INT_CNT_AD, PWM_INT_CNT_BU, PWM_INT_CNT_BD, PWM_TR_CNT_ZERO, PWM_TR_CNT_LOAD, PWM_TR_CNT_AU, PWM_TR_CNT_AD, PWM_TR_CNT_BU, or PWM_TR_CNT_BD.
Returns: None.

pwm_gen_get_int_status()

Gets interrupt status for the specified PWM generator block.

Prototype: uint32_t pwm_gen_get_int_status(uint32_t ui32Base, uint32_t ui32Gen, bool bMasked)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to query. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
bMasked specifies whether masked or raw interrupt status is returned.
Description:
If bMasked is set as true, then the masked interrupt status is returned; otherwise, the raw interrupt status is returned.
Returns: Returns the contents of the interrupt status register or the contents of the raw interrupt status register for the specified PWM generator.

pwm_gen_clear_int()

Clears the specified interrupt(s) for the specified PWM generator block.

Prototype:
void pwm_gen_clear_int(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Ints)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to query. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Ints specifies the interrupts to be cleared.
Description:
This function clears the specified interrupt(s) by writing a 1 to the specified bits of the interrupt status register for the specified PWM generator. The ui32Ints parameter is the logical OR of PWM_INT_CNT_ZERO, PWM_INT_CNT_LOAD, PWM_INT_CNT_AU, PWM_INT_CNT_AD, PWM_INT_CNT_BU or PWM_INT_CNT_BD.
Note:
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns: None

pwm_enable_int()

Enables generator and fault interrupts for a PWM module.

Prototype: void pwm_enable_int(uint32_t ui32Base, uint32_t ui32GenFault)
Parameters:
ui32Base is the base address of the PWM module.
ui32GenFault contains the interrupts to be enabled. This parameter must be a logical OR of any of PWM_GEN_1, PWM_GEN_2, PWM_GEN_3, PWM_INT_FAULT0, PWM_INT_FAULT1, PWM_INT_FAULT2, or PWM_INT_FAULT3.
Description:
This function unmasks the specified interrupt(s) by setting the specified bits of the interrupt enable register for the selected PWM module.
Returns: None.

pwm_disable_int()

Disables generator and fault interrupts for a PWM module.

Prototype:
void pwm_disable_int(uint32_t ui32Base, uint32_t ui32GenFault)
Parameters:
ui32Base is the base address of the PWM module.
ui32GenFault contains the interrupts to be disabled. This parameter must be a logical OR of any of PWM_GEN_1, PWM_GEN_2, PWM_GEN_3, PWM_INT_FAULT0, PWM_INT_FAULT1, PWM_INT_FAULT2, or PWM_INT_FAULT3.
Description:
This function masks the specified interrupt(s) by clearing the specified bits of the interrupt enable register for the selected PWM module.
Returns: None.

pwm_clear_fault_int()

Clears the fault interrupt for a PWM module.

Prototype: void pwm_clear_fault_int(uint32_t ui32Base)
Parameters:
ui32Base is the base address of the PWM module.
Description: This function clears the fault interrupt by writing to the appropriate bit of the interrupt status register for the selected PWM module.

This function clears only the FAULT0 interrupt and is retained for backwards compatibility. It is recommended that pwm_clear_fault_int_ext() be used instead because it supports all fault interrupts supported on devices with and without extended PWM fault handling support.
Note:
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns: None.

pwm_get_int_status()

Gets the interrupt status for a PWM module.

Prototype:
uint32_t pwm_get_int_status(uint32_t ui32Base, bool bMasked)
Parameters:
ui32Base is the base address of the PWM module.
bMasked specifies whether masked or raw interrupt status is returned.
Description:
If bMasked is set as true, then the masked interrupt status is returned; otherwise, the raw interrupt status is returned.
Returns: The current interrupt status, enumerated as a bit field of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, PWM_GEN_3, PWM_INT_FAULT0, PWM_INT_FAULT1, PWM_INT_FAULT2, or PWM_INT_FAULT3.

pwm_clear_fault_int_ext()

Clears the fault interrupt for a PWM module.

Prototype:
void pwm_clear_fault_int_ext(uint32_t ui32Base, uint32_t ui32FaultInts)
Parameters:
ui32Base is the base address of the PWM module.
ui32FaultInts specifies the fault interrupts to clear.
Description:
This function clears one or more fault interrupts by writing to the appropriate bit of the PWM interrupt status register. The parameter ui32FaultInts must be the logical OR of any of PWM_INT_FAULT0, PWM_INT_FAULT1, PWM_INT_FAULT2, or PWM_INT_FAULT3.

The fault interrupts are derived by performing a logical OR of each of the configured fault trigger signals for a given generator. Therefore, these interrupts are not directly related to the four possible FAULTn inputs to the device but indicate that a fault has been signaled to one of the four possible PWM generators.
Note:
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns: None

pwm_gen_configure()

Configures a PWM generator.

Prototype: void pwm_gen_configure(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Config)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to configure. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Config is the configuration for the PWM generator.
Description:
This function is used to set the mode of operation for a PWM generator. The counting mode, synchronization mode, and debug behavior are all configured. After configuration, the generator is left in the disabled state.

A PWM generator can count in two different modes: count down mode or count up/down mode. In count down mode, it counts from a value down to zero, and then resets to the preset value, producing left-aligned PWM signals (that is, the rising edge of the two PWM signals produced by the generator occur at the same time). In count up/down mode, it counts up from zero to the preset value, counts back down to zero, and then repeats the process, producing centeraligned PWM signals (that is, the middle of the high/low period of the PWM signals produced by the generator occurs at the same time).

When the PWM generator parameters (period and pulse width) are modified, their effect on the output PWM signals can be delayed. In synchronous mode, the parameter updates are not applied until a synchronization event occurs. This mode allows multiple parameters to be modified and take effect simultaneously, instead of one at a time. Additionally, parameters to multiple PWM generators in synchronous mode can be updated simultaneously, allowing them to be treated as if they were a unified generator. In non-synchronous mode, the parameter updates are not delayed until a synchronization event. In either mode, the parameter updates only occur when the counter is at zero to help prevent oddly formed PWM signals during the update (that is, a PWM pulse that is too short or too long).

The PWM generator can either pause or continue running when the processor is stopped via the debugger. If configured to pause, it continues to count until it reaches zero, at which point it pauses until the processor is restarted. If configured to continue running, it keeps counting as if nothing had happened.

The ui32Config parameter contains the desired configuration. It is the logical OR of the following:

Setting PWM_GEN_MODE_FAULT_MINPER allows an application to set the minimum duration of a PWM fault signal. Faults are signaled for at least this time even if the external fault pin deasserts earlier. Care should be taken when using this mode because during the fault signal period, the fault interrupt from the PWM generator remains asserted. The fault interrupt handler may, therefore, reenter immediately if it exits prior to expiration of the fault timer.
Note:
Changes to the counter mode affect the period of the PWM signals produced. pwm_gen_set_period() and pwm_set_pulse_width() should be called after any changes to the counter mode of a generator.
Returns: None.

pwm_gen_set_period()

Sets the period of a PWM generator.

Prototype:
void pwm_gen_set_period(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Period)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to be modified. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Period specifies the period of PWM generator output, measured in clock ticks.
Description:
This function sets the period of the specified PWM generator block, where the period of the generator block is defined as the number of PWM clock ticks between pulses on the generator block zero signal.
Note:
Any subsequent calls made to this function before an update occurs cause the previous values to be overwritten.
Returns: None.

pwm_gen_get_period()

Gets the period of a PWM generator block.

Prototype:
uint32_t pwm_gen_get_period(uint32_t ui32Base, uint32_t ui32Gen)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to query. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3. Description:
This function gets the period of the specified PWM generator block. The period of the generator block is defined as the number of PWM clock ticks between pulses on the generator block zero signal.

If the update of the counter for the specified PWM generator has yet to be completed, the value returned may not be the active period. The value returned is the programmed period, measured in PWM clock ticks.
Returns:
Returns the programmed period of the specified generator block in PWM clock ticks.

pwm_set_pulse_width()

Sets the pulse width for the specified PWM output.

Prototype: void pwm_set_pulse_width(uint32_t ui32Base, uint32_t ui32PWMOut, uint32_t ui32Width)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOut is the PWM output to modify. This parameter must be one of PWM_OUT_0, PWM_OUT_1, PWM_OUT_2, PWM_OUT_3, PWM_OUT_4, PWM_OUT_5, PWM_OUT_6, or PWM_OUT_7.
ui32Width specifies the width of the positive portion of the pulse.
Description:
This function sets the pulse width for the specified PWM output, where the pulse width is defined as the number of PWM clock ticks.
Note:
Any subsequent calls made to this function before an update occurs cause the previous values to be overwritten.
Returns: None

pwm_get_pulse_width()

Gets the pulse width of a PWM output.

Prototype:
uint32_t pwm_get_pulse_width(uint32_t ui32Base, uint32_t ui32PWMOut)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOut is the PWM output to query. This parameter must be one of PWM_OUT_0, PWM_OUT_1, PWM_OUT_2, PWM_OUT_3, PWM_OUT_4, PWM_OUT_5, PWM_OUT_6, or PWM_OUT_7.
Description:
This function gets the currently programmed pulse width for the specified PWM output. If the update of the comparator for the specified output has yet to be completed, the value returned may not be the active pulse width. The value returned is the programmed pulse width, measured in PWM clock ticks.
Returns: Returns the width of the pulse in PWM clock ticks.

pwm_dead_band_enable()

Enables the PWM dead band output and sets the dead band delays.

Prototype:
void pwm_dead_band_enable(uint32_t ui32Base, uint32_t ui32Gen, uint16_t ui16Rise, uint16_t ui16Fall)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator to modify. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui16Rise specifies the width of delay from the rising edge.
ui16Fall specifies the width of delay from the falling edge.
Description:
This function sets the dead bands for the specified PWM generator, where the dead bands are defined as the number of PWM clock ticks from the rising or falling edge of the generator’s OutA signal. Note that this function causes the coupling of OutB to OutA.
Returns: None.

pwm_output_state()

Enables or disables PWM outputs.

Prototype:
void pwm_output_state(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bEnable)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOutBits are the PWM outputs to be modified. This parameter must be the logical OR of any of PWM_OUT_0_BIT, PWM_OUT_1_BIT, PWM_OUT_2_BIT, PWM_OUT_3_BIT, PWM_OUT_4_BIT, PWM_OUT_5_BIT, PWM_OUT_6_BIT, or PWM_OUT_7_BIT.
bEnable determines if the signal is enabled or disabled.
Description:
This function enables or disables the selected PWM outputs. The outputs are selected using the parameter ui32PWMOutBits. The parameter bEnable determines the state of the selected outputs. If bEnable is true, then the selected PWM outputs are enabled, or placed in the active state. If bEnable is false, then the selected outputs are disabled or placed in the inactive state.
Returns: None.

pwm_output_invert()

Selects the inversion mode for PWM outputs.

Prototype:
void pwm_output_invert(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bInvert)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOutBits are the PWM outputs to be modified. This parameter must be the logical OR of any of PWM_OUT_0_BIT, PWM_OUT_1_BIT, PWM_OUT_2_BIT, PWM_OUT_3_BIT, PWM_OUT_4_BIT, PWM_OUT_5_BIT, PWM_OUT_6_BIT, or PWM_OUT_7_BIT.
bInvert determines if the signal is inverted or passed through.
Description:
This function is used to select the inversion mode for the selected PWM outputs. The outputs are selected using the parameter ui32PWMOutBits. The parameter bInvert determines the inversion mode for the selected outputs. If bInvert is true, this function causes the specified PWM output signals to be inverted or made active low. If bInvert is false, the specified outputs are passed through as is or made active high.
Returns: None

pwm_output_fault_level()

Specifies the level of PWM outputs suppressed in response to a fault condition.

Prototype: void pwm_output_fault_level(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bDriveHigh)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOutBits are the PWM outputs to be modified. This parameter must be the logical OR of any of PWM_OUT_0_BIT, PWM_OUT_1_BIT, PWM_OUT_2_BIT, PWM_OUT_3_BIT, PWM_OUT_4_BIT, PWM_OUT_5_BIT, PWM_OUT_6_BIT, or PWM_OUT_7_BIT.
bDriveHigh determines if the signal is driven high or low during an active fault condition.
Description:
This function determines whether a PWM output pin that is suppressed in response to a fault condition is driven high or low. The affected outputs are selected using the parameter ui32PWMOutBits. The parameter bDriveHigh determines the output level for the pins identified by ui32PWMOutBits. If bDriveHigh is true then the selected outputs are driven high when a fault is detected. If it is false, the pins are driven low.

In a fault condition, pins which have not been configured to be suppressed via a call to pwm_output_fault() are unaffected by this function.
Note:
This function is available only on devices which support extended PWM fault handling.
Returns: None.

pwm_output_fault()

Specifies the state of PWM outputs in response to a fault condition.

Prototype: void pwm_output_fault(uint32_t ui32Base, uint32_t ui32PWMOutBits, bool bFaultSuppress)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOutBits are the PWM outputs to be modified. This parameter must be the logical OR of any of PWM_OUT_0_BIT, PWM_OUT_1_BIT, PWM_OUT_2_BIT, PWM_OUT_3_BIT, PWM_OUT_4_BIT, PWM_OUT_5_BIT, PWM_OUT_6_BIT, or PWM_OUT_7_BIT.
bFaultSuppress determines if the signal is suppressed or passed through during an active fault condition.
Description:
This function sets the fault handling characteristics of the selected PWM outputs. The outputs are selected using the parameter ui32PWMOutBits. The parameter bFaultSuppress determines the fault handling characteristics for the selected outputs. If bFaultSuppress is true, then the selected outputs are made inactive. If bFaultSuppress is false, then the selected outputs are unaffected by the detected fault.

On devices supporting extended PWM fault handling, the state the affected output pins are driven to can be configured with pwm_output_fault_level(). If not configured, or if the device does not support extended PWM fault handling, affected outputs are driven low on a fault condition.
Returns: None.

pwm_gen_configure_fault()

Configures the minimum fault period and fault pin senses for a given PWM generator.

Prototype: void pwm_gen_configure_fault(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32MinFaultPeriod, uint32_t ui32FaultSenses)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator for which fault configuration is being set. This function must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32MinFaultPeriod is the minimum fault active period expressed in PWM clock cycles.
ui32FaultSenses indicates which sense of each FAULT input should be considered the “asserted” state. Valid values are logical OR combinations of PWM_FAULTn_SENSE_HIGH and PWM_FAULTn_SENSE_LOW.
Description:
This function configures the minimum fault period for a given generator along with the sense of each of the 4 possible fault inputs. The minimum fault period is expressed in PWM clock cycles and takes effect only if pwm_gen_configure() is called with flag PWM_GEN_MODE_FAULT_PER set in the ui32Config parameter. When a fault input is asserted, the minimum fault period timer ensures that it remains asserted for at least the number of clock cycles specified.
Note:
This function is only available on devices supporting extended PWM fault handling.
Returns: None.

pwm_gen_set_fault_trigger()

Configures the set of fault triggers for a given PWM generator.

Prototype: void pwm_gen_set_fault_trigger(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator for which fault triggers are being set. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Group indicates the subset of possible faults that are to be configured. This parameter must be PWM_FAULT_GROUP_0 or PWM_FAULT_GROUP_1.
ui32FaultTriggers defines the set of inputs that are to contribute towards generation of the fault signal to the given PWM generator. For PWM_FAULT_GROUP_0, this is the logical OR of PWM_FAULT_FAULT0, PWM_FAULT_FAULT1, PWM_FAULT_FAULT2, or PWM_FAULT_FAULT3. For PWM_FAULT_GROUP_1, this is the logical OR of PWM_FAULT_DCMP0, PWM_FAULT_DCMP1, PWM_FAULT_DCMP2, PWM_FAULT_DCMP3, PWM_FAULT_DCMP4, PWM_FAULT_DCMP5, PWM_FAULT_DCMP6, or PWM_FAULT_DCMP7.
Description:
This function allows selection of the set of fault inputs that is combined to generate a fault condition to a given PWM generator. By default, all generators use only FAULT0 (for backwards compatibility) but if pwm_gen_configure() is called with flag PWM_GEN_MODE_FAULT_SRC in the ui32Config parameter, extended fault handling is enabled and this function must be called to configure the fault triggers.

The fault signal to the PWM generator is generated by ORing together each of the signals specified in the ui32FaultTriggers parameter after having adjusted the sense of each FAULTn input based on the configuration previously set using a call to pwm_gen_configure_fault().
Note:
This function is only available on devices supporting extended PWM fault handling.
Returns: None.

pwm_gen_get_fault_trigger()

Returns the set of fault triggers currently configured for a given PWM generator.

Prototype: uint32_t pwm_gen_get_fault_trigger(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator for which fault triggers are being queried. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Group indicates the subset of faults that are being queried. This parameter must be PWM_FAULT_GROUP_0 or PWM_FAULT_GROUP_1.
Description:
This function allows an application to query the current set of inputs that contribute to the generation of a fault condition to a given PWM generator.
Note:
This function is only available on devices supporting extended PWM fault handling.
Returns: Returns the current fault triggers configured for the fault group provided. For PWM_FAULT_GROUP_0, the returned value is a logical OR of PWM_FAULT_FAULT0, PWM_FAULT_FAULT1, PWM_FAULT_FAULT2, or PWM_FAULT_FAULT3. For PWM_FAULT_GROUP_1, the return value is the logical OR of PWM_FAULT_DCMP0, PWM_FAULT_DCMP1, PWM_FAULT_DCMP2, PWM_FAULT_DCMP3, PWM_FAULT_DCMP4, PWM_FAULT_DCMP5, PWM_FAULT_DCMP6, or PWM_FAULT_DCMP7.

pwm_gen_get_fault_status()

Returns the current state of the fault triggers for a given PWM generator.

Prototype:
uint32_t pwm_gen_get_fault_status(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator for which fault trigger states are being queried. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Group indicates the subset of faults that are being queried. This parameter must be PWM_FAULT_GROUP_0 or PWM_FAULT_GROUP_1.
Description:
This function allows an application to query the current state of each of the fault trigger inputs to a given PWM generator. The current state of each fault trigger input is returned unless pwm_gen_configure() has previously been called with flag PWM_GEN_MODE_FAULT_LATCHED in the ui32Config parameter, in which case the returned status is the latched fault trigger status. If latched faults are configured, the application must call pwm_gen_clear_fault() to clear each trigger.
Note:
This function is only available on devices supporting extended PWM fault handling.
Returns:
Returns the current state of the fault triggers for the given PWM generator. A set bit indicates that the associated trigger is active. For PWM_FAULT_GROUP_0, the returned value is a logical OR of PWM_FAULT_FAULT0, PWM_FAULT_FAULT1, PWM_FAULT_FAULT2, or PWM_FAULT_FAULT3. For PWM_FAULT_DCMP0, PWM_FAULT_DCMP1, PWM_FAULT_DCMP2, PWM_FAULT_DCMP3, PWM_FAULT_DCMP4, PWM_FAULT_DCMP5, PWM_FAULT_DCMP6, or PWM_FAULT_DCMP7.

pwm_gen_clear_fault()

Clears one or more latched fault triggers for a given PWM generator.

Prototype:
void pwm_gen_clear_fault(uint32_t ui32Base, uint32_t ui32Gen, uint32_t ui32Group, uint32_t ui32FaultTriggers)
Parameters:
ui32Base is the base address of the PWM module.
ui32Gen is the PWM generator for which fault trigger states are being queried. This parameter must be one of PWM_GEN_0, PWM_GEN_1, PWM_GEN_2, or PWM_GEN_3.
ui32Group indicates the subset of faults that are being queried. This parameter must be PWM_FAULT_GROUP_0 or PWM_FAULT_GROUP_1.
ui32FaultTriggers is the set of fault triggers which are to be cleared.
Description:
This function allows an application to clear the fault triggers for a given PWM generator. This function is only required if pwm_gen_configure() has previously been called with flag PWM_GEN_MODE_FAULT_LATCHED in parameter ui32Config.
Note:
This function is only available on devices supporting extended PWM fault handling.
Returns: None.

pwm_output_update_mode()

Sets the update mode or synchronization mode to the PWM outputs.

Prototype:
void pwm_output_update_mode(uint32_t ui32Base, uint32_t ui32PWMOutBits, uint32_t ui32Mode)
Parameters:
ui32Base is the base address of the PWM module.
ui32PWMOutBits are the PWM outputs to be modified. This parameter must be the logical OR of any of PWM_OUT_0_BIT, PWM_OUT_1_BIT, PWM_OUT_2_BIT, PWM_OUT_3_BIT, PWM_OUT_4_BIT, PWM_OUT_5_BIT, PWM_OUT_6_BIT, or PWM_OUT_7_BIT.
ui32Mode specifies the enable update mode to use when enabling or disabling PWM outputs.
Description:
This function sets one of three possible update modes to enable or disable the requested PWM outputs. The ui32Mode parameter controls when changes made via calls to pwm_output_state() take effect. Possible values are:
PWM_OUTPUT_MODE_NO_SYNC, which enables/disables changes to take effect immediately. PWM_OUTPUT_MODE_SYNC_LOCAL, which causes changes to take effect when the local PWM generator’s count next reaches 0. PWM_OUTPUT_MODE_SYNC_GLOBAL, which causes changes to take effect when the local PWM generator’s count next reaches 0 following a call to pwm_sync_update() which specifies the same generator in its ui32GenBits parameter.
Note:
This function is only available on Snowflake class devices.
Returns: None