C2000 DSP uses 16-bit bytes (CHAR_BIT=16), unlike the typical 8-bit byte systems. This difference affects memory addressing and zero-copy type conversions. The memory layout for U32 and floating-point values on C2000 is distinct from common 8-bit little-endian systems, as shown in comparative tables. Additionally, C2000 requires strict address alignment: 32-bit data must be aligned on 2-byte boundaries.
uint16_t buffer[8];
uint32_t t32;
/* In fact, the following two both read memory as [0][1] and convert to u32 */
// On a normal CPU, the following would read memory as [1][2] and convert to u32
t32 = *(uint32_t *)(& buffer[1]);
// On a normal CPU, the following is the correct zero-copy way to read [0][1]
t32 = *(uint32_t *)(& buffer[0]);
/* The following two will instead read memory as [2][3] and convert to u32 */
t32 = *(uint32_t *)(& buffer[3]);
t32 = *(uint32_t *)(& buffer[2]);
C2000's Special Memory Layout
The C2000 DSP is the one-and-only modern chip with 16-bit bytes, so its memory addressing differs from the usual CHAR_BIT == 8.
This needs extra attention when doing zero-copy casts on protocol-layer data. I've dealt with it before, but today I ran into it again and had forgotten all about it, so I had to manually test it again. Let me write it down.
In addition, it has strict access-alignment requirements: 32-bit data also requires addresses to be aligned to 2 bytes. Example: