Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Quad channel input problem

  1. #1

    Quad channel input problem

    Hi,

    I'm using PCM1808 ADC board (as mentioned in this topic: https://forum.pjrc.com/threads/53069...Module-via-I2S) with Teensy 3.6.

    I'm trying to use two of them at a time.

    At first, I connect just one and open PeakMeterStereo from Examples->Audio->Analysis.

    Running PeakMeterStereo as it is gives me success, everything is measured nicely when I open serial monitor and the LED on Teensy shines brightly (I guess, because PIN 13 which is used for I2S input is connected to LED). However, if I just rename AudioInputI2S to AudioInputI2SQuad in the code (without any modifications in the connections), the example stops working. The meter is still being displayed in the serial monitor, but the level is always zero and the LED does not shine. If I rename it back to AudioInputI2S, it starts working again. Connecting second board to PIN 38 doesn't change the result works ok with AudioInputI2S but gives zeros (and no LED) with AudioInputI2SQuad.

    It feels like either I am missing something or perhaps the PINs in quad channel class are misconfigured or maybe something else.

    Could you please help me to figure out?

    Thanks!

  2. #2
    @PaulStoffregen was Teensy 3.6 ever tested with simultaneous quad channel input and output?

    It seems like there is a configuration problem. With the current configuration only quad channel output works. I was looking at how AudioInputI2S/AudioOutputI2S are being initialized. And if I change 15 to 31 in output_i2s_quad.cpp (like I2S_TCR4_SYWD(15) and all other parts which have 15), quad input starts to work (the LED starts to shine and the peak meters measure levels properly for all four input channels). But with 31 the output stops working. With 15, the output works, but the input doesn't.

    I also needed to replace a line in input_i2s_quad.cpp:
    Code:
    dma.TCD->SADDR = &I2S0_RDR0
    to
    Code:
    dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0 + 2)
    like it is in input_i2s.cpp to get the proper levels on the quad inputs.

    Given that I have no idea what those numbers are, I'm wondering if you could help. Seems like it's only a few flags away from working. The hardware is definitely ok (given that all for output channels work with 15 and all four inputs work with 31). The stereo pass through example works perfectly too...

  3. #3
    OMG, several nights of desperation and I think I have managed to make it working.

    I'm definitely doing it not 100% correctly, but here is my diff to the Audio library which makes my setup sound:

    Code:
    diff --git a/input_i2s_quad.cpp b/input_i2s_quad.cpp
    index 2c71fae..cde3a01 100644
    --- a/input_i2s_quad.cpp
    +++ b/input_i2s_quad.cpp
    @@ -54,7 +54,7 @@ void AudioInputI2SQuad::begin(void)
     #endif
     
     #if defined(KINETISK)
    -	dma.TCD->SADDR = &I2S0_RDR0;
    +	dma.TCD->SADDR = (void *)((uint32_t)&I2S0_RDR0 + 2);
     	dma.TCD->SOFF = 4;
     	dma.TCD->ATTR = DMA_TCD_ATTR_SSIZE(1) | DMA_TCD_ATTR_SMOD(3) | DMA_TCD_ATTR_DSIZE(1);
     	dma.TCD->NBYTES_MLNO = 4;
    diff --git a/output_i2s_quad.cpp b/output_i2s_quad.cpp
    index b263b96..5d04d29 100644
    --- a/output_i2s_quad.cpp
    +++ b/output_i2s_quad.cpp
    @@ -69,7 +69,7 @@ void AudioOutputI2SQuad::begin(void)
     	dma.TCD->ATTR = DMA_TCD_ATTR_SSIZE(1) | DMA_TCD_ATTR_DSIZE(1) | DMA_TCD_ATTR_DMOD(3);
     	dma.TCD->NBYTES_MLNO = 4;
     	dma.TCD->SLAST = -sizeof(i2s_tx_buffer);
    -	dma.TCD->DADDR = &I2S0_TDR0;
    +	dma.TCD->DADDR = (void *)((uint32_t)&I2S0_TDR0 + 2);
     	dma.TCD->DOFF = 4;
     	dma.TCD->CITER_ELINKNO = sizeof(i2s_tx_buffer) / 4;
     	dma.TCD->DLASTSGA = 0;
    @@ -314,9 +314,9 @@ void AudioOutputI2SQuad::config_i2s(void)
     	I2S0_TCR2 = I2S_TCR2_SYNC(0) | I2S_TCR2_BCP | I2S_TCR2_MSEL(1)
     		| I2S_TCR2_BCD | I2S_TCR2_DIV(3);
     	I2S0_TCR3 = I2S_TCR3_TCE_2CH;
    -	I2S0_TCR4 = I2S_TCR4_FRSZ(1) | I2S_TCR4_SYWD(15) | I2S_TCR4_MF
    +	I2S0_TCR4 = I2S_TCR4_FRSZ(1) | I2S_TCR4_SYWD(31) | I2S_TCR4_MF
     		| I2S_TCR4_FSE | I2S_TCR4_FSP | I2S_TCR4_FSD;
    -	I2S0_TCR5 = I2S_TCR5_WNW(15) | I2S_TCR5_W0W(15) | I2S_TCR5_FBT(15);
    +	I2S0_TCR5 = I2S_TCR5_WNW(31) | I2S_TCR5_W0W(31) | I2S_TCR5_FBT(31);
     
     	// configure receiver (sync'd to transmitter clocks)
     	I2S0_RMR = 0;
    @@ -324,9 +324,9 @@ void AudioOutputI2SQuad::config_i2s(void)
     	I2S0_RCR2 = I2S_RCR2_SYNC(1) | I2S_TCR2_BCP | I2S_RCR2_MSEL(1)
     		| I2S_RCR2_BCD | I2S_RCR2_DIV(3);
     	I2S0_RCR3 = I2S_RCR3_RCE_2CH;
    -	I2S0_RCR4 = I2S_RCR4_FRSZ(1) | I2S_RCR4_SYWD(15) | I2S_RCR4_MF
    +	I2S0_RCR4 = I2S_RCR4_FRSZ(1) | I2S_RCR4_SYWD(31) | I2S_RCR4_MF
     		| I2S_RCR4_FSE | I2S_RCR4_FSP | I2S_RCR4_FSD;
    -	I2S0_RCR5 = I2S_RCR5_WNW(15) | I2S_RCR5_W0W(15) | I2S_RCR5_FBT(15);
    +	I2S0_RCR5 = I2S_RCR5_WNW(31) | I2S_RCR5_W0W(31) | I2S_RCR5_FBT(31);
     
     	// configure pin mux for 3 clock signals
     	CORE_PIN23_CONFIG = PORT_PCR_MUX(6); // pin 23, PTC2, I2S0_TX_FS (LRCLK)
    I haven't tested the sound quality yet (I'm feeding all four ADC channels with one little mic). But at least I have something on all input and output channels.

    @Paul I was going through the forum again and it looks like my problem is related to https://forum.pjrc.com/threads/53076...Quad-BCK-Query and likely to the outcome of https://forum.pjrc.com/threads/53820...ic-on-i2cInput (which is a low priority for you).

    I'm attaching a photo of my proof-of-concept messy thing with two PCM1808 ADCs and two PCM5102A DACs.

    Could you please have a quick look at my diff? I suspect I might be doing something wrong (like it might shrink one byte from the 24 bit ADC's input). And I'll test it with some better quality input in the upcoming days.

    Click image for larger version. 

Name:	IMG_4299.jpg 
Views:	16 
Size:	166.0 KB 
ID:	16558

  4. #4
    Soldered a jack and tested the pass through with an audio player. It works but the level directly from the Audio Player -> Phones is significantly higher than the level from the Audio Player -> ADC -> Pass through -> DAC -> Phones.

    So the change above is likely cutting some 8 bits of the data...

  5. #5
    Quote Originally Posted by hoho View Post
    Soldered a jack and tested the pass through with an audio player. It works but the level directly from the Audio Player -> Phones is significantly higher than the level from the Audio Player -> ADC -> Pass through -> DAC -> Phones.

    So the change above is likely cutting some 8 bits of the data...
    Are you sure it's not a preamp you are missing?

    (I'm feeding all four ADC channels with one little mic)
    Do you want to try it with a line level source? Send an "ipod" through it and see how it sounds?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •