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.

Question about the #pragma pack(n)



Hi Team,

My customer would like to use the function below:

We want to use a 1 byte alignmen #pragma pack(1)
How do we do that with your TI compiler?

Examples
Arm Compiler for Embedded User Guide Version 6.17
Compiler User Guide: #pragma pack(n) (keil.com)\

If the C2000 can do it, do we have some material tell me how to do.

Thanks!

Jenson

  • For general background on the C28x compiler, please see the C28x compiler manual.

    If the C2000 can do it

    Unfortunately, the C28x compiler does not support packing members of a structure.

    Thanks and regards,

    -George

  • HI,

    I have started witch TI last week and I am currently porting old, good checked code from MCHP, STM32 etc.to C28035 and I have block on the unions and structures.

    George - is it possible that in 2022 compilers can not make packed structures????

    And I have to transfer 32 bytes by SCI when I have 4 byte-length variables to transfer?

    I can not belive it Disappointed

    Regards

    Mariusz

    P.S.

    I know how to pack and unpack myself, but last time when i did it was circa 30 years ago!

    MD

  • I only have a vague idea of what this ...

    I have to transfer 32 bytes by SCI when I have 4 byte-length variables to transfer?

    ... means.  But I am confident the article Byte Accesses with the C28x CPU will be helpful.

    Thanks and regards,

    -George

  • Hi George,

    I have found your suggestion yesterday in another threat and now I am a bit smarter about c2000 Slight smile

    I have adapted my unions and other side parsers and everythng works now Slight smile

    So, I remember from the very past times the discusions about "byte" if it should be 8 bit forever or should be a smallest part of the data in the particular micro.

    This is academic discurs, but for me byte should be 8 bits long forever.

    I am working in environment with 64 bits in Windows PC, 32 bits in STM, 24 bits (quite specific) in PIC24Fxxx, rare with pure 16 bits MCHP DSP' and 8 bits in PIC16F/PIC18F.

    From this perspective 8 bits for universal byte looks good and consistient, when the micro has more than 8bits in "byte", you should understand variables boundaries while modifying linker scripts and this is easy for me to switch basing on byte.

    From the C level pure 8 bits byte is usefull and (for me) operations with __byte from c2000 are unnatural because compilers from systems mentioned above don't needs such operations.

    Anyway, my first week with c2000 is over. - it looks good for me for the future:).

    Thank you for the attention Slight smile

    I have another "subject" for now, but I create new thread for this.

    Regards