This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with local arraydeclaration/address parameter passing

l.s.,

Has anyone experienced problems with declaring a local array and passing the first element of the array address as a parameter of a function?

When this is done(sometimes....) the array is in C: memory. When the array is declared static globally the problem does not occur, the array is in X: mem.

Used are RTX tiny and reentrant functions.

***.

Parents Reply Children
  • Hi Franz,

    Thanks for your reply, i needed more time due to beautiful weather and a day off.

    Below some sample code. When 'BYTE nvm_value[2];' is declared locally in this function a C mem address is passed to STOR_GetEqualizerPreset. When declared globally a X mem address is passed.

    I always forget to select the correct toolchain, sorry, it is C51.

    regards, ***.

    ERRCODE sp_SetEqualizerPresets(void) reentrant
    /***********************************************************************************/
    /* Input(s) : */
    /* Output(s) : */
    /* Description : */
    /***********************************************************************************/
    {
    ERRCODE Err = ERR_OK;
    BYTE index;
    BYTE equalizer_word = 0;
    BYTE word_1_lsb = 0;
    BYTE word_2_lsb = 0;
    //BYTE nvm_value[2];
    WORD Address;
    WORD Value;

    for(index = 0; index < MAX_EQUALIZER_COEFFICIENTS; index = index + 2)
    {
    STOR_GetEqualizerPreset(index, &nvm_value[0]);

    Value = nvm_value[0];
    Value <<= 8;
    Value = Value | nvm_value[1];

    if((equalizer_word % 2) == 0)
    {
    Address = EQUALIZER_RAM_BASE_WORD_1 + word_1_lsb;
    word_1_lsb++;
    }
    else
    {
    Address = EQUALIZER_RAM_BASE_WORD_2 + word_2_lsb;
    word_2_lsb++;
    }
    equalizer_word++;


    sp_WriteEqualizer(Address , Value);

    }
    return Err;
    }

  • As it says at the top of the form for submitting items to this forum (3rd bullet point), please use the < pre > and < /pre > tags when posting code (but without the extra spaces) - then your layout will be preserved.