ISD91200 Series Technical Reference Manual
Release Date: Sep 16, 2019
- 254 -
Revision 2.4
5.10.4.13
Byte Endian
APB access to the SPI controller is via the 32bit wide TX and RX registers. When the transfer is set as
MSB first (SP1I_CTL.LSB = 0) and the SPI1_CTL.BYTEENDIAN bit is set, the data stored in the TX
buffer and RX buffer will be rearranged such that the least significant
physical
byte
is processed first.
For TXBITLEN =0 (32 bits transfer), the sequence of transmitted/received data will be BYTE0, BYTE1,
BYTE2, and then BYTE3. If TXBITLEN is set to 24-bits, the sequence will be BYTE0, BYTE1, and
BYTE2. The rule of 16-bits mode is the same as above.
Byte3
Byte0
Byte1
Byte2
SPI->TX[0]/SPI->RX[0]
TX/RX Buffer
Byte3
Byte0 Byte1 Byte2
LSB = 0 (MSB first)
N/A
Byte0 Byte1 Byte2
N/A
Byte0 Byte1
N/A
TX_BIT_LEN = 24 bits
TX_BIT_LEN = 16 bits
TX_BIT_LEN = 32 bits
MSB first
MSB first
MSB first
MSB first
[31:24]
[7:0]
[15:8]
[23:16]
TX/RX Buffer
Byte0
Byte3 Byte2 Byte1
N/A
Byte2 Byte1 Byte0
N/A
Byte1 Byte0
N/A
TX_BIT_LEN = 24 bits
TX_BIT_LEN = 16 bits
TX_BIT_LEN = 32 bits
MSB first
MSB first
MSB first
Time
N/A
N/A
Byte0
N/A
TX_BIT_LEN = 8 bits
MSB first
N/A
N/A
Byte0
N/A
TX_BIT_LEN = 8 bits
MSB first
BYTE_ENDIAN = 1
BYTE_ENDIAN = 0
Figure 5-57 Byte Re-Ordering Transfer
Byte ordering can be a confusing issue when converting from arrays of data processed by the CPU for
transmission out the SPI port. The CortexM0 stores data in a little endian format; that is the LSB of a
multi-byte word or half-word are stored first in memory. Consider how the CortexM0 stores the following
arrays in memory:
3. unsigned char ucSPI_DATA[]={0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
4. unsigned int uiSPI_DATA[]={0x01020304, 0x05060708};
0x05
0x08
0x07
0x06
0x01
0x04
0x03
0x02
0x08
0x05
0x06
0x07
0x04
0x01
0x02
0x03
0x20000000
0x20000004
0x20000008
0x2000000c
Byte3
Byte0
Byte1
Byte2
Byte3
Byte0
Byte1
Byte2
0x20000010
0x20000014
unsigned char ucSPI_DATA[]={0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
unsigned int uiSPI_DATA[]={0x01020304, 0x05060708};
ucSPI_DATA[]
→
uiSPI_DATA[]
→
RAM Address
RAM Contents
[7:0]
[31:24]
[23:16]
[15:8]
APB Data Bus
Byte0
Byte3
Byte2
Byte1
Byte0
Byte3
Byte2
Byte1
Figure 5-58 Byte Order in Memory