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.

Compiler/TMS320F28335: Alternative attribute for „__packed__“.

Part Number: TMS320F28335
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: TI C/C++ Compiler

Hello,

 

I am working on an EtherCat Slave. To implement the slave the EtherCat Technology Group provides the Slave Stack Code [1]. This Code uses structs in combination with pointer arithmetic. This makes it necessary to prohibit dummy bytes in structs, which are automatically inserted by the compiler. Usually the “__packed__” attribute can be used, to tell the compiler that for a particular struct no dummy bytes are allowed. In [2] I figured out that the “__packed__” attribute is not supported in the C2000 compiler.

 

Is there any other way to prohibit dummy bytes in structs with the C2000 compiler?

Regards, Stephan

 

[1] https://www.ethercat.org/en/products/54FA3235E29643BC805BDD807DF199DE.htm

[2] http://processors.wiki.ti.com/index.php/GCC_Extensions_in_TI_Compilers#Type_Attributes


  • Hi user5183717,

    Our EtherCAT expert is out of the office for this week. He will address this when he comes back.

    The C2000 is a 16-bit word machine. Meaning the smallest amount of data it can access is 16-bits. So, a byte is represented as a 16-bit word.

    I do not believe there is a way to pack the data as you want on the C2000. But I will let our expert clarify. You may need to modify the way the data is accessed in this case.

    sal
  • Hi Sal,

    thank you for your answer. Is the EtherCat expert allready in house? I did modity the way the data is accessed. This works now for that particallar process data image I am using. But I am scared that when I change the data structure, the problem comes back.

    I figured out that the compiler is inserting a 16bit dumy word for the following struct:

    typedef struct OBJ_STRUCT_PACKED_START {
    UINT16 u16SubIndex0;
    UINT32 SI1; /* Subindex1 - Reference to 0x7000.1 */
    UINT32 SI2; /* Subindex2 - Reference to 0x7000.2 */
    UINT32 SI3; /* Subindex3 - Reference to 0x7000.3 */
    UINT32 SI4; /* Subindex4 - Reference to 0x7000.4 */
    UINT32 SI5; /* Subindex5 - Reference to 0x7000.5 */
    UINT32 SI6; /* Subindex6 - Reference to 0x7000.6 */
    UINT32 SI7; /* Subindex7 - Reference to 0x7000.7 */
    UINT32 SI8; /* Subindex8 - Reference to 0x7000.8 */
    UINT32 SI9; /* Subindex9 - Reference to 0x7000.9 */
    UINT32 SI10; /* Subindex10 - Reference to 0x7000.10 */
    UINT32 SI11; /* Subindex11 - Reference to 0x7000.11 */
    UINT32 SI12; /* Subindex12 - Reference to 0x7000.12 */
    UINT32 SI13; /* Subindex13 - Reference to 0x7000.13 */
    UINT32 SI14; /* Subindex14 - Reference to 0x7000.14 */
    } OBJ_STRUCT_PACKED_END
    TOBJ1600;

    The dumy word is placed between member 0 and member 1.

    That is the source for my error. Is there a way to packt structs for cases like this?

    Regards, Stephan

    
    

  • Hi Stephen,

    For C28x, a 32-bit access must occur on a 32-bit boundary. This is why there is a dummy word between member 0 and member 1.

    Regards,
    sal

  • Stephan,
    There is no way around it, we have to make sure the SW knows about the padded bytes/words and work around it in code.

    Please take a look at SW collateral we have released in controlSuite for EtherCAT on C28.
    C:\ti\controlSUITE\development_kits\TMDSECATCND379D_V1.0

    If you follow the user guide (assuming you are already an ETG member), SPRUIG9, it tells how to apply patches to the EtherCAT stack to get it running on C28. The patches are at this time for SSC V5.11 only.

    If you generate the slave stack source code along with the echoback example, it shows how we addressed the issue you are talking about.

    Please let us know what you think or if you have any further questions.


    Best Regards
    Santosh Athuru