Adc_MDD

Module -- ADC

High-Level Description

The ADC module shall control sampling and conversion of voltages from the hardware layer into digital signals. The ADC Register definition has been captured from the TMS570LS31x/21x 16/32-Bit RISC Flash Microcontroller Technical Reference Manual (SPNU499 – September 2011).

Figures

Component Diagram


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 InputsModule Outputs
NoneNone

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
None

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)

Adc_GroupTypeN/Auint802
Adc_GroupConfigDataType

uint8 NumOfChannels,

uint32 ChannelSelect,

uint32* ResultBuf

structFULLFULL
Adc_StatusType

ADC_IDLE,

ADC_BUSY,

ADC_COMPLETED,

ADC_STREAM_COMPLETED

enum03
Adc_ValueGroupTypeN/Auint1604095
Adc_ValueGroupTypeN/Auint16*FULLFULL

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_VbattOVTransIntConfig_Cnt_u32

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_NUMOFGROUPS_CNT_U81Counts3
D_GROUPEV_CNT_U81Counts0
D_GROUP1_CNT_U81Counts1
D_GROUP2_CNT_U81Counts2
D_NUMOFADCCALREADS_CNT_U81Counts8
D_NTCPARMBIT0_CNT_U81Counts1
D_NTCPARMBIT1_CNT_U81Counts2
D_NTCPARMBIT2_CNT_U81Counts4
D_ADC1RSLTBASEADR_CNT_U321Counts0xFF3E0000U
D_ADC1NUMRSLTBUF_CNT_U081Counts64
D_ADC1CURRENTMODE_ULS_LGC1BOOLEANGenerated in Adc_Cfg.h.
D_ADC1MAGINTMASK1_CNT_U161Counts0/0*
D_ADC1MAGINTASET_CNT_U161Counts1/0*
D_ADC1MAGINTCR1_CNT_U321Countsk_VbattOVTransIntConfig_Cnt_u32/ 0*
D_ADC1THRINTENACLR_CNT_U161Counts6/7*
D_ADC1EVTBUFSZ_CNT_U081CountsGenerated in Adc_Cfg.h.
D_ADC1G1BUFSZ_CNT_U081CountsGenerated in Adc_Cfg.h.
D_ADC1G2BUFSZ_CNT_U081CountsGenerated in Adc_Cfg.h.
D_GROUPEND_CNT_U321CountsGenerated in Adc_Cfg.h.
D_GROUPBUSY_CNT_U321CountsGenerated in Adc_Cfg.h.

D_ADC1CURRENTMODE_ULS_LGC if True value 1 is selected to proceed. If not value 2 will be used,

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
T_Adc1GroupConfigData_Cnt_Str[D_NUMOFGROUPS_CNT_U8]

Module specific Lookup Tables Constants

Constant NameResolutionValueSoftware Segment
None


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,

  1. None

Data Hiding Functions

  1. <None>

Global Functions/Macros Defined by this Module

ADC Init

Function Name

Adc_Init_FixedCfg

( macro aliased is Adc_Init(x) )

TypeMinMaxUTP Tol.
Arguments PassedNoneN/AN/AN/A
Return ValueN/A

This function is used to initialize each of the ADC1 Groups (Event, Group1, and Group2).

Initialize Module Internal Variables

None

Register Configuration

Setup Result Buffer

Function NameAdc_SetupResultBufferTypeMinMaxUTP Tol.
Arguments PassedGroupAdc_GroupType02
DataBufferPtrAdc_ValueGroupRefTypeFULLFULL
Return ValueN/AStd_ReturnType000

This function is the Adc group result buffer setup service. It is responsible for setting up the result buffer pointer of the group.

This Api is provided to support for the standard Autosar API, however the design of this driver does not buffer an intermediate copy of the results and therefore does not require a result buffer. The hardware provides a sufficient Adc results buffer.

For optimization purposes, this function could be defined as a macro.

Setup Group’s Result Buffer

return E_OK

Start Group Conversion

Function NameAdc_StartGroupConversionTypeMinMaxUTP Tol.
Arguments PassedGroupAdc_GroupType02
DataBufferPtrAdc_ValueGroupRefTypeFULLFULL
Return ValueN/AStd_ReturnType000

This function starts a software triggered conversion of all channels of the requested Adc channel group.

In order to provide optimized execution of this single line function, this API should be defined as a macro, however, due to timing it is at the moment defined as a function. The need for minimal runtime is driven by a Nexteer use case which executes this in the context of the MtrCtrl ISR in some EPS systems.

Select Channels to Convert

adcREG1->GxSEL[Group] = T_Adc1GroupConfigData_Cnt_Str[Group].ChannelSelect

Get Group Status

Function NameAdc_GetGroupStatusTypeMinMaxUTP Tol.
Arguments PassedGroupAdc_GroupType02
Return ValueReturnVal_Cnt_T_EnumAdc_StatusType030

Returns the conversion status of the requested ADC1 channel group.

Get Status

Read Group Conversions

Function NameAdc_ReadGroupTypeMinMaxUTP Tol.
Arguments PassedGroupAdc_GroupType02
Return ValueReturnVal_Cnt_T_EnumAdc_StatusType030

Reads the group conversion result of the last completed conversion round of the requested group and

stores the channel values starting at the DataBufferPtr address. The group channel values are stored in ascending channel number order (in contrast to the storage layout of the result buffer if streaming access is configured).

Per the design direction in FDD33, direct ADC result buffer acces is used instead of using the hardware FIFO access register.

Read Group

Local Functions/Macros Used by this MDD only

Software Module Implementation

Runtime Environment (RTE) Initial Values

None

Initialization Functions

None

Periodic Functions

None

Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

None

Transition Functions

None


Execution Requirements

Execution Sequence of the Module

Adc_Init should be called after SystemTime_Init due to the use of the uS System Time.

Adc_Init should be called prior to IoHwAb_Init to ensure registers are configured prior to triggering initial conversions.

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
Adc_InitOnce (at initialization)STARTUP

Execution Requirements for Serial Communication Functions

Function NameSub-Module called by (Serial Comm Function Name)
N/A


Memory Map Definition Requirements

Sub Modules (Functions)

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

Name of Sub ModuleSoftware Segment
Adc_InitADC_START_SEC_CODE
Adc_SetupResultBufferADC_START_SEC_CODE
Adc_StartGroupConversionADC_START_SEC_CODE
Adc_ReadGroupADC_START_SEC_CODE
Adc_GetGroupStatusADC_START_SEC_CODE
ADCOffsetCalibrationADC_START_SEC_CODE

Local Functions

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

Name of Sub ModuleSoftware Segment


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 version based on FDD 33C rev 00605Nov12LN
22

Constant confiuguration tables renamed to start with “T_”

Rewored Adc_ReadGroup to provide direct fixed memory access as required in the FDD

15Jan13JJW
33Updated FDD 33C rev 007 and FDD33E rev225-April-13Selva
Last modified October 12, 2025: Initial commit (0347a62)