S32 SDK
FTM Pulse Width Modulation Driver

Detailed Description

FlexTimer Peripheral Pulse Width Modulation Driver.

Data Structures

struct  ftm_pwm_ch_fault_param_t
 FlexTimer driver PWM Fault channel parameters. More...
 
struct  ftm_pwm_fault_param_t
 FlexTimer driver PWM Fault parameter. More...
 
struct  ftm_independent_ch_param_t
 FlexTimer driver independent PWM parameter. More...
 
struct  ftm_combined_ch_param_t
 FlexTimer driver combined PWM parameter. More...
 
struct  ftm_pwm_param_t
 FlexTimer driver PWM parameters. More...
 

Macros

#define FTM_MAX_DUTY_CYCLE   (0x8000U)
 Maximum value for PWM duty cycle. More...
 
#define FTM_DUTY_TO_TICKS_SHIFT   (15U)
 Shift value which converts duty to ticks. More...
 

Enumerations

enum  ftm_pwm_update_option_t { FTM_PWM_UPDATE_IN_DUTY_CYCLE = 0x00U, FTM_PWM_UPDATE_IN_TICKS = 0x01U }
 FlexTimer Configure type of PWM update in the duty cycle or in ticks. More...
 

Functions

status_t FTM_DRV_DeinitPwm (uint32_t instance)
 Stops all PWM channels . More...
 
status_t FTM_DRV_InitPwm (uint32_t instance, const ftm_pwm_param_t *param)
 Configures the duty cycle and frequency and starts outputting the PWM on all channels configured in param. More...
 
status_t FTM_DRV_UpdatePwmChannel (uint32_t instance, uint8_t channel, ftm_pwm_update_option_t typeOfUpdate, uint16_t firstEdge, uint16_t secondEdge, bool softwareTrigger)
 This function updates the waveform output in PWM mode (duty cycle and phase). More...
 
status_t FTM_DRV_FastUpdatePwmChannels (uint32_t instance, uint8_t numberOfChannels, const uint8_t *channels, const uint16_t *duty, bool softwareTrigger)
 This function will update the duty cycle of PWM output for multiple channels. More...
 
status_t FTM_DRV_UpdatePwmPeriod (uint32_t instance, ftm_pwm_update_option_t typeOfUpdate, uint32_t newValue, bool softwareTrigger)
 This function will update the new period in the frequency or in the counter value into mode register which modify the period of PWM signal on the channel output. More...
 

Macro Definition Documentation

#define FTM_DUTY_TO_TICKS_SHIFT   (15U)

Shift value which converts duty to ticks.

Definition at line 44 of file ftm_pwm_driver.h.

#define FTM_MAX_DUTY_CYCLE   (0x8000U)

Maximum value for PWM duty cycle.

Definition at line 42 of file ftm_pwm_driver.h.

Enumeration Type Documentation

FlexTimer Configure type of PWM update in the duty cycle or in ticks.

Implements : ftm_pwm_update_option_t_Class

Enumerator
FTM_PWM_UPDATE_IN_DUTY_CYCLE 

The type of PWM update in the duty cycle/pulse or also use in frequency update

FTM_PWM_UPDATE_IN_TICKS 

The type of PWM update in ticks

Definition at line 51 of file ftm_pwm_driver.h.

Function Documentation

status_t FTM_DRV_DeinitPwm ( uint32_t  instance)

Stops all PWM channels .

Parameters
[in]instanceThe FTM peripheral instance number.
Returns
counter the current counter value

Definition at line 241 of file ftm_pwm_driver.c.

status_t FTM_DRV_FastUpdatePwmChannels ( uint32_t  instance,
uint8_t  numberOfChannels,
const uint8_t *  channels,
const uint16_t *  duty,
bool  softwareTrigger 
)

This function will update the duty cycle of PWM output for multiple channels.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]numberOfChannelsThe number of channels which should be updated.
[in]channelsThe list of channels which should be updated.
[in]dutyThe list of duty cycles for selected channels.
[in]softwareTriggerIf true a software trigger is generate to update PWM parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 503 of file ftm_pwm_driver.c.

status_t FTM_DRV_InitPwm ( uint32_t  instance,
const ftm_pwm_param_t param 
)

Configures the duty cycle and frequency and starts outputting the PWM on all channels configured in param.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]paramFTM driver PWM parameter to configure PWM options.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 43 of file ftm_pwm_driver.c.

status_t FTM_DRV_UpdatePwmChannel ( uint32_t  instance,
uint8_t  channel,
ftm_pwm_update_option_t  typeOfUpdate,
uint16_t  firstEdge,
uint16_t  secondEdge,
bool  softwareTrigger 
)

This function updates the waveform output in PWM mode (duty cycle and phase).

Parameters
[in]instanceThe FTM peripheral instance number.
[in]channelThe channel number. In combined mode, the code finds the channel.
[in]typeOfUpdateThe type of PWM update in the duty cycle/pulse or in ticks.
[in]firstEdgeDuty cycle or first edge time for PWM mode. Can take value between 0 - FTM_MAX_DUTY_CYCLE(0 = 0% from period and FTM_MAX_DUTY_CYCLE = 100% from period) Or value in ticks for the first of the PWM mode in which can have value between 0 and ftmPeriod is stored in the state structure.
[in]secondEdgeSecond edge time - only for combined mode. Can take value between 0 - FTM_MAX_DUTY_CYCLE(0 = 0% from period and FTM_MAX_DUTY_CYCLE = 100% from period). Or value in ticks for the second of the PWM mode in which can have value between 0 and ftmPeriod is stored in the state structure.
[in]softwareTriggerIf true a software trigger is generate to update PWM parameters.
Returns
success
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 305 of file ftm_pwm_driver.c.

status_t FTM_DRV_UpdatePwmPeriod ( uint32_t  instance,
ftm_pwm_update_option_t  typeOfUpdate,
uint32_t  newValue,
bool  softwareTrigger 
)

This function will update the new period in the frequency or in the counter value into mode register which modify the period of PWM signal on the channel output.

Parameters
[in]instanceThe FTM peripheral instance number.
[in]typeOfUpdateThe type of PWM update is a period in Hz or in ticks.
  • For FTM_PWM_UPDATE_IN_DUTY_CYCLE which reuse in FTM_DRV_UpdatePwmChannel function will update in Hz.
  • For FTM_PWM_UPDATE_IN_TICKS will update in ticks.
[in]newValueThe frequency or the counter value which will select with modified value for PWM signal. If the type of update in the duty cycle, the newValue parameter must be value between 1U and maximum is the frequency of the FTM counter. If the type of update in ticks, the newValue parameter must be value between 1U and 0xFFFFU.
[in]softwareTriggerIf true a software trigger is generate to update PWM parameters.
Returns
operation status
  • STATUS_SUCCESS : Completed successfully.
  • STATUS_ERROR : Error occurred.

Definition at line 437 of file ftm_pwm_driver.c.