1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

aligned attribute in XC compiler

Discussion in 'Microcontrollers' started by elecLear78, Jul 21, 2017.

  1. elecLear78

    elecLear78 Member

    Joined:
    Jul 16, 2013
    Messages:
    227
    Likes:
    1
    Location:
    india
    I have seen this code

    #define PM_ROW __attribute__((space(prog), aligned(128)))
    const PM_ROW MyRowData1InFlash[] =
    { 0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,
    0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111,0x1111
    };
    const PM_ROW MyRowData2InFlash[] =
    { 0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,
    0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222,0x2222
    };

    If i do not give align(128) will the compiler not put in multiples of 128 addresses. When it is mandatory that i give this align parameter? Please advise.
     
  2. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    If you omit the align attribute the compiler will put it wherever it likes. It's only mandatory when you need it aligned.

    Mike.
     
    • Like Like x 1

Share This Page