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.

F28M36x-c28 core - compiler/optimizer problem?

Other Parts Discussed in Thread: SYSBIOS

Hi,

I just ran into a very strange problem. I found already the solution but I would appreciate if someone can explain to me why this is a problem.

I'm just building a bootloader for the F28M36x chip, the following code does not work correctly within the secondary program, which is started by my bootloader (which runs in a task of SYSBIOS)

Code:

StdError IpcDriver::registerCommand(IpcCommand cmd, IpcCallbackFxn clbFxn)
{
    StdError ret = E_GENERAL_ERROR;

    for ( u32 i = 0; i < maxIpcCommands; i++ )
    {
        if ( this->cmdList.fxn[i] == 0 )
        {
            this->cmdList.cmd[i] = cmd;
            this->cmdList.fxn[i] = clbFxn;
            ret = E_SUCCESS;
            break;
        }
    }

    return ret;
}

The above code works fine if the Program is started by the debugger but if it is started just by a function-pointer call to _c_int00() just this function does not work at all. In fact this function would then never set the cmd and clbFxn values to the list. (except if the debugger pauses execution and then steps over every line of this function)

I then modified it to the following:

StdError IpcDriver::registerCommand(IpcCommand cmd, IpcCallbackFxn clbFxn)
{
    StdError ret = E_GENERAL_ERROR;

    for ( u32 i = 0; i < maxIpcCommands; i++ )
    {
        volatile IpcCallbackFxn tempFxn = this->cmdList.fxn[i];
        if ( tempFxn == 0 )
        {
            volatile IpcCommand newCmd = cmd;
            this->cmdList.cmd[i] = newCmd;
            tempFxn = clbFxn;
            this->cmdList.fxn[i] = tempFxn;
            ret = E_SUCCESS;
            break;
        }
    }

    return ret;
}


This works also in the secondary program. Also if it is just in run mode.

I find it very strange that it makes a difference if the program is started by the debugger or via a function call of a previous program.

would be glad if someone can explain the cause.

regards

Andreas