TMS320F28377D: TMS320F28377D Stack Pointer Reset issue.

Part Number: TMS320F28377D

Tool/software:

Hi Team,
i tyring to jump my Application as well as reset Stack pointer but Get some Error in Assembly level or what I don't understand so it' s Great help for resolve this issue here I'm sharing code and Respected Error as below.



above is code Snip.

below as error:-

Description Resource Path Location Type
#18 expected a ")" main.c /Power_Convt_SW_New_DSP line 292 C/C++ Problem.

Regards,

  • Hello,

    Is the JumpToApplication() function code that you wrote? Or is this provided by one of TI's software packages?

    Best Regards,

    Delaney

  • Hi Ujwal, 

    Can you send me your code as text so I can test it out?

    Best Regards,

    Delaney

  • Hi Delaney,

    Sure will share code so you might evolute itself, if possible to you come online like TeamViewer or anything so you can check it out rapidly all my hardware stuff it ready.

    Regards,
    Ujwal AP. 

  • Hi Ujwal,

    Can you send the code through E2E first for me to try? Since it is a build error, I should be able to replicate easily without hardware.

    Best Regards,

    Delaney

  • void JumpToApplication(void)
    {
    //#if 0
        // Define a function pointer to the application start address
        void (*appStart)(void);
    
        // Get the reset vector address (address of the application's reset handler)
        appStart = (void (*)(void))(*((volatile uint32_t *)(APPLICATION_FLASH_START_ADDRESS + 0x4)));
    
        // Disable interrupts
        DINT;
    
        // Set the stack pointer to the application's stack pointer
        uint32_t appStackPointer = *(volatile uint32_t *)APPLICATION_FLASH_START_ADDRESS; // Get the stack pointer from the application's start address
        __asm(" MOV     DP, %0" : : "r" (appStackPointer)); // Set the stack pointer
    
        // Jump to the application
        appStart(); // Call the application
    //#endif
    /*    // Disable interrupts
        DINT; // Disable global interrupts
    
        // Set the Stack Pointer (SP)
        asm(" MOV     DP, %0" : : "r" (STACK_START_ADDR)); // Set Data Pointer to stack address
        asm(" MOV     SP, %0" : : "r" (STACK_START_ADDR)); // Set Stack Pointer to stack address
    
        // Set the Program Counter (PC) to the application start address
        asm(" MOV     DP, %0" : : "r" (APPLICATION_FLASH_START_ADDRESS)); // Set Data Pointer to application address
        asm(" MOV     PC, %0" : : "r" (APPLICATION_FLASH_START_ADDRESS)); // Set Program Counter to application address
    
        // Set the Program Counter (PC) to the application start address
        AppEntry appEntry = (AppEntry)(APPLICATION_FLASH_START_ADDRESS); // Cast the application start address to a function pointer
        appEntry(); // Jump to the application
    */
        /*    // Define the new stack pointer location
        // This should be a valid RAM address where the stack will start
        volatile Uint32 *newStackPointer = (volatile Uint32 *)0x2000; // Change this address as needed
    
        // Set the stack pointer to the new location
        // In C, you can't directly assign to SP, so you need to use assembly
        asm(" MOV     A, newStackPointer"); // Load the address into A register
        asm(" MOV     SP, A");              // Move the value in A to the stack pointer
         */
    /*
        // Get the application's stack pointer value from the start of the image
        uint32_t app_sp = *((uint32_t *)APP_START_ADDRESS);
    
        // Get the application's entry point (Reset Handler)
        AppEntryPoint app_entry = (AppEntryPoint)(*((uint32_t *)(APP_START_ADDRESS + 4)));
    
        __asm(" MOV SP, @_stack_top");
        // Reset the stack pointer (SP)
        (__asm__ volatile ("MOV SP, %0" : : "r" (app_sp) : ));
    
        // Jump to the application entry point
        app_entry();
    */
    
    void main(void)
    {
        //ReceiveCANData();
        JumpToApplication();
    }
    }

    hey Delaney here sharing function and it calling stage from main 

    __asm(" MOV DP, %0" : : "r" (appStackPointer)); // Set the stack pointer
    above line will spotted on "linenum=15" for error

    error: Description Resource Path Location Type
    #18 expected a ")" main.c /CPS_SW_GEN5_New_DSP line 294 C/C++ Problem


    regards
    Ujwal AP. 

  • Hi Ujwal,

    I apologize for the delay. To update, I have copied your code into a project and am getting the same issue as you are seeing. Unfortunately, I have not been able to resolve the build warning after the adjusting the code, currently working with the compiler team to see what may be causing this.

    Best regards,

    Delaney

  • Thanks Delaney for your prompt Response, but we are curiously looking for solution,

    tell me if any thing required from my end, so i'll provide and we can mitigate this issue.
    awaiting for your solution.

    Thanks,
    Ujwal AP. 

  • Hi Ujwal,

    From our compiler expert:

    asm statements are not specified in the C or C++ standards. That particular variant comes from GCC. Our clang-based compilers (tiarmclang and c29clang) support it. 

    Best Regards,

    Delaney

  • Hi Delaney!!!

    Thanks, Respond,

    but how i can resolve this issue?
    If you can give me your asm statements just Verified by you so, i can implement nullify particular challenge.

    Awaiting for your good response.

    Regards,
    Ujwal AP.