5.18. PWM

5.18.1. Types

Base type

Type Name

Brief

enum

Pwm_EdgeNotificationType

Possible edge notification

enum

Pwm_OutputStateType

Output state type.

enum

Pwm_ChannelClassType

Channel class type.

enum

Pwm_epwmOutputCh_t

EPWM outputs in a single epwm channel.

typedef void(*)(void)

Pwm_NotifyFuncType

Notification callback function pointer

5.18.1.1. enum Pwm_EdgeNotificationType

Enumerator

Value

Description

PWM_RISING_EDGE

1U

Rising edges issue notification

PWM_FALLING_EDGE

2U

Falling edges issue notification.

PWM_BOTH_EDGES

3U

Both edges issue notification

Brief: Possible edge notification

5.18.1.2. enum Pwm_OutputStateType

Enumerator

Value

Description

PWM_LOW

0U

LOW state.

PWM_HIGH

HIGH state.

Brief: Output state type.

5.18.1.3. enum Pwm_ChannelClassType

Enumerator

Value

Description

PWM_FIXED_PERIOD

0U

Period is immutable

PWM_FIXED_PERIOD_SHIFTED

Period is immutable with phase shift

PWM_VARIABLE_PERIOD

Period is variable

Brief: Channel class type.

5.18.1.4. enum Pwm_epwmOutputCh_t

Enumerator

Value

Description

PWM_OUTPUT_CH_A

0U

Output channel A.

PWM_OUTPUT_CH_B

1U

Output channel B.

PWM_OUTPUT_CH_BOTH_A_AND_B

2U

Both Output channel A and B.

Brief: EPWM outputs in a single epwm channel.

5.18.1.5. typedef Pwm_NotifyFuncType

typedef void(* Pwm_NotifyFuncType) (void);

Brief: Notification callback function pointer

5.18.2. Structures

Name

Brief

Pwm_ChannelConfigType_PC

Pwm channel configuration.

Pwm_ConfigType_PC

Pwm configuration structure.

Pwm_ChannelConfigType

Pwm channel configuration.

Pwm_ConfigType

Pwm configuration structure.

Pwm_RegisterReadbackType

PWM register readback structure.

5.18.3. Defines

Name

Brief

PWM_START_SEC_VAR_INIT_8

Possible edge notification

PWM_STOP_SEC_VAR_INIT_8

Possible edge notification

PWM_SW_MAJOR_VERSION

Driver Implementation Major Version.

PWM_SW_MINOR_VERSION

Driver Implementation Minor Version.

PWM_SW_PATCH_VERSION

Driver Implementation Patch Version.

PWM_AR_RELEASE_MAJOR_VERSION

AUTOSAR Major version specification implemented by PWM Driver.

PWM_AR_RELEASE_MINOR_VERSION

AUTOSAR Minor version specification implemented by PWM Driver.

PWM_AR_RELEASE_REVISION_VERSION

AUTOSAR Patch version specification implemented by PWM Driver.

PWM_VENDOR_ID

Texas Instruments Vendor ID.

PWM_MODULE_ID

PWM Driver Module ID.

PWM_INSTANCE_ID

PWM Driver Instance ID.

PWM_E_INIT_FAILED

PWM driver configuration parameter error.

PWM_E_UNINIT

PWM driver Not initialized error.

PWM_E_PARAM_CHANNEL

PWM driver Invalid param.

PWM_E_PERIOD_UNCHANGEABLE

PWM driver Fixed period channel.

PWM_E_ALREADY_INITIALIZED

PWM driver Already initialized.

PWM_E_PARAM_POINTER

PWM driver pointer parameter error.

PWM_E_NOT_DISENGAGED

RunTime Error: API Pwm_SetPowerState is called while the PWM module is still in use.

PWM_SID_INIT

PWM driver service ID for Initialization API.

PWM_SID_DEINIT

PWM driver service ID for De-Initialization API.

PWM_SID_SET_DUTY_CYCLE

PWM driver service ID for set duty cycle API.

PWM_SID_SET_PERIOD_AND_DUTY

PWM driver service ID for set duty cycle and period API.

PWM_SID_SET_OUTPUT_TO_IDLE

PWM driver service ID for set output state to idle API.

PWM_SID_GET_OUTPUT_STATE

PWM driver service ID for get output state API.

PWM_SID_DISABLE_NOTIFICATION

PWM driver service ID for disable notification API.

PWM_SID_ENABLE_NOTIFICATION

PWM driver service ID for Enable notification API.

PWM_SID_GET_VERSION_INFO

PWM driver service ID for Get version info API.

PWM_SID_REGISTER_READBACK

PWM driver service ID for Critical register read back API.

PWM_STATUS_UNINIT

PWM driver Status uninitialized.

PWM_STATUS_INIT

PWM driver Status Initialized.

PWM_ISR_VOID

void ISR type

PWM_ISR_CAT1

Category 1 ISR type.

PWM_ISR_CAT2

Category 2 ISR type.

PWM_DUTY_100_PERCENT

16 bit value representing 100% of a period value

PWM_DUTY_0_PERCENT

16bit value representing 0% of a period value

PWM_USE_EPWM

5.18.4. Functions

Return type

Function Name

Brief

void

Pwm_Init(const Pwm_ConfigType * CfgPtr)

Service for PWM initialization. Initializes internal variables and the PWM unit of the micro controller. The function can be called on task level.

void

Pwm_DeInit(void )

Service for PWM de-initialization. After DeInit output states should be in idle level (it is configurable whether reset state is restored or if channel output states are really set to idle). The function can be called on task level.

void

Pwm_SetDutyCycle(Pwm_ChannelType ChannelNumber, uint16 DutyCycle)

Service for setting Duty Cycle This service sets the duty cycle for a channel if DutyCycle is 0%, set output to inverse of polarity if DutyCycle is >= 100%, set output to polarity if 0% < DutyCycle < 100%, set output accordingly The function can be called on task level.

void

Pwm_SetPeriodAndDuty(Pwm_ChannelType ChannelNumber, Pwm_PeriodType Period, uint16 DutyCycle)

Service for setting Period and Duty Cycle This service sets period and duty cycle for a channel if DutyCycle is 0%, set output to inverse of polarity if DutyCycle is >= 100%, set output to polarity if 0% < DutyCycle < 100%, set output accordingly The function can be called on task level.

void

Pwm_SetOutputToIdle(Pwm_ChannelType ChannelNumber)

Service to set the output of a channel immediately to idle. This service sets the output of a channel immediately to idle. The idle output level is configured in driver configuration. The function can be called on task level.

void

Pwm_DisableNotification(Pwm_ChannelType ChannelNumber)

Service to disable the Edge Notification Disables the Edge Notification This service deactivates the Edge Notification for the pwm channel specified by the ChannelNumber Parameter. The function can be called on task level.

void

Pwm_EnableNotification(Pwm_ChannelType ChannelNumber, Pwm_EdgeNotificationType Notification)

Service to enable the Edge Notification Enables the Edge Notification This service enables the notification of the chosen edges for the Pwm channel specified by the ChannelNumber.The function can be called on task level.

void

Pwm_GetVersionInfo(Std_VersionInfoType * versioninfo)

This service returns the version information of this module. Returns the version information of this module. The function can be called on task level.

Std_ReturnType

Pwm_RegisterReadback(Pwm_ChannelType ChannelNumber, Pwm_RegisterReadbackType * RegRbPtr)

This function reads the important registers of the hardware unit and returns the value in the structure. This API is used to check the status of critical registers which do not change during program execution.

Pwm_OutputStateType

Pwm_GetOutputState(Pwm_ChannelType ChannelNumber)

This function read the internal state of the PWM output signal.

5.18.4.1. function Pwm_Init

void Pwm_Init(
    const Pwm_ConfigType * CfgPtr
)

Brief: Service for PWM initialization. Initializes internal variables and the PWM unit of the micro controller. The function can be called on task level.

Possible output states of a PWM channel

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x00

Sync/Async : Synchronous

Reentrancy : Non Reentrant

Parameters:

  • CfgPtr - Pointer to the configuration

Returns:

  • None

Return: None

5.18.4.2. function Pwm_DeInit

void Pwm_DeInit(
    void 
)

Brief: Service for PWM de-initialization. After DeInit output states should be in idle level (it is configurable whether reset state is restored or if channel output states are really set to idle). The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x01

Sync/Async : Synchronous

Reentrancy : Non Reentrant

Parameters:

  • None

Returns:

  • None

Return: None

5.18.4.3. function Pwm_SetDutyCycle

void Pwm_SetDutyCycle(
    Pwm_ChannelType ChannelNumber,
    uint16 DutyCycle
)

Brief: Service for setting Duty Cycle This service sets the duty cycle for a channel if DutyCycle is 0%, set output to inverse of polarity if DutyCycle is >= 100%, set output to polarity if 0% < DutyCycle < 100%, set output accordingly The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x02

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

  • DutyCycle - Duty cycle

Returns:

  • None

Return: None

5.18.4.4. function Pwm_SetPeriodAndDuty

void Pwm_SetPeriodAndDuty(
    Pwm_ChannelType ChannelNumber,
    Pwm_PeriodType Period,
    uint16 DutyCycle
)

Brief: Service for setting Period and Duty Cycle This service sets period and duty cycle for a channel if DutyCycle is 0%, set output to inverse of polarity if DutyCycle is >= 100%, set output to polarity if 0% < DutyCycle < 100%, set output accordingly The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x03

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

  • Period - Period

  • DutyCycle - Duty cycle

Returns:

  • None

Return: None

5.18.4.5. function Pwm_SetOutputToIdle

void Pwm_SetOutputToIdle(
    Pwm_ChannelType ChannelNumber
)

Brief: Service to set the output of a channel immediately to idle. This service sets the output of a channel immediately to idle. The idle output level is configured in driver configuration. The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x04

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

Returns:

  • None

Return: None

5.18.4.6. function Pwm_DisableNotification

void Pwm_DisableNotification(
    Pwm_ChannelType ChannelNumber
)

Brief: Service to disable the Edge Notification Disables the Edge Notification This service deactivates the Edge Notification for the pwm channel specified by the ChannelNumber Parameter. The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x06

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

Returns:

  • None

Return: None

5.18.4.7. function Pwm_EnableNotification

void Pwm_EnableNotification(
    Pwm_ChannelType ChannelNumber,
    Pwm_EdgeNotificationType Notification
)

Brief: Service to enable the Edge Notification Enables the Edge Notification This service enables the notification of the chosen edges for the Pwm channel specified by the ChannelNumber.The function can be called on task level.

Mode : Supervisor Mode (Privileged Mode)

Service ID[hex] : 0x07

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

  • Notification - Notification

Returns:

  • None

Return: None

5.18.4.8. function Pwm_GetVersionInfo

void Pwm_GetVersionInfo(
    Std_VersionInfoType * versioninfo
)

Brief: This service returns the version information of this module. Returns the version information of this module. The function can be called on task level.

Mode : User Mode (Non-Privileged Mode)

Service ID[hex] : 0x08

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • versioninfo - version info

Returns:

  • None

Return: None

5.18.4.9. function Pwm_RegisterReadback

Std_ReturnType Pwm_RegisterReadback(
    Pwm_ChannelType ChannelNumber,
    Pwm_RegisterReadbackType * RegRbPtr
)

Brief: This function reads the important registers of the hardware unit and returns the value in the structure. This API is used to check the status of critical registers which do not change during program execution.

Service ID[hex] : 0x0D

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel number

  • RegRbPtr - Pointer to where to store the readback values. If this pointer is NULL, then the API will return E_NOT_OK.

Returns:

  • E_OK Register read back has been done successfully

  • E_NOT_OK Register read back failed

Return: Std_ReturnType

5.18.4.10. function Pwm_GetOutputState

Pwm_OutputStateType Pwm_GetOutputState(
    Pwm_ChannelType ChannelNumber
)

Brief: This function read the internal state of the PWM output signal.

Service ID[hex] : 0x05

Sync/Async : Synchronous

Reentrancy : Reentrant

Parameters:

  • ChannelNumber - Channel Number

Returns:

  • PWM_HIGH The PWM output state is high

  • PWM_LOW The PWM output state is low

Return: Pwm_OutputStateType