RTEMS  5.1
Functions
pwmc.c File Reference
#include "chip.h"
#include <stdint.h>
#include <assert.h>

Functions

void PWMC_ConfigureChannel (Pwm *pPwm, uint8_t channel, uint32_t prescaler, uint32_t alignment, uint32_t polarity)
 Configures PWM a channel with the given parameters, basic configure function. More...
 
void PWMC_ConfigureChannelExt (Pwm *pPwm, uint8_t channel, uint32_t prescaler, uint32_t alignment, uint32_t polarity, uint32_t countEventSelect, uint32_t DTEnable, uint32_t DTHInverte, uint32_t DTLInverte)
 Configures PWM a channel with the given parameters, extend configure function. The PWM controller must have been clocked in the PMC prior to calling this function. Beware: this function disables the channel. It waits until disable is effective. More...
 
void PWMC_ConfigureClocks (Pwm *pPwm, uint32_t clka, uint32_t clkb, uint32_t mck)
 Configures PWM clocks A & B to run at the given frequencies. More...
 
void PWMC_SetPeriod (Pwm *pPwm, uint8_t channel, uint16_t period)
 Sets the period value used by a PWM channel. More...
 
void PWMC_SetDutyCycle (Pwm *pPwm, uint8_t channel, uint16_t duty)
 Sets the duty cycle used by a PWM channel. This function writes directly to the CDTY register if the channel is disabled; otherwise it uses the update register CDTYUPD. Note that the duty cycle must always be inferior or equal to the channel period. More...
 
void PWMC_SetDeadTime (Pwm *pPwm, uint8_t channel, uint16_t timeH, uint16_t timeL)
 Sets the dead time used by a PWM channel. This function writes directly to the DT register if the channel is disabled; otherwise it uses the update register DTUPD. Note that the dead time must always be inferior or equal to the channel period. More...
 
void PWMC_ConfigureSyncChannel (Pwm *pPwm, uint32_t channels, uint32_t updateMode, uint32_t requestMode, uint32_t requestComparisonSelect)
 Configures Synchronous channel with the given parameters. Beware: At this time, the channels should be disabled. More...
 
void PWMC_SetSyncChannelUpdatePeriod (Pwm *pPwm, uint8_t period)
 Sets the update period of the synchronous channels. This function writes directly to the SCUP register if the channel #0 is disabled; otherwise it uses the update register SCUPUPD. More...
 
void PWMC_SetSyncChannelUpdateUnlock (Pwm *pPwm)
 Sets synchronous channels update unlock. More...
 
void PWMC_EnableChannel (Pwm *pPwm, uint8_t channel)
 Enables the given PWM channel. More...
 
void PWMC_DisableChannel (Pwm *pPwm, uint8_t channel)
 Disables the given PWM channel. More...
 
void PWMC_EnableChannelIt (Pwm *pPwm, uint8_t channel)
 Enables the period interrupt for the given PWM channel. More...
 
uint32_t PWMC_GetStatus2 (Pwm *pPwm)
 Return PWM Interrupt Status2 Register. More...
 
void PWMC_DisableChannelIt (Pwm *pPwm, uint8_t channel)
 Disables the period interrupt for the given PWM channel. More...
 
void PWMC_EnableIt (Pwm *pPwm, uint32_t sources1, uint32_t sources2)
 Enables the selected interrupts sources on a PWMC peripheral. More...
 
void PWMC_DisableIt (Pwm *pPwm, uint32_t sources1, uint32_t sources2)
 Disables the selected interrupts sources on a PWMC peripheral. More...
 
void PWMC_SetOverrideValue (Pwm *pPwm, uint32_t value)
 Set PWM output override value. More...
 
void PWMC_EnableOverrideOutput (Pwm *pPwm, uint32_t value, uint32_t sync)
 Enable override output. More...
 
void PWMC_OutputOverrideSelection (Pwm *pPwm, uint32_t value)
 Output Selection for override PWM output. More...
 
void PWMC_DisableOverrideOutput (Pwm *pPwm, uint32_t value, uint32_t sync)
 Disable override output. More...
 
void PWMC_SetFaultMode (Pwm *pPwm, uint32_t mode)
 Set PWM fault mode. More...
 
void PWMC_FaultClear (Pwm *pPwm, uint32_t fault)
 PWM fault clear. More...
 
void PWMC_SetFaultProtectionValue (Pwm *pPwm, uint32_t value)
 Set PWM fault protection value. More...
 
void PWMC_EnableFaultProtection (Pwm *pPwm, uint32_t value)
 Enable PWM fault protection. More...
 
void PWMC_ConfigureComparisonUnit (Pwm *pPwm, uint32_t x, uint32_t value, uint32_t mode)
 Configure comparison unit. More...
 
void PWMC_ConfigureEventLineMode (Pwm *pPwm, uint32_t x, uint32_t mode)
 Configure event line mode. More...
 

Detailed Description

Implementation of the Pulse Width Modulation Controller (PWM) peripheral.

Function Documentation

◆ PWMC_ConfigureChannel()

void PWMC_ConfigureChannel ( Pwm pPwm,
uint8_t  channel,
uint32_t  prescaler,
uint32_t  alignment,
uint32_t  polarity 
)

Configures PWM a channel with the given parameters, basic configure function.

The PWM controller must have been clocked in the PMC prior to calling this function. Beware: this function disables the channel. It waits until disable is effective.

Parameters
channelChannel number.
prescalerChannel prescaler.
alignmentChannel alignment.
polarityChannel polarity.

◆ PWMC_ConfigureChannelExt()

void PWMC_ConfigureChannelExt ( Pwm pPwm,
uint8_t  channel,
uint32_t  prescaler,
uint32_t  alignment,
uint32_t  polarity,
uint32_t  countEventSelect,
uint32_t  DTEnable,
uint32_t  DTHInverte,
uint32_t  DTLInverte 
)

Configures PWM a channel with the given parameters, extend configure function. The PWM controller must have been clocked in the PMC prior to calling this function. Beware: this function disables the channel. It waits until disable is effective.

Parameters
channelChannel number.
prescalerChannel prescaler.
alignmentChannel alignment.
polarityChannel polarity.
countEventSelectChannel counter event selection.
DTEnableChannel dead time generator enable.
DTHInverteChannel Dead-Time PWMHx output Inverted.
DTLInverteChannel Dead-Time PWMHx output Inverted.

◆ PWMC_ConfigureClocks()

void PWMC_ConfigureClocks ( Pwm pPwm,
uint32_t  clka,
uint32_t  clkb,
uint32_t  mck 
)

Configures PWM clocks A & B to run at the given frequencies.

This function finds the best MCK divisor and prescaler values automatically.

Parameters
clkaDesired clock A frequency (0 if not used).
clkbDesired clock B frequency (0 if not used).
mckMaster clock frequency.

◆ PWMC_ConfigureComparisonUnit()

void PWMC_ConfigureComparisonUnit ( Pwm pPwm,
uint32_t  x,
uint32_t  value,
uint32_t  mode 
)

Configure comparison unit.

Parameters
xcomparison x index
valuecomparison x value.
modecomparison x mode

◆ PWMC_ConfigureEventLineMode()

void PWMC_ConfigureEventLineMode ( Pwm pPwm,
uint32_t  x,
uint32_t  mode 
)

Configure event line mode.

Parameters
xLine x
modeBitwise OR of line mode selection

◆ PWMC_ConfigureSyncChannel()

void PWMC_ConfigureSyncChannel ( Pwm pPwm,
uint32_t  channels,
uint32_t  updateMode,
uint32_t  requestMode,
uint32_t  requestComparisonSelect 
)

Configures Synchronous channel with the given parameters. Beware: At this time, the channels should be disabled.

Parameters
channelsBitwise OR of Synchronous channels.
updateModeSynchronous channel update mode.
requestModePDC transfer request mode.
requestComparisonSelectPDC transfer request comparison selection.

◆ PWMC_DisableChannel()

void PWMC_DisableChannel ( Pwm pPwm,
uint8_t  channel 
)

Disables the given PWM channel.

Beware, channel will be effectively disabled at the end of the current period. Application can check channel is disabled using the following wait loop: while ((PWM->PWM_SR & (1 << channel)) != 0);

Parameters
channelChannel number.

◆ PWMC_DisableChannelIt()

void PWMC_DisableChannelIt ( Pwm pPwm,
uint8_t  channel 
)

Disables the period interrupt for the given PWM channel.

Parameters
channelChannel number.

◆ PWMC_DisableIt()

void PWMC_DisableIt ( Pwm pPwm,
uint32_t  sources1,
uint32_t  sources2 
)

Disables the selected interrupts sources on a PWMC peripheral.

Parameters
sources1Bitwise OR of selected interrupt sources of PWM_IDR1.
sources2Bitwise OR of selected interrupt sources of PWM_IDR2.

◆ PWMC_DisableOverrideOutput()

void PWMC_DisableOverrideOutput ( Pwm pPwm,
uint32_t  value,
uint32_t  sync 
)

Disable override output.

Parameters
valueBitwise OR of output selection.
sync0: enable the output asynchronously, 1: enable it synchronously

◆ PWMC_EnableChannel()

void PWMC_EnableChannel ( Pwm pPwm,
uint8_t  channel 
)

Enables the given PWM channel.

This does NOT enable the corresponding pin;this must be done in the user code.

Parameters
channelChannel number.

◆ PWMC_EnableChannelIt()

void PWMC_EnableChannelIt ( Pwm pPwm,
uint8_t  channel 
)

Enables the period interrupt for the given PWM channel.

Parameters
channelChannel number.

◆ PWMC_EnableFaultProtection()

void PWMC_EnableFaultProtection ( Pwm pPwm,
uint32_t  value 
)

Enable PWM fault protection.

Parameters
valueBitwise OR of FPEx[y].

◆ PWMC_EnableIt()

void PWMC_EnableIt ( Pwm pPwm,
uint32_t  sources1,
uint32_t  sources2 
)

Enables the selected interrupts sources on a PWMC peripheral.

Parameters
sources1Bitwise OR of selected interrupt sources of PWM_IER1.
sources2Bitwise OR of selected interrupt sources of PWM_IER2.

◆ PWMC_EnableOverrideOutput()

void PWMC_EnableOverrideOutput ( Pwm pPwm,
uint32_t  value,
uint32_t  sync 
)

Enable override output.

Parameters
valueBitwise OR of output selection.
sync0: enable the output asynchronously, 1: enable it synchronously

◆ PWMC_FaultClear()

void PWMC_FaultClear ( Pwm pPwm,
uint32_t  fault 
)

PWM fault clear.

Parameters
faultBitwise OR of fault to clear.

◆ PWMC_GetStatus2()

uint32_t PWMC_GetStatus2 ( Pwm pPwm)

Return PWM Interrupt Status2 Register.

◆ PWMC_OutputOverrideSelection()

void PWMC_OutputOverrideSelection ( Pwm pPwm,
uint32_t  value 
)

Output Selection for override PWM output.

Parameters
valueBitwise OR of output override value.

◆ PWMC_SetDeadTime()

void PWMC_SetDeadTime ( Pwm pPwm,
uint8_t  channel,
uint16_t  timeH,
uint16_t  timeL 
)

Sets the dead time used by a PWM channel. This function writes directly to the DT register if the channel is disabled; otherwise it uses the update register DTUPD. Note that the dead time must always be inferior or equal to the channel period.

Parameters
channelChannel number.
timeHDead time value for PWMHx output.
timeLDead time value for PWMLx output.

◆ PWMC_SetDutyCycle()

void PWMC_SetDutyCycle ( Pwm pPwm,
uint8_t  channel,
uint16_t  duty 
)

Sets the duty cycle used by a PWM channel. This function writes directly to the CDTY register if the channel is disabled; otherwise it uses the update register CDTYUPD. Note that the duty cycle must always be inferior or equal to the channel period.

Parameters
channelChannel number.
dutyDuty cycle value.

◆ PWMC_SetFaultMode()

void PWMC_SetFaultMode ( Pwm pPwm,
uint32_t  mode 
)

Set PWM fault mode.

Parameters
modeBitwise OR of fault mode.

◆ PWMC_SetFaultProtectionValue()

void PWMC_SetFaultProtectionValue ( Pwm pPwm,
uint32_t  value 
)

Set PWM fault protection value.

Parameters
valueBitwise OR of fault protection value.

◆ PWMC_SetOverrideValue()

void PWMC_SetOverrideValue ( Pwm pPwm,
uint32_t  value 
)

Set PWM output override value.

Parameters
valueBitwise OR of output override value.

◆ PWMC_SetPeriod()

void PWMC_SetPeriod ( Pwm pPwm,
uint8_t  channel,
uint16_t  period 
)

Sets the period value used by a PWM channel.

This function writes directly to the CPRD register if the channel is disabled; otherwise, it uses the update register CPRDUPD.

Parameters
channelChannel number.
periodPeriod value.

◆ PWMC_SetSyncChannelUpdatePeriod()

void PWMC_SetSyncChannelUpdatePeriod ( Pwm pPwm,
uint8_t  period 
)

Sets the update period of the synchronous channels. This function writes directly to the SCUP register if the channel #0 is disabled; otherwise it uses the update register SCUPUPD.

Parameters
periodupdate period.

◆ PWMC_SetSyncChannelUpdateUnlock()

void PWMC_SetSyncChannelUpdateUnlock ( Pwm pPwm)

Sets synchronous channels update unlock.

Note: If the UPDM field is set to 0, writing the UPDULOCK bit to 1 triggers the update of the period value, the duty-cycle and the dead-time values of synchronous channels at the beginning of the next PWM period. If the field UPDM is set to 1 or 2, writing the UPDULOCK bit to 1 triggers only the update of the period value and of the dead-time values of synchronous channels. This bit is automatically reset when the update is done.