iLLD_TC27xD  1.0
Startup Sequence
Collaboration diagram for Startup Sequence:

The startup driver is responsible for initializing the basic features of microcontroller to bring it up to the user functions. In framework these functions are called as "CoreX_main".

In TC27X controllers, CPU0 is master controller which is booted from reset. IfxCpu_CStart driver provides following functionalities and they are listed in the order of their execution.

Core Startup Sequence

1) Execute pre-initialization hook, which is user configurable. Ifx_Cpu_ConfigStartupPreInitHook
2) Setup user stack pointer for the CPU core
3) Set program/data cache bypass to configuration defined settings. Refer Ifx_Cpu_CStart_ConfigEnableCache.
4) Set base address for trap vector and interrupt vector for the CPU core
5) Set interrupt stack pointer
6) Initialize the base pointers for the small data area registers for CPU core
7) Initialize the CSA for CPU core
8) Do the C initialization to initialize the global variables etc.
9) Initialize the clock system to configuration defined settings. Ifx_Scu_Ccu_ConfigClock
10) Start remaining cores if they configuration setting request them to be enabled. Ifx_Cpu_CStart_ConfigEnableCores
11) Call user function "CoreX_main"

Note
All the above functionalities are executed by "master core" in this case CPU0. Remaining cores will execute only subset of the above functions, i.e. steps 8) 9) and 10) are not executed by remaining CPU core startups.

Using Startup pre-initialization hook

If the application/ demo example need some activity other than above defined functionalities, user can configure the function which is called before any other initialization is executed. Example of such activity is testing the CSA and STACK.

Following are the steps to be done to configure user defined activity which is needed before startup sequence.

Step1: Define a hook function

This definition shall be as user defined code (Generally in DemoApps folder).
Considerations:

  1. Format: IFX_INLINE void <pre init function name>(cpu)
    Note
    Define such a routine with the consideration, that there shall be no function call within this.
  2. Use the information available as parameter cpu

Example code in a user defined file eg. Ifx_preInitHook.h, placed under folder/subfolder: 0_AppSw/Tricore/DemoApp:

// file: Ifx_preInitHook.h
//Example function for pre initialization Hook for startup functions.
IFX_INLINE mySysPreInitHook(uint32 cpu)
{
switch (cpu)
{
case 0:
{
//user code for cpu0: Function calls NOT allowed.
break;
}
case 1:
{
//user code for cpu1: Function calls NOT allowed.
break;
}
case 2:
{
//user code for cpu2: Function calls NOT allowed.
break;
}
case default:
{
break;
}
}
}

Step2: Configure the pre initialization function for startup sequence call

Create a file for configuring the hook. For example, Ifx_Cfg_CStart.h at ../0_Src/0_AppSw/Config/Tricore (or in DemoApp folder)

Note
This configuration, overload the macro IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(cpu), which is already defined in IfxCpu_CStart.h. !!IMPORTANT!! Don't modify this at IfxCpu_CStart.h, because this is library file.
//file: Ifx_Cfg_CStart.h
#include "Ifx_preInitHook.h" //Assuming this is the file name as in above example
#define IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(cpu) mySysPreInitHook(cpu) //This is INLINE function.