PWM_CDD_MDD

Module –

High-Level Description

Non-AUTOSAR PWM driver required to perform EPS motor control PWM profiles.

Figures

Component Diagram

This diagram shows all data that is shared between functions within the module.

No data sharing

Diagram – Function (Per1)

None (For more refer section 6)


Variable Data Dictionary

For details on module input / output variable, refer to the Data Dictionary for the application. Input / output variable names are listed here for reference.

Module Inputs (Global Variable Name)Module Outputs (Global Variable Name)
CDD_PhaseAdvFinal_Cnt_G_u16[2]CDD_DutyCycleSmall_Cnt_G_u16[2]
CDD_CommOffset_Cnt_G_u16[2]CDD_PWMDutyCycleASum_Cnt_G_u32[2]
CDD_MtrPosElec_Rev_G_u0p16[2]CDD_PWMDutyCycleBSum_Cnt_G_u32[2]
CDD_PwmDisable_Cnt_G_lgc[2]CDD_PWMDutyCycleCSum_Cnt_G_u32[2]
CDD_MtrTrqCmdSign_Cnt_G_s16[2]CDD_PWMPeriodSum_Cnt_G_u32[2]
CDD_DeadTimeComp_Uls_G_u8p8[2]CDD_PhsReasA_Cnt_G_u16[2]
CDD_ModIdxFinal_Uls_G_u16p16[2]CDD_PhsReasB_Cnt_G_u16[2]
CDD_CDDDataAccessBfr_Cnt_G_u16CDD_PhsReasC_Cnt_G_u16[2]
CDD_AppDataFwdPthAccessBfr_Cnt_G_u16CDD_DCPhsComp_Cnt_G_u16[3]
CDD_AppDataFbkPthAccessBfr_Cnt_G_u16CDD_PWMPeriod_Cnt_G_u16

Module Internal Variables

This section identifies the name, range and resolutions for module specific data created by this module. If there are no range restrictions on the variable, the term “FULL” is placed into the table for legal range.

Variable NameResolution

Legal Range

(min)

Legal Range

(max)

Software Segment
CDD_SeedPWMDither_Cnt_M_u16N/A N/A N/A PWMCDD_START_SEC_VAR_CLEARED_16
CDD_DitherFlt1SV_Cnt_M_u16N/A N/A N/A PWMCDD_START_SEC_VAR_CLEARED_16
CDD_DitherFlt2SV_Cnt_M_u16N/A N/A N/A PWMCDD_START_SEC_VAR_CLEARED_16
CDD_PhaseOffset_Rev_M_u0p16[3]N/A N/A N/A PWMCDD_START_SEC_VAR_CLEARED_16
CDD_NextDCSmall_Cnt_M_u16N/A N/A N/A PWMCDD_START_SEC_VAR_CLEARED_16
PrevDCPhsAComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
PrevDCPhsBComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
PrevDCPhsCComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
DCPhsAComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
DCPhsBComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
DCPhsCComp_Cnt_M_u16p0107150PWMCDD_START_SEC_VAR_CLEARED_16
PrevPWMPeriod_Cnt_M_u16129507150PWMCDD_START_SEC_VAR_CLEARED_16
PWMPeriod_Cnt_M_u16129507150PWMCDD_START_SEC_VAR_CLEARED_16

User defined typedef definition/declaration

This section documents any user types uniquely used for the module.

Typedef NameElement NameUser Defined Type

Legal Range

(min)

Legal Range

(max)

None

Constant Data Dictionary

Calibration Constants

This section lists the calibrations used by the module. For details on calibration constants, refer to the Data Dictionary for the application.

Constant Name
k_ADCTrig1Offset_Cnt_s16
k_ADCTrig2Offset_Cnt_s16
k_DitherLPFKn_Cnt_u16
k_PwmDeadBand_Cnt_u16

Program(fixed) Constants

Embedded Constants

All embedded constants whose values are provided in Eng units will be evaluated to the equivalent counts by using the FPM_InitFixedPoint_m() macro within the #define statement.

Local

Constant NameResolutionUnitsValue
d_NhetFreq_Hz_Cnt_u161u1675000000UL
d_HalfPrec8_Cnt_u161u16128U
d_HalfPrec16_Cnt_u161u1632768UL
d_Scaler1_Cnt_u161u161U
d_Scaler8_Cnt_u161u168U
d_Scaler16_Cnt_u161u1616U
d_SeedInitial_Cnt_u161u1610U
d_SeedMultiplier_Cnt_u161u1657U
d_SeedOffset_Cnt_u161u161U
d_PWMClockFreq_Hz_u321U3275000000UL
d_PWMFreqBase_Hz_u161u1616000U
d_PWMFreqDither_Hz_u161u162000U
d_PwmPrdMax_Cnt_u161u16(d_PwmFreq_Hz_Cnt_u16 /(uint32)(d_PWMFreqBase_Hz_u16 - d_PWMFreqDither_Hz_u16))
d_PwmPrdMin_Cnt_u161u16

d_PwmFreq_Hz_Cnt_u16 /(uint32)(d_PWMFreqBase_Hz_u16 )

+ d_PWMFreqDither_Hz_u16)

d_PwmPrdRange_Cnt_u161u16(d_PwmPrdMax_Cnt_u16-(uint16)d_PwmPrdMin_Cnt_u16)
d_PwmPrdInitVal_Cnt_u161u16((uint16)(d_PWMClockFreq_Hz_u32/(uint32)d_PWMFreqBase_Hz_u16))
d_FilterKdBits_Cnt_U161u165U
d_MaxModIdx_Uls_u0p162-16u0p16(FPM_InitFixedPoint_m(0.9999847412109375,u0p16_T))
d_MinModIdx_Uls_u0p162-16u0p16(FPM_InitFixedPoint_m(0.0,u0p16_T))
d_120Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.3333333333,u0p16_T))
d_0Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.0,u0p16_T))
d_30Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.0833333333,u0p16_T))
d_60Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.1666666666,u0p16_T))
d_240Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.6666666666,u0p16_T))
d_180Deg_Rev_u0p162-16u0p16(FPM_InitFixedPoint_m(0.5,u0p16_T))
d_PhaseAOffsetNrm_Rev_u0p162-16u0p16d_0Deg_Rev_u0p16
d_PhaseBOffsetNrm_Rev_u0p162-16u0p16((uint16)(d_PhaseAOffsetNrm_Rev_u0p16-d_120Deg_Rev_u0p16))
d_PhaseCOffsetNrm_Rev_u0p162-16u0p16(d_PhaseAOffsetNrm_Rev_u0p16+d_120Deg_Rev_u0p16)
d_PhaseAOffsetInv_Rev_u0p162-16u0p16d_60Deg_Rev_u0p16
d_PhaseBOffsetInv_Rev_u0p162-16u0p16(d_PhaseAOffsetInv_Rev_u0p16+d_120Deg_Rev_u0p16)
d_PhaseCOffsetInv_Rev_u0p162-16u0p16((uint16)(d_PhaseAOffsetInv_Rev_u0p16-d_120Deg_Rev_u0p16))
d_RevpCnt_Uls_u0p322-32u0p32699051UL/*(FPM_InitFixedPoint_m(1/d_PACntspRev_Uls_u16p0,u0p32_T))*/
d_PACntspRev_Uls_u16p01u16p06144U
d_SinePhsToGndTblSize_Cnt_u161u162049U
d_MSBMask_Cnt_u161u160x8000U
D_POSITIVEONE_CNT_S81s81
D_PHSAIDX_CNT_U161u160U
D_PHSBIDX_CNT_ U161u161U
D_PHSCIDX_CNT_ U161u162U

Global

This section lists the global constants used by the module. For details on global constants, refer to the Data Dictionary for the application.

Constant Name

Module specific Lookup Tables Constants

Constant NameResolutionValueSoftware Segment
t_S_SinePhsToGndTbl_Cnt_u0p16[2049]2-16None


Functions/Macros used by the Sub-Modules

Library Functions / Macros

The library and functions / Macros that are called by the various sub modules are identified below,

The library functions / Macros that are called by the various sub modules are identified below,

  1. FPM_FloatToFixed_m()

  2. FPM_FixedToFloat_m()

  3. Limit_m()

  4. Max_m()

  5. Min_m()

  6. CDD_Read_PhaseAdvanceFinal_Rev_u0p16()

Data Hiding Functions

  1. None

Global Functions/Macros Defined by this Module

Global Function #1

Function NameCDD_ApplyPWMMtrElecMechPolTypeMinMaxUTP Tol.
Arguments PassedMtrElecMechPol_Cnt_s8Sint 8
Return ValueCDD_PhaseOffset_Rev_M_u0p16Uint16

Description

Applies the offsets needed for MtrElecMech Polarity Setting

Global Function #2

Function NameCDDPorts_ClearPhsReasSumTypeMinMaxUTP Tol.
Arguments PassedDataAccessBfr_Cnt_T_u16Uint16
Return ValueCDD_PWMDutyCycleASum_Cnt_G_u32Uint32
CDD_PWMDutyCycleBSum_Cnt_G_u32Uint32
CDD_PWMDutyCycleCSum_Cnt_G_u32Uint32
CDD_PWMPeriodSum_Cnt_G_u32Uint32

Description

Local Functions/Macros Used by this MDD only

Local Macros are defined in PWMCDD_Cfg.h file as the return values/calculation of return values are more project specific

Local Function #1

Function NamePwmPeriodDither_u16TypeMinMaxUTP Tol.
Arguments PassedNone
Return ValuePWMPeriod_Cnt_T_u16Unit16

Description

Generates the next PWM Period

Local Function #2

Function NameDeadTimeComp_u16p0TypeMinMaxUTP Tol.
Arguments PassedDCPhsUnComp_Cnt_T_u24p8
Phase_Rev_T_u0p16
Return ValueDCPhsComp_Cnt_T_u16p0

Description

Applies the dead time compensation

Local Function #3

Function NameModIndxPhase_u0p16TypeMinMaxUTP Tol.
Arguments PassedPhaseIndex_Rev_T_u0p16
Return ValueModIdxPhs_Cnt_T_u0p16

Description

Calculates ModIndx for each phase

Local Macro #1

Function NameCDD_Read_PhaseAdvanceFinal_Rev_u0p16TypeMinMaxUTP Tol.
Arguments Passed&PhaseAdvFinal_Rev_T_u0p16U0p1601
Return Valuenone

Description

Converts phase advance final from count units to rev units. (Units type conversion)

Local Macro #2

Function NameCDD_Read_CorrectedMtrPos_Rev_u0p16TypeMinMaxUTP Tol.
Arguments Passed& CorrectedMtrPos_Rev_T_u0p16U0p1601
Return Valuenone

Description

Reads the Motor position global variable and assign it to “CorrectedMtrPos_Rev_T_u0p16”

Local Macro #3

Function NameCDD_Read_CommOffset_Cnt_u16TypeMinMaxUTP Tol.
Arguments Passed&CommOffset_Cnt_T_u16U1602^16
Return Valuenone

Description

Reads the Commutation offset and assign it global variable and assign it to “CommOffset_Cnt_T_u16”

Software Module Implementation

Runtime Environment (RTE) Initial Values

This section lists the initial values of data written by this module but controlled by the RTE. After RTE initialization, the data in this table will contain these values.

DataValue
None

Initialization Functions

Init: _Init

Design Rationale

None

Module Outputs

None

Module Internal

CDD_DutyCycleSmall_Cnt_G_u16[CDD_CDDDataAccessBfr_Cnt_G_u16] = 0U;

CDD_SeedPWMDither_Cnt_M_u16 = d_SeedInitial_Cnt_u16


Periodic Functions

Per: _Per1

Design Rationale

None

Program Flow Start

N/A

Store Module Inputs to Local copies

None

Processing of function

Store Local copy of outputs into Module Outputs

None

Program Flow End

N/A

Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

SCom: _Scom_

Design Rationale

None

Program Flow Start

N/A

Store Module Inputs to Local copies

None

Processing of function

Store Local copy of outputs into Module Outputs

None

Program Flow End

N/A


Execution Requirements

Execution Sequence of the Module

Execution Rates for sub-modules called by the Scheduler

This table serves as reference for the Scheduler design

Function NameCalling FrequencySystem State(s) in which the function is called
PwmCdd_InitOnceEcuStartup
PwmCdd_Per1Motor control ISRAll states

Execution Requirements for Serial Communication Functions

Function NameSub-Module called by (Serial Comm Function Name)
None


Memory Map Definition Requirements

Sub Modules (Functions)

This table identifies the software segments for functions identified in this module.

Name of Sub ModuleSoftware Segment
None

Local Functions

This table identifies the software segments for local functions identified in this module.

Name of Sub ModuleSoftware Segment
None


Known Issues / Limitations With Design

  1. INLINE functions defined in GlobalMacro.h are not unit tested.


Revision Control Log

Item #Rev #Change DescriptionDateAuthor Initials
11.0Initial Version17 Oct 2012Selva
22.0Nhet specific names are changed to common names and project specific variables assignment are moved to configuration Macros to keep PWMCdd same across projects15-Feb-12Selva
33.0Changed the Buffer index of CDD_ModIdxFinal_Uls_G_u16p16 from "CDD_AppDataFwdPthAccessBfr_Cnt_G_u16" to "CDD_CDDDataAccessBfr_Cnt_G_u16"19-Apr-13Selva

\

Last modified October 12, 2025: Initial commit (0347a62)