www.ti.com

Table of Contents

Application Note

Migrating Software From 8-Bit (Byte) Addressable CPUs
to C28x CPU

Veena KamathABSTRACT
While developing applications, you may assume that the device runs on a 8-bit addressable device and canface issues while porting the code to a 16-bit addressable device. This application note discusses such common
scenarios and provides a guide on how to develop application irrespective of the addressability.

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

List of Figures
Figure 3-1. Memory Allocation in C28x Core...............................................................................................................................5
Figure 3-2. Memory Allocation in Arm Core.................................................................................................................................5

List of Tables
Table 2-1. Memory Map Table..................................................................................................................................................... 2Trademarks
TMS320™ and Code Composer Studio™ are trademarks of Texas Instruments.
Arm® is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
All trademarks are the property of their respective owners.

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPU
Copyright © 2024 Texas Instruments Incorporated

1Introduction

www.ti.com

1 Introduction
The TMS320C28x is one of several fixed-point CPUs in the TMS320™ family. It has a 16-bit addressablearchitecture compared to 8-bit addressable architecture like Arm® CPUs.
In a 8-bit addressable architecture, every 8 bits of data has a unique address, where as in a 16-bit addressabledevice , every 16 bits of data has a unique address. Hence, in a 16-bit architecture, the smallest addressable
unit of memory and the smallest data type supported is 16 bits.

2 Byte vs Word Terminology
Historically, byte is defined as the smallest addressable unit of memory. Hence, technically, the size of a byteis hardware dependent: 16 bits for C28x devices and 8 bits for Arm devices. But nowadays, byte is used as asynonym of 8 bits, since majority of the device architectures are 8 bit addressable. To avoid the confusion, let us
use the terminology 8-bit bytes and 16-bit words
Byte and Word Usage in the device feature set Documentation:

From the C28x compiler's perspective, the memory size is always expressed in smallest addressable units,
which is 16 bits. This includes the memory length, code/data size provided in the linker cmd files, .map file, andso forth. The standard sizeof() function also returns the size in 16 bits.
•Memory Map Table in device-specific data sheet:
Table 2-1. Memory Map Table•MemorySize

Start Address

End Address

LS0 RAM

2K × 160x0000 8000

0x0000 87FF

LS1 RAM

2K × 160x0000 8800

0x0000 8FFF

Linker command file:
RAMLS0RAMLS1•: origin = 0x00008000,: origin = 0x00008800,

length = 0x0800
length = 0x0800.map file generated by Code Composer Studio™ (CCS):MEMORY CONFIGURATIONS
name------------RAMLS0RAMLS1•

2origin-------00008000
00008800

length-----00000800
00000800

used---00000112
00000194

unused-----000006ee
0000066c

attr---RWIX
RWIX

sizeof(uint32_t) = 2 → 2 * 16 bits

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPU
Copyright © 2024 Texas Instruments Incorporated

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

www.ti.com

Key Points to Consider

3 Key Points to Consider
3.1 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 andint8_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 anincrease 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.

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPU
Copyright © 2024 Texas Instruments Incorporated

3

Key Points to Consider•

www.ti.com

Usage of unions needs to be revisited.

3.2 Memory Size is Expressed in 16 Bits
The memory sizes mentioned in the linker cmd files, .map files are all expressed in 16 bits. The sizeof() function
always returns the size with respect to smallest addressable memory units (8 bits for Arm and 16 bits for C28x).
Be careful to not hardcode the size information in the application. One common scenario is while using
memset/cpy/cmp functions, the size parameter to these functions are in terms of smallest addressable units.

Also, note the difference in data packing after memset usage:
C28x

Arm

myStruct
000A000A 000A000A

myStruct
0A0A0A0A 0A0A0A0A

3.3 Arrays and Structures: Individual Element Offsets are Different•In C28x, there is a unique address for every 16 bits, as opposed to 8 bits in an Arm device.
Example:uint32_t
uint16_t
uint8_t4

Array32[4]Array16[4]Array8[4]= {1,2,3,4};= {1,2,3,4};= {1,2,3,4};

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPU
Copyright © 2024 Texas Instruments Incorporated

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

www.ti.com

Key Points to Consider

Figure 3-1. Memory Allocation in C28x Core

Figure 3-2. Memory Allocation in Arm Core•

While using arrays, the index-based accesses and pointer increment-based access would yield the same
results in both the devices. But if you try to use hardcoded offsets, it would produce different results.

•Same is applicable for structs. While struct.element provides the same results in both devices, the usage of(baseaddr + offset) to access struct.

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPU
Copyright © 2024 Texas Instruments Incorporated5Key Points to Consider

www.ti.com

3.4 Difference in Standard Data Type Widths
As opposed to any 8-bit addressable architecture, the sizes of int and char are different in C28x devices. For
better portability, it is highly recommended to use the width-based data types such as uint16_t, int16_t, uint32_t,int32_t, uint64_t, int64_t, float32_t, float64_t, and so forth. These data types are defined in the C28 compiler
header file stdint.h.
Note that the data types uint8_t and int8_t are not defined by the C28x compiler. C2000Ware remaps these touint16_t and int16_t data types, respectively.
TypeSizechar16 bits_Bool16 bits

short16 bits

int

16 bits

long32 bits

long long

64 bitsfloat

32 bits

double(COFF)

32 bits

double(EABI)

64 bitslong double

64 bits

Pointers

32 bits

For more details on the data types, see the TMS320C28x Optimizing C/C++ Compiler v22.6.0.LTS User's
Guide .

3.5 Dealing With 8-Bit Communication Protocols
Communication peripherals like the Controller Area Network (CAN), Serial Communications Interface (SCI) andUniversal Asynchronous Receiver/Transmitter (UART) in C28x devices support 8-bit data transfers. But note thatthe data would be stored as 16 bits in the memory. The C28x compiler does not support pragma pack(1).
Example:In this example, the function takes in uint16_t * as the input data parameter. But it only expects 8 bits of data peruint16_t type. The upper half of the uint16_t is ignored and only the lower 8 bits are transferred.

4 References••

6

TMS320C28x Optimizing C/C++ Compiler v22.6.0.LTS User's Guide
https://software-dl.ti.com/ccs/esd/documents/c2000_byte-accesses-with-the-c28x-cpu.html

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPUCopyright © 2024 Texas Instruments Incorporated

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

www.ti.com

Revision History

5 Revision History
NOTE: Page numbers for previous revisions may differ from page numbers in the current version.
Changes from Revision * (March 2023) to Revision A (April 2023)
Page• Updated the numbering format for tables, figures and cross-references throughout the document.................. 2• Updated Section 2.............................................................................................................................................. 2• Updated Section 3.1........................................................................................................................................... 3• Updated Section 3.2........................................................................................................................................... 4

SPRAD88A – MARCH 2023 – REVISED APRIL 2023
Submit Document Feedback

Migrating Software From 8-Bit (Byte) Addressable CPUs to C28x CPUCopyright © 2024 Texas Instruments Incorporated7IMPORTANT NOTICE AND DISCLAIMERTI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCEDESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS”
AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANYIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRDPARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate
TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicablestandards, and any other safety, security, regulatory or other requirements.
These resources are subject to change without notice. TI grants you permission to use these resources only for development of anapplication that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license
is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you
will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of theseresources.
TI’s products are provided subject to TI’s Terms of Sale or other applicable terms available either on ti.com or provided in conjunction withsuch TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers forTI products.
TI objects to and rejects any additional or different terms you may have proposed. IMPORTANT NOTICE
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2024, Texas Instruments Incorporated