Hi guys,
I am trying to modify the audio library to support 4 channels with 24bit-depth. I basically have 32bits samples that I cut to 24 later.
I am very close to get everything working, however the input signal is not correct. There seems to be an overlap in the buffers somewhere, see screenshot of a pure-tone sine wave. The number of samples selected corresponds to the FRAME_BY_BLOCK size.
The I2S buffer seems to operate at the same speed as the USB buffer, but could be slightly out of phase (1kHz I2S and 1kHz USB, see screenshot).
I think the problem could be caused by a setting in the DMA, however I don't fully understand what I have to use for the modulo (SMOD and DMOD). I tried a few settings but they end up crashing the Teensy. If you think it would be caused by something else let me know.
Here's the code I have for the DMA setting at the moment:
Screenshot of USB vs I2S
Screenshot of a 1kHz pure-tone sent to 1 input and recorded in audacity
Thanks!
Vincent
I am trying to modify the audio library to support 4 channels with 24bit-depth. I basically have 32bits samples that I cut to 24 later.
I am very close to get everything working, however the input signal is not correct. There seems to be an overlap in the buffers somewhere, see screenshot of a pure-tone sine wave. The number of samples selected corresponds to the FRAME_BY_BLOCK size.
The I2S buffer seems to operate at the same speed as the USB buffer, but could be slightly out of phase (1kHz I2S and 1kHz USB, see screenshot).
I think the problem could be caused by a setting in the DMA, however I don't fully understand what I have to use for the modulo (SMOD and DMOD). I tried a few settings but they end up crashing the Teensy. If you think it would be caused by something else let me know.
Here's the code I have for the DMA setting at the moment:
Code:
dma.TCD->SADDR = &I2S0_RDR0;
dma.TCD->SOFF = 4;
dma.TCD->ATTR =
DMA_TCD_ATTR_SMOD(3) | // 15-11 : Source adress modulo. != 0 activate the feature
DMA_TCD_ATTR_SSIZE(2) | // 10-8 : Source tranfer size. (0:8bit,1:16bit,2:32bit), Originally 1
DMA_TCD_ATTR_DMOD(0) | // 7-3 : Destination adress modulo
DMA_TCD_ATTR_DSIZE(2); // 2-0 : Destination tranfer size. (0:8bit,1:16bit,2:32bit)
// Number of bytes to transfer (in each service request)
dma.TCD->NBYTES_MLNO = 4;
dma.TCD->SLAST = 0;
dma.TCD->DLASTSGA = -sizeof(i2s_rx_buffer);
dma.TCD->DADDR = i2s_rx_buffer;
dma.TCD->DOFF = 4;
// Set loop counts
dma.TCD->CITER_ELINKNO = sizeof(i2s_rx_buffer) / 4;
dma.TCD->BITER_ELINKNO = sizeof(i2s_rx_buffer) / 4;
dma.TCD->CSR = DMA_TCD_CSR_INTHALF | DMA_TCD_CSR_INTMAJOR;
Screenshot of USB vs I2S
Screenshot of a 1kHz pure-tone sent to 1 input and recorded in audacity
Thanks!
Vincent