19.4.2.3 Audio Data Length and Frame Length

While codec devices may generate audio data samples of various word lengths of 8, 16, 20, 24 and 32, the dsPIC33A SPI module supports transmit/receive audio data lengths of 16, 24 and 32.
Note: Actual sample data can be any length, with a maximum of 32 bits, and the data must be packed in one of three (16/24/32) formats.

Table 19-14 illustrates how the MODE[32,16] bits (SPIxCON1[11:10]) control the maximum allowable sample length and frame length (LRCK period on SSx).

Table 19-14. Audio Data Length vs. LRCK Period
SPIxCON1[11:10]

Data Length (bits)

FIFO Width (bits)

Left/Right Channel Sample Length (bits)

Enhanced Buffer FIFO Depth (samples)(1)

LRCK Period Frame Length (bits)

MODE32MODE16
001616≤ 16X/232
011616≤ 32X/264
112432≤ 32X/464
103232≤ 32X/464
Note: FIFO depth varies between devices. The data shown is specified considering device with available FIFO depth of 'X'.

The parameters of the MODE[32,16] bits (SPIxCON1[11:10]) have the following behavior:

  • Controls left/right channel data length, frame length
  • In 16-bit Sample mode, 32/64-bit frame length is supported
  • In 24/32-bit Sample mode, 64-bit frame length is supported
  • Defines FIFO width and depth (for example, 24-bit data has a 32-bit wide and X/4-location deep FIFO)
  • If the written data is greater than the data selected, the upper bytes are ignored
  • If the written data is less than the data selected, the FIFO Pointers change on the write to the MSB of the selected length

If this data is written to the transmit FIFO in more than one write, the write order must be from Least Significant to Most Significant.

For example, assume that audio data is 24 bits per sample with 8 bits available at a time. According to Table 19-14, the FIFO width is 32 bits per sample. Therefore, the 8 MSbs, bits[31:24], in each FIFO sample are ignored.

Data written to unused bytes is ignored. Also, transactions that are only to unused bytes are also ignored. Therefore, a byte write to address offset, 0x0023, is completely ignored and does not cause a FIFO push if the data is less than 32 bits wide.