TMS570_Startup_SysStartup_MDD

Module --

High-Level Description

This module outlines the functionality of the system startup functions of the TMS570. This code is intended to be run starting at the reset vector.

Figures

Diagram – Function Data Sharing

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

No Shared Data


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
ResetCause_Cnt_EnumResetCause_Cnt_Enum

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 NameValue
enum systemClockSourceSYS_OSC0
SYS_PLL11
SYS_EXTERNAL13
SYS_LPO_LOW4
SYS_LPO_HIGH5
SYS_PLL26
SYS_EXTERNAL27
SYS_VCLK9

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
<None>

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_OTP1BITERRADDR_CNT_U321Counts0xF00803F4
D_OTP2BITERRADDR_CNT_U321Counts0xF00803FC
D_DPRAMSELECT_CNT_U321Counts0x4
D_SPRAMSELECT_CNT_U321Counts0x8
D_EFCAUTOLOADERROREN_CNT_U321Counts0x00040000
D_EFCINSTRUCTIONERROREN_CNT_U321Counts0x00080000
D_EFCINSTRUCTIONINFOEN_CNT_U321Counts0x00100000
D_EFCSELFTESTERROREN_CNT_U321Counts0x00200000
D_EFCSELFTESTDONE_CNT_U321Counts0x00008000
D_EFCSELFTESTERROR_CNT_U321Counts0x00004000
D_OUTPUTENABLE_CNT_U321Counts0x0003C000
D_SELFTESTERROR_CNT_U321Counts0x18
D_LPOTRIMVALUE_CNT_U321Counts((*(uint32*)0xF00801B4) & 0xFFFF0000)>>16
D_PLLSLIPMASK_CNT_U321Counts0x00000300
D_LOWBYTEMASK_CNT_U321Counts0x0000000FFUL
D_CURRENTLPOTRIMMASK_CNT_U321Counts0x00000FFFFUL
D_LPOMONLFTRIMMASK_CNT_U321Counts0xFFFFFF00UL
D_LPOMONHFTRIMMASK_CNT_U321Counts0xFFFF00FFUL
D_OTPRAMDEVICEADDR_CNT_U321Counts0xF0080148u
D_ESRAM5ENABLE_CNT_U321Counts0x01<<20
D_ESRAM6ENABLE_CNT_U321Counts0x01<<21
D_ESRAM8ENABLE_CNT_U321Counts0x01<<27

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
D_SPRAMGRPSTMS_CNT_U32
D_DPRAMGRPSTMS_CNT_U32
D_CSDISCLRVAL_CNT_U32
D_CSVSTATMASK_CNT_U32
D_PCSPWRDWNCLR0VAL_CNT_U32
D_PCSPWRDWNCLR1VAL_CNT_U32
D_PSPWRDWNCLR0VAL_CNT_U32
D_PSPWRDWNCLR1VAL_CNT_U32
D_PSPWRDWNCLR2VAL_CNT_U32
D_PSPWRDWNCLR3VAL_CNT_U32
D_RAMPWRONINITMASKTMS_CNT_U32
D_RAMRESETINITMASKTMS_CNT_U32
D_PLLCTL1VAL_CNT_U32
D_FRDCNTLVAL_CNT_U32

Module specific Lookup Tables Constants

(This is for lookup tables (arrays) with fixed values, same name as other tables)

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

Global Function #1

Function Name(Exact name used)TypeMinMaxUTP Tol.
Arguments Passed(if none, write None)
(Insert more rows for additional passed arguments)
Return Value(if no value returned, write N/A)

Description

(Place flowchart/design for local function)

Local Functions/Macros Used by this MDD only

Local Function DiagFailedReset

Function NameDiagFailedResetTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function resetStartup

Function NameresetStartupTypeMinMaxUTP Tol.
Arguments PassedMemInitMask_Cnt_T_u32uint32FULLFULL
Return ValueN/A

Description

Local Function pwronStartup

Function NamepwronStartupTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function afterSTC

Function NameafterSTCTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function memInitialization

Function NamememInitializationTypeMinMaxUTP Tol.
Arguments PassedMemInitMask_Cnt_T_u32uint32FULLFULL
Return ValueN/A

Design Rationale

All VIM registers are cleared at the end of the startup initialization routine because the startup routine tests will set some interrupt flags during the testing (CCMSelfCheck).

Description

Local Function cpuSelfTest

Function NamecpuSelfTestTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function setupPLL

Function NamesetupPLLTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Design Rationale

This function configures the PLL settings. These register settings assume 20MHz oscillator. Changes to these values will drive changes to these register values.

Description

Local Function efcCheck

Function NameefcCheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function efcStuckZeroTestPassed

Function NameefcStuckZeroTestPassedTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueTestPassed_Cnt_T_lgcbooleanFALSETRUE0

Description

Local Function efcSelfTest

Function NameefcSelfTestTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description


Local Function periphInit

Function NameperiphInitTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function checkEFCSelfTestPassed

Function NamecheckEFCSelfTestPassedTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueTestPassed_Cnt_T_lgcbooleanFALSETRUE0

Description

Local Function setupFlash

Function NamesetupFlashTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Design Rationale

The device ID is checked and if the gladiator revA part ID is detected, pre-emption is disabled. This is to account for errata DEVICE#145 of revA parts.

Description

Local Function trimLPO

Function NametrimLPOTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function fmcBus2Check

Function NamefmcBus2CheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function fmcECCcheck

Function NamefmcECCcheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function mapClocks

Function NamemapClocksTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function stcSelfCheck

Function NamestcSelfCheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Design Rationale

This function assumes a divide by two on the clock frequency will produce a frequency for the test to run at < 90MHz. For the current design, the clock frequency is 160MHz which will produce an 80MHz clock for this test.

Description

Local Function ccmSelfCheck

Function NameccmSelfCheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function pbistSelfCheck

Function NamepbistSelfCheckTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Design Rationale

This function assumes a divide by two on the clock frequency will produce a frequency for the test to run at < 90MHz. For the current design, the clock frequency is 160MHz which will produce an 80MHz clock for this test.

Description

Local Function pbistRun

Function NamepbistRunTypeMinMaxUTP Tol.
Arguments PassedraminfoL_Cnt_T_u32uint32FULLFULL
algomask_Cnt_T_u32uint32FULLFULL
Return ValueN/A

Design Rationale

This function assumes a divide by two on the clock frequency will produce a frequency for the test to run at < 90MHz. For the current design, the clock frequency is 160MHz which will produce an 80MHz clock for this test.

Description

Local Function pbistStop

Function NamepbistStopTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Function Delay

Function NameDelayTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValueN/A

Description

Local Macro GetRamDomian1Enabled

Function NameGetRamDomian1EnabledTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValuebooleanFALSETRUE1

Description

Local Macro GetRamDomian2Enabled

Function NameGetRamDomian2EnabledTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValuebooleanFALSETRUE1

Description

Local Macro GetRamDomian3Enabled

Function NameGetRamDomian3EnabledTypeMinMaxUTP Tol.
Arguments PassedNone
Return ValuebooleanFALSETRUE1

Description

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

(Note: For multiple init functions, insert new headers at the “Header 2” level – subset of “5.1 Initialization Functions” and follow the same sub-section design shown below)

Init: _c_int00 / Startup

Design Rationale

This _c_int00 function is designed to be placed at the reset vector. Since this function needs to be compiled in arm mode, it immediately branches to the Startup() function which can optionally be compiled in thumb mode to allow memory optimizations. Since stacks are not available, the Startup() function needs to be defined as a Reset vector similar to _c_int00 so that the compiler does not try pushing data to the stack on entry to this function.

Texas Instruments had provided a recommended startup sequence which the design was based from. The document (spna106a.pdf) and accompanying source code (spna106a.zip) are located in the doc folder of this SWC. Note that SysStartup code primarily handles up to step 35 of spna106a (excluding step 12, 29, 30). Some of the notable deviations from the document include:

  • Addition of debugger connection detection to allow skipping initialization steps which interfere with debugging

  • Replacement of while(1) loops where failures occurred with Nexteer’s failure strategy summarized in section below

  • Use of configuration template headers to define initialization constants that may change from program to program

  • Handling of resets and use of “ResetCause” variable

  • Moving of mux initialization (Step 12 in spna106a) into application specific code (out of common initialization sequence)

  • Moving of SECDED logic check on RAM and Flash (Step 29, 30) into application specific code (out of common initialization sequence)

  • Some of the functions names were changed and the return type was changed to add clarity to the design (efcStuckZeroTest, checkEFCSelfTest)

Failed Initialization Diagnostic Strategy

A common strategy is used when diagnostics that are part of this initialization routine fail. In general, the “ResetCause” variable is set to an appropriate value, the nError pin is forced low, and a software reset is performed. The nError will put the controller into a known safe state. The software reset will allow the rest of the initialization tests to be bypassed, as well as reset the controller’s registers to a known state. The rest of the tests are bypassed to ensure the first failure is captured as the “ResetCause”, and the application can then evaluate the failure reason and set appropriate diagnostics codes (and communicate these on the communication bus if desired). Note that the registers getting reset will also reset the nError pin state, so forcing the nError pin low is also done when processing the software reset. Also note that for any of these diagnostics that fail, the general RAM banks will be initialized as part of the reset handling (as opposed to just initializing peripheral ram like most other resets).

Software Initiated Resets

For the two types of resets which can be initiated by software (CPU reset and SW reset), a strategy for setting the “ResetCause” variable has been used to allow for flexibility in adding new reset causes. A check is done to see if the current value of the “ResetCause” indicates a power-on reset. If this is the case, the initialization code assumes whatever code that initiated the reset did not explicitly indicate the reason for reset, and therefore the initialization code overwrites the value to the appropriate reset type (CPU or SW). If the reset value is anything other than power-on reset, the initialization code leaves the “ResetCause” as-is under the assumption that whatever code that initiated the reset set this cause specifically.

Errata Processing

The device ID is checked at power-on and if the gladiator revA part ID is detected, a _esmCcmErrorsClear_() function is called to handle DEVICE#140 errata processing.

Processing


Periodic Functions

None

Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

None


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
_c_int00()power on and during a resetN/A

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
_c_int00()

Local Functions

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

Name of Sub ModuleSoftware Segment
Startup
DiagFailedResetinline with calling function
resetStartup
pwronStartupinline with calling function
afterSTCinline with calling function
setupPLLinline with calling function
trimLPOinline with calling function
setupFlashinline with calling function
periphInitinline with calling function
mapClocksinline with calling function
ccmSelfCheckinline with calling function
stcSelfCheckinline with calling function
cpuSelfTestinline with calling function
efcCheckinline with calling function
efcSelfTestinline with calling function
efcStuckZeroTestPassedinline with calling function
checkEFCSelfTestPassedinline with calling function
fmcBus2Checkinline with calling function
fmcECCcheckinline with calling function
pbistSelfCheckinline with calling function
pbistRuninline with calling function
pbistStopinline with calling function
memInitializationinline with calling function


Known Issues / Limitations With Design

  1. (Item #1)


Revision Control Log

Item #Rev #Change DescriptionDateAuthor Initials
11Initial creation05/11/12LWW
22Updates for LPO Trim issue06/11/12LWW
33Updates to turn of PLL Slip and clock monitor resets in PLLCTL1 Register, added clearing of VIM interrupt requests before jumping into bootloader, added turning on DCAN parity if the memory is configured to be powered on prior to the memory initialization call07/13/12LWW
44Update SetUpPll code to check and recover from PLLSLIP and/or FBLSLIP. Modified SetUpPll code, Updated the TrimLPO function and added delay() function09/14/12BG, BDO
55Updated PLL settings for clock change to 150MHz10/12/12BWL
66Made PLL configurable and tied flash waitstate settings to frequency02/14/13LWW
77Made RAM pbist only run on banks enabled in OTP memory02/15/13BWL
88Correction for static register check02/15/13BWL
99Added call to Startup to allow compilation of file in thumb mode08/02/13LWW
Last modified October 12, 2025: Initial commit (0347a62)