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.

TMS320F28379D: EtherCAT FoE Solution byte alignment issue

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software:

Hello. I'm unable to correctly execute the FoE on the TMS320F28379D. I am using SSC v5.11 to generate the code. I've compared the generated code in v5.11 to that on v5.12 for the F28388 and the issue appears to be there as well.

In the generated code we have this structure being used in ecatfoe.h:

 /** \brief Complete FoE datagram*/
typedef struct MBX_STRUCT_PACKED_START
{
      TMBXHEADER        MbxHeader; /**< \brief Mailbox header*/
      TFOEHEADER        FoeHeader; /**< \brief FoE header*/
    UINT16              Data[((MAX_MBX_DATA_SIZE)-(FOE_HEADER_SIZE)) >> 1]; /**< \brief FoE Data buffer*/
}MBX_STRUCT_PACKED_END
TFOEMBX;

where 
/**
 * \brief Mailbox header
 */
typedef struct MBX_STRUCT_PACKED_START
{
    UINT16 Length;  /**< \brief Length*/
    UINT16 Address; /**< \brief Address*/

    UINT16 Flags[1]; /**< \brief Flags*/

#define MBX_OFFS_TYPE     0      /**< \brief Protocol type offset*/
#define MBX_MASK_TYPE     0x0F00 /**< \brief Protocol type mask*/
#define MBX_SHIFT_TYPE    8      /**< \brief Protocol type shift*/
#define MBX_OFFS_COUNTER  0      /**< \brief Protocol counter offset*/
#define MBX_MASK_COUNTER  0xF000 /**< \brief Protocol counter mask*/
#define MBX_SHIFT_COUNTER 12     /**< \brief Protocol counter shift*/
} MBX_STRUCT_PACKED_END TMBXHEADER;
/** \brief FoE header*/
typedef struct  MBX_STRUCT_PACKED_START
{
    UINT16        OpCode; /**< \brief OpCode
                             *
                             * 1 : RRQ<br>
                             * 2 : WRQ<br>
                             * 3 : DATA<br>
                             * 4 : ACK<br>
                             * 5 : ERR<br>
                             * 6 : BUSY*/
    union MBX_STRUCT_PACKED_START
    {
        UINT32        Password; /**< \brief Password (used in Read request and Write request). 0 if unknown*/
        UINT32        PacketNo; /**< \brief Packet number (used in DATA and ACK datagram)*/
        UINT32        ErrorCode; /**< \brief Error code (used in ERR datagram)*/
        struct MBX_STRUCT_PACKED_START
        {
            UINT16    Done; /**< \brief Done indication (used in BUSY datagram)*/
            UINT16    Entire;  /**< \brief Entire indication (used in BUSY datagram)*/
        }MBX_STRUCT_PACKED_END
        Busy; /**< \brief Busy variable*/
    }MBX_STRUCT_PACKED_END
    Cmd; /**< \brief Command field*/
}MBX_STRUCT_PACKED_END
TFOEHEADER;

This TMBXHEADER size is 6 bytes (48 bits). This header is padding itself to be 32bit aligned. That pushes off the first member of TFOEHEADER (the opCode) to be at the wrong address.. thereby making all members offset incorrectly.

This is what I am seeing in debugging:

That 0x0002 is the correct FoeHeader.opCode as shown in the memory browser. However the struct shows it as 0x1836.

Is there something I am missing? I assume this was delivered as working? 

  • Hi,

    We provide an eCAT + FoE software example for F2838x device, but not for F2837x device. Hardware wise, are you using the ET1100 device with f2837x or something else?

    Best,

    Kevin

  • Hi Kevin,

    Thanks for the response. Yes let me clarify. I am using an F2837x device with an ET1100 IC.

    I followed the guide in the controlSUITE\development_kits\TMDSECATCND379D_V1.0\TMDSECATCNCD379D_EtherCAT_Solution_Ref folder to enable C28x projects in SSC v5.11. I then enabled related BOOTSTRAP and FOE flags. This code is what I was executing. As you can see, it doesn't align correctly with FoE.

    I mentioned the F2838x device because following that platform's example I did a diff on the code. That diff looks pretty much the same with regards to how FoE works. Since both of these microcontrollers are of the C28x series, and do not allow byte packing, I assume they would both have this same issue. 

    My main point is that I am unable to get the F2837x work correctly. I viewed the F2838x and found that it should exhibit the same problem given it is the same series cpu. Now I am here, confused as to why mine doesn't work, and how the F2838x could work. 

  • I've been digging deeper into this to determine how to resolve it. There are a lot comparisons with regards to the FoE length that do not make sense due to the alignment i.e. the length provided by the master is incorrect because the comparison being done is including the padding (FOE_HEADER_SIZE). The sending as well is sending the struct raw with the padding. I assume that is causing an offset..? 

    Is there any way to speak with someone regarding this to better understand what you have intended to support? 

  • I have been able to send an FoE transaction correctly in the following configuration: 

    I'm using the generated code for the F2838x in SSC v5.12. I'm using the HAL file from the TMDSECATCNCD379D_EtherCAT_Solution_Ref project. 

    While I do see a some new functions for copying that could help, it doesn't appear they are being used. I'm not sure why this is working but it is...