SPRAD88A march   2023  – april 2023 TMS320C28341 , TMS320C28342 , TMS320C28343 , TMS320C28343-Q1 , TMS320C28344 , TMS320C28345 , TMS320C28346 , TMS320C28346-Q1 , TMS320F28P550SJ , TMS320F28P559SJ-Q1

 

  1.   Abstract
  2.   Trademarks
  3. 1Introduction
  4. 2Byte vs Word Terminology
  5. 3Key Points to Consider
    1. 3.1 8-Bit Data Types are not Supported
    2. 3.2 Memory Size is Expressed in 16 Bits
    3. 3.3 Arrays and Structures: Individual Element Offsets are Different
    4. 3.4 Difference in Standard Data Type Widths
    5. 3.5 Dealing With 8-Bit Communication Protocols
  6. 4References
  7. 5Revision History

8-Bit Data Types are not Supported

In C28x CPU-based projects, 8-bit data types are not supported. char is 16 bits wide and the types uint8_t and int8_t are not defined by the C28x compiler. C2000Ware remaps these to uint16_t and int16_t data types. For more details on the data types, see the TMS320C28x Optimizing C/C++ Compiler v22.6.0.LTS User's Guide.

However, the C28x compiler provides intrinsic __byte() for byte accesses. For more details, see the https://software-dl.ti.com/ccs/esd/documents/c2000_byte-accesses-with-the-c28x-cpu.html.

  • While porting an application from an 8-bit addressable architecture, such as Arm to C28x, you may find an increase in memory requirement due to this difference.

    Example:

    struct
    {
       uint8_t a;
       uint8_t b;
       uint16_t c;
    } myStruct; 

    In an Arm device, the size of myStruct would be 8 + 8 + 16 = 32 bits. Whereas, in C28x, the size would be 16 + 16 + 16 = 48 bits.

  • Since the int8 or char data types in C28x is 16 bit wide, the compiler will not do a wraparound at 0xFF while performing arithmetic or shift operations.

    Example:

    uint8_t a = 0xFF;
    a += 1;
    if (a == 0)
    {
         //Condition is true for Arm and false for C28x
    }
  • While converting larger data types to smaller ones or vise versa, care should be taken to properly typecast, use masks, and be aware of the device endianness. The C28x-based devices are little endian devices.
    GUID-20230313-SS0I-GL1K-Q50Z-7ZGMCZZ8XF83-low.png
  • Usage of unions needs to be revisited.
    GUID-20230206-SS0I-WR4Z-2NBK-QPSDPNWFMK5J-low.png