Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed the week of November 23.

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.

TMS320F28377S: C28x endianess

Part Number: TMS320F28377S

Hi,

I'm working with a driver for our embedded device that needs integration to the customer's application.  This driver can be switched to big endian reflecting the endianess of the customer's host controller.  I would like to test if the driver's big endian adaptation works in real life.

Somewhere I might have picked up that for some of the C28x controllers it might be possible to switch the endianess.  Of course I don't mean the endianess at byte level; this is intrinsically fixed since they address memory in 16 bit chunks.  I rather mean on the word level. 

The C28x I know so far put the least significant word of a 32 bit value on the low address and the most significant one on the high address:

32-bit value: 0x12345678

C28x Memory Map (little endian word order)
------------------------------------------

  Address    ¦  Word Content
 ------------+--------------
  0x0100     ¦    [0x5678]      <-- low word  (stored first / lower address)
  0x0101     ¦    [0x1234]      <-- high word (stored second / higher address)
  0x0102     ¦    [ ...  ]
  0x0103     ¦    [ ...  ]

 ------------+--------------

  CPU reads 32-bit from 0x0100:
  +---------------------+
  ¦  0x0101  ¦  0x0100  ¦
  +---------------------+

  ¦ [0x1234] ¦ [0x5678] ¦
  ¦ high word¦ low word ¦
  +---------------------+
  ^                     ^
  MSB                  LSB

Question: is there a register to switch C28x family controllers to big-endian word order as illustrated below?

Hypothetical big endian word order
----------------------------------

  Address    ¦  Word Content
 ------------+--------------
  0x0100     ¦    [0x1234]     <-- High Word (would be at lower address)
  0x0101     ¦    [0x5678]     <-- Low Word  (would be at higher address)
  0x0102     ¦    [ ...  ]
  0x0103     ¦    [ ...  ]

 ------------+--------------


Thank you,

Mark

  • Hi Mark,

    There is no register, configuration bit, or compiler directive on the TMS320F28377S (or any C28x-based device) to switch the word order of 32-bit values in memory. The C28x architecture is inherently little-endian: the low word always resides at the lower address, and the high word at the higher address. This is a hardwired architectural characteristic, not a configurable option 1.

    This is further confirmed by how the memory model works in practice — the C28x is 16-bit word-addressable, sizeof(Uint32) returns 2 (words), and all pointer arithmetic and register layouts assume fixed little-endian word order 2. When viewing 32-bit values in memory, the low word is always at the base address 3.

    What you can do instead

    To test your driver's big-endian word-order adaptation on the C28x, you'll need to implement software-based word swapping. For example:

    // Swap word order of a 32-bit value before/after transmission
    Uint32 swap_word_order(Uint32 val) {
        return (val >> 16) | (val << 16);
    }

    This would let you emulate big-endian word order at the interface boundary (e.g., in your communication buffer) while the CPU internally continues to operate in its native little-endian format.


    1. Porting Applications to C2000 – Endianness (SPRAD88A)
    2. E2E: TMS320F28377S GPIO init code – sizeof and word addressing
    3. E2E: TMS320F28377S SHA-256 – C28 core little-endian memory view

    Best Regards,

    Zackary Fleenor

  • Thank you for your extensive reply.  I might have had a different controller in mind where the Endianess switching was possible.