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.

How to allocate an entire buffer in the same page?

How can I ensure that all elements of a buffer will be on the same page.

ex. 

 Uint16 buffer[32];

I need to make sure that the entire buffer will be on the same page because it will be accessed using direct addressing on a assembler routine.

 

  • Ari,

    The linker command file (.cmd) gives you the ability to define this buffer as its own section and place it exactly where you want it:

    In the C file:

    #pragma    DATA_SECTION(buffer,"BufferSect");
    Uint16 buffer[32];

    In the .cmd file:

    MEMORY
    {
       PAGE 0:    /* Program Memory */
       PAGE 1:    /* Data Memory */
       MYRAM:    origin = 0x008000, length = 0x000020
    }

    SECTIONS
    {
       BufferSect   :> MYRAM,  PAGE=1
    }

    Regards,
    Dave Foley

     

  • Hi Ari,

    while David's method works I prefer to use DATA_ALIGN pragma directive. This way you don't have to create additional memory section. So you don't hav to edit linker command file.

    Regards, Mitja