I would like to set up the DSP (21363) SPORT0 to receive I2S data using DMA and pack the data in internal memory. The incoming I2S data is valid for bit(31:16), other bits are 0 and shall be ignored. So I want to pack each pair of valid 16 bits into a 32-bit data array in internal memory. Hence, each location in the array will have bit(31:16) containing the first I2S sample and bit(15:0) the second I2S sample. Then, I will access each location using a pointer initialized to a "16-bit memory address" so as to obtain the 16-bit data instead of the full 32 bits.
I have configured the A channel in SPORT0 in the following way:
WRPORT(SPCTL0) = (OPMODE | L_FIRST | SLEN32 | SPEN_A | SDEN_A | SCHEN_A | PACK);
I am using DMA chaining to implement a double-buffered input.
I have already successfully used SPORT0 to receive 24- and 32-bit I2S data in the past with DMA and chaining. But this is the first time with packing. The result that I get is data packed into memory with bit(15:0) of each I2S sample and not bit(31:16). I see this using the the HPUSB-ICE probe and viewing the 32-bit data array. The data sent to the DSP via I2S is also known. Did I setup the SPORT register correctly?
Here is how I setup the pointer that accesses the 32-bit data array.
short *data_shortptr = (short *)((int)(&input_bitstream) * 2);
Thanks in advance!