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.

why compiler5.0.1 allocate 32-bit address to a 16-bit variable ?

ccsv5, big-edian device,32bit CPU

INVDRAMParmGrop1 (RW):  origin = 0x08011500  length = 0x100

.invsectionGrop101 : > INVDRAMParmGrop1, PAGE = 1
.invsectionGrop102 : > INVDRAMParmGrop1, PAGE = 1

#pragma DATA_SECTION( invVoltPwrAB,".invsectionGrop101");
#pragma DATA_SECTION( invVoltPwrBC,".invsectionGrop102");

volatile sint16 invVoltPwrAB = 0; 
volatile sint16 invVoltPwrBC = 0;

I didn't find the option about 32-bit align set .Is there something wrong about my compiler set?

  • Follow the question above,in the same project,two struct variables will be allocate diffrent address with diffrent code.What's the compiler's principle? 

    INVDRAMParmGrop3 (RW):  origin = 0x08011700  length = 0x100

    .invsectionGrop301 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop302 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop303 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop304 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop305 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop306 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop307 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop308 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop309 : > INVDRAMParmGrop3, PAGE = 1
    .invsectionGrop310 : > INVDRAMParmGrop3, PAGE = 1

    #pragma DATA_SECTION( CtrlWordChannelSel,".invsectionGrop301");
    #pragma DATA_SECTION( invCtrlModeSel,".invsectionGrop302");

    …………

    #pragma DATA_SECTION( MainCtrlWordMode4,".invsectionGrop309");
    #pragma DATA_SECTION( MainStsWordMode4,".invsectionGrop310");

    1.the compiler allocate the struct in wrong address,which is 16-bit.This address is part of ctrlwordchannelsel's.

    struct1  MainCtrlWordMode4;

    struct2  MainStsWordMode4;

    2.the compiler allocate the struct in right address 0x08011720,which is 32-bit.

    struct1  MainCtrlWordMode4 = {0};

    struct2  MainStsWordMode4 = {0};

  • fan Linlin said:
    I didn't find the option about 32-bit align set .Is there something wrong about my compiler set?

    I'm not sure I understand.  I think you expect invVoltPwrAB and invVoltPwrBC to be right next to each other, and not have a 2-byte hole in between them.  I presume I am correct about that.

    I am unable to reproduce this behavior.  I'd appreciate if you would package up your CCS project and attach it to your next post.

    Thanks and regards,

    -George

  • You're right.I do expect invVoltPwrAB and invVoltPwrBC to be right next to each other.

    I'sorry I can't post my code because it's our product.And there isn't enough time to do more test.So I try to find any possible options about this problem. So is there anyting usefull except code? The CCS project propertise?How can I do?

  • Please show the options used when compiling and linking.  And attach your linker command file.  That might reveal something useful.

    Another method to consider ... Supply those data definitions in hand-coded assembly.  This thread discusses some of the details of that method.

    Thanks and regards,

    -George

  • I'm sorry to reply so late.

    The options is as follows:

    2475.sys_link.zip

    I will try to define and initialize variables in assembly .

  • I am still unable to reproduce your results.  The only way for us to move forward is for you to send in your project.  Would you be willing to do that via private channels?

    Thanks and regards,

    -George