TMS320F28377S: branching to C code (related to application code flashing) before _c_int00 function

Part Number: TMS320F28377S

Hi Team,

I have seen in multiple places in forum and notes that "No C code can be executed until _c_int00 setup routine is run where stack and variable initialization etc. will be done".

References: 

1. Running an Application from Internal Flash Memory on the TMS320F28xxx DSP (Rev. L)

2. Piccolo 3-Day Workshop, Peripheral, and Architecture Training Course Materials

3. https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/564640/ccs-tms320f28335-dspxxx_codestartbranch-asm-and-boot28-inc-files-start-up-using-c-language-rather-assembly

 

We have a part of code which related to flashing the application code which is written in c and will be run before the _c_int00 function. like below,

wd_disable:
    .if WD_DISABLE == 1
	    SETC OBJMODE        ;Set OBJMODE for 28x object code
	    EALLOW              ;Enable EALLOW protected register access
	    MOVZ DP, #7029h>>6  ;Set data page for WDCR register
	    MOV @7029h, #0068h  ;Set WDDIS bit in WDCR to disable WD
	    EDIS                ;Disable EALLOW protected register access
	    LCR _boot_main
	    LB Entry_2_Cint_00         ;Branch to start of boot._asm in RTS library
	.endif

	.end

boot_main function called before _c_int00 function. We didn't observe any issues but I want to know what can be the issues with this implementation. I have few doubts,

1. Without stack initialization what will be the stack address?

2. If I am not using any variables and functions of boot_main in main application code, still there can be any issue with the above implementation?

3. What should be the ideal way if I want to call the c function before main function?

Thanks in advance.

  • We didn't observe any issues but I want to know what can be the issues with this implementation. I have few doubts,

    2. If I am not using any variables and functions of boot_main in main application code, still there can be any issue with the above implementation?

    1&2. As long as you don't have any thing being pushed to the stack there should be no issues.

    3. What should be the ideal way if I want to call the c function before main function?

    3. The ideal way would be not to call a c function before the main function. Are you needing to call a c function before main function?

  • As long as you don't have any thing being pushed to the stack there should be no issues.

        - We had some functions in boot_main function so stack will be used. What will be the issue if we use the stack before _c_int00?

    The ideal way would be not to call a c function before the main function. Are you needing to call a c function before main function?

       - yes we have used boot_main.c function before main function which will be used for application code flashing

    What will be the starting stack address, if we don't initialize and use it before main function? Will it be continuation to the BOOT ROM stack address? (BOOT_RSVD       : origin = 0x000002, length = 0x000120     /* Part of M0, BOOT rom will use this for stack */)

  • What will be the starting stack address

    At reset, the stack pointer will start at RAMM0 or 0x000000.

    Will it be continuation to the BOOT ROM stack address?

    Yes, this is correct.

    Best,

    Ryan Ma

  • 1&2. As long as you don't have any thing being pushed to the stack there should be no issues.

       - What will be the issue if we use the stack before _c_int00?

    In my case, for boot_main() the stack will be BOOT_RSVD memory and after _c_int00 the stack for main application code will be RAMM1.

  • Hi Yedida,

       - What will be the issue if we use the stack before _c_int00?

    There should not be an any issue if using stack before _c_int00, however after _c_int00 is called then your stack will point to another location depending on the configuration you set.