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

how to locate variables @ fixed locations

hi all!

i'd like to locate a variable (e.g. version number) at a fixed location in ROM, so the firmware can check the userware's version @ startup!

userware:
int version = 1; // locate this @ 0x1000 - but how ?!

firmware:
if (*((int*)0x1000) != 1)
{
DisplayErrorMessage();
}

how can I achieve this using C166/L166 ?!

thanks in advance for any help...

Matthias

  • Ah, yet another request from someone who wants to use the _at_ keyword with an initialiser.

    Matthias, this has been discussed many times on the forum. It can be done but not easily. Search for the _at_ keyword.

    Stefan

  • Hi Matthias,
    I always use the following way to achieve what you want to do:
    1. I create a single file named version.c
    In this file I only have the following definitions
    unsigned char const far FirmwareVersion[] = {030731};
    2. Then I locate this file to a specific memory location, using the locater directive
    ?FC?VERSION%FCONST (0x57FE0)
    in the user section of the L166 locate tab of the options window.
    (in this example this is a far memory location, but this depends from your memory layout).
    3. I fetch this date in a c-function as follows:
    fmemcpy(TempBuf,0x57FE0,6);
    TempBuf is then filled with the string "030731".

    Maybe this works for you.
    regards
    Uwe