This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
In 18.1.3 compiler files, what is the purpose of function "__TI_auto_init_template" from autoinit.c file?
Can you explain the flow of below code snippet?
uint16_t initial_WDT;
if (WDTCTL_ptr)
{
initial_WDT = *WDTCTL_ptr;
*WDTCTL_ptr = HOLD_WDT;
}
run_cinit();
if (WDTCTL_ptr)
*WDTCTL_ptr = RESTORE_WDT(initial_WDT);
Thanks,
Subha.
Subha,
__TI_auto_init_template is a helper function. It is invoked from other functions such as __TI_auto_init in autoinit.c. __TI_auto_init is part of the C/C++ runtime environment initialization and invoked from _c_int00.
For details, refer to the "System Initialization" section of the TMS320C28x Optimizing C/C++ Compiler User's Guide.
Ajay
I referred that particular section.
I want to know what this particular snippet of code do?
uint16_t initial_WDT;
if (WDTCTL_ptr)
{
initial_WDT = *WDTCTL_ptr;
*WDTCTL_ptr = HOLD_WDT;
}
run_cinit();
if (WDTCTL_ptr)
*WDTCTL_ptr = RESTORE_WDT(initial_WDT);
What is the watchdog functionality in __TI_auto_init_template function?
Thanks
Subha.
The code snippet disables and restores the watchdog timer around the call to run_cinit() if WDTCTL_ptr is not NULL. WDTCTL_ptr is NULL for C28x and this code does not run on C28x. autoinit.c is shared across multiple architectures.
Hi Ajay,
Could you please tell me what and all those macro values are?
And where to get them from.
I think I cannot get some values!
There must be a document where I can get the details on autoinit. I checked the compiler manual, spru514v and got the flow, but I really need to have some clarity on the values for watchdog register.
TI releases several different C/C++ compilers. Nearly all the RTS source code is shared between all these compilers, including the file autoinit.c. So, there is code in this file that is never used by the C28x compiler, but is used by other compilers.
The rest of this post discusses lines of code which are in autoinit.c. Start with ...
/*****************************************************************************/ /* Standard top-level autoinit */ /*****************************************************************************/ static __inline __attribute__((always_inline)) void __TI_auto_init_template(int RUN_BINIT, int RUN_PINIT, volatile uint16_t* WDTCTL_ptr) {
Because of the always_inline attribute, every call to this function is inlined. It is not exactly the same as a long macro, but it is similar.
Next, consider ...
DEFINE_SPECIALIZATION(".text:__TI_auto_init_nobinit") void __TI_auto_init_nobinit(void) { __TI_auto_init_template(0, 1, NULL); } DEFINE_SPECIALIZATION(".text:__TI_auto_init_nopinit") void __TI_auto_init_nopinit(void) { __TI_auto_init_template(1, 0, NULL); } DEFINE_SPECIALIZATION(".text:__TI_auto_init_nobinit_nopinit") void __TI_auto_init_nobinit_nopinit(void) { __TI_auto_init_template(0, 0, NULL); }
Each of these functions calls __TI_auto_init_template with different arguments. The boot routine, which is in the source file boot28.asm, has this instruction ...
LCR #__TI_auto_init
The linker maps the symbol __TI_auto_init to one of the auto_init variants implemented in autoinit.c. In the specific case of the C28x compiler, the linker always chooses from among the three functions I show above. For example, the symbol __TI_auto_init may be mapped to the symbol __TI_auto_init_nobinit_nopinit.
For your purposes, the important detail to notice is that every instance of the __TI_auto_init_template that may ever be called has NULL as the last argument. This means the parameter WDTCTL_ptr is always NULL. When the call to __TI_auto_init_template is inlined, and every instance of WDTCTL_ptr is replaced with NULL, all of the code related to the watchdog timer is removed at compile time. Thus, in the case of the C28x compiler, no watchdog timer code is present in the autoinit function.
Thanks and regards,
-George
Hi George,
Thank you for elaborating.
I understand that WDTCTL_ptr is always NULL for c28x case.
Earlier, we need the watchdog macros values and related information, to be added as a part of the documentation process. But since c28x has no usage then we can remove it.
Regards
Gurusha
Please search the C28x Embedded Application Binary Interface for the sub-chapter titled Copy Tables and Variable Initialization. Here is a key passage:
The assignment of handler indexes is not fixed; the linker reassigns indices for each application depending on what decompression routines are needed for that application. The handler table is generated into the .cinit section of the executable file.
So it is the linker which lays out the table that is being processed by this C code. The handler comes from an entry in that table. To understand it fully requires reading through all of this sub-chapter.
Thanks and regards,
-George