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

Allocating Data Structure to Specific Memory Location

I have data structures of >166 Kbytes of data elements. I have declared these structures as:

typedef struct CodeTiming_tag
{
ubyte code_id;
ubyte algo_id;
uword timing_parameter[MAX_TABLE_ENTRY];
}CodeTimingType;

extern CodeTimingType xhuge current_code;
extern CodeTimingType xhuge next_code;
Compiling the source file that defines the "current_code" and "next_code" structures, I get the following error:
Error C172: 'FDATA0': length exceeded: act=32770, max=16384.

MAX_TABLE_ENTRY values greater than 1024 resulted in compiler error. I also did get an 'HDATA0' error, but it went away when I specifying to the LARGE memory model.

I am not declaring any FAR data in my code. Comments?

I am using a PHYTEC C167 development board 2MRAM and 2MROM, with the following default memory layout (specified in Start167.a66):

ROM (1st Meg) 0x0-0xFFFFF
RAM (1st Meg) 0x100000-0x1FFFFF
ROM (2nd Meg) 0x200000-0x2FFFFF
RAM (2nd Meg) 0x300000-0x3FFFFF

I would like to allocate the structure starting at the RAM 2nd Meg location. Suggestions?

Thanks for your help,
Phong

  • I compiled your example and didn't have any problems.

    I would like to allocate the structure starting at the RAM 2nd Meg location. Suggestions?

    There is a knowledgebase article on that:
    http://www.keil.com/support/docs/586.htm

    Regards,
    - mike

  • I compiled the project using uVision 2, with default settings in the C166 page under the "Options for Target" selection (right click on Project name in File window).

    How did you compile the example? (command line, what option settings, etc.)

    Thanks,
    Phong

  • I compiled the project using uVision 2, with default settings in the C166 page under the "Options for Target" selection

    You MUST specify your memory layout in the "Options for Target" (ROM and RAM memory ranges). That insformation will be used by the linker to allocate memory. Memory configuration in Start167.a66 is used for initializing the BUSCONx and ADDRSELx registers; it is not known to the linker.
    I compiled the following code:

    typedef struct CodeTiming_tag
    {
    char code_id;
    char algo_id;
    int timing_parameter[32770];
    }CodeTimingType;
    
    CodeTimingType xhuge current_code;
    CodeTimingType xhuge next_code;
    
    void main()
    {
    }
    
    leaving all the settings with there default values APART FROM memory layout in the "Options for Target".

    - mike

  • Mike,

    I did define the memory layout. Sorry I didn't explain this correctly in previous post.

    I created a new project and retried what you did, and did not get an error during compile.

    In my old project, I do get an error whenever the array size is larger than 1024.

    In my code, I am moving data from this large structure to a smaller buffer (255 bytes) specified as sdata type, and setting the PEC source pointer to this smaller buffer for automatic PEC data transfer to a capture & compare register. Wonder if this has anything to do with it.

    Anyways thanks for the input. Will poke around some more.

    Phong