Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 31

Thread: change I2S BCK ratio ?

  1. #1

    change I2S BCK ratio ?

    Hello,

    I try to use a PCM1802 and I noticed that the output was sliced, the data coming in are sliced too (parts are missing, DOUT is outputing nothing here and there)

    so I checked the BCK signal and I noticed that the teensy (3.6) outputs 32 clocks of each L/R channel (LRCK)

    while the datasheet says it has to be 48 in total, 24 BCK edges per channel

    is there a way to change this in the audio code library ?

    here is my test code

    Code:
    AudioInputI2S            i2s1;           
    AudioOutputAnalog        dac1;     
    AudioConnection          patchCord2(i2s1, 0, dac1, 0);
    
    #define FSYNC 12 // has to be high on normal usage
    
    void setup() {
      AudioMemory(32);
      pinMode(FSYNC,OUTPUT);
      digitalWrite(FSYNC,HIGH);
    }
    
    void loop() {
    }
    thanks in advance


  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    Yup, you may want to read the reference manual, esp, SAI Transmit Configuration 4 Register (I2Sx_TCR4) + TCR5 - and you probable have to change the clock.
    you can find the manuals here: https://www.pjrc.com/teensy/datasheets.html
    Would be great if you show us the code and even better if you publish it at github in a way that we can add it to the audio-library.

  3. #3
    if I manage to make it work :-)

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    I can buy one and help..

  5. #5
    just checked the I2S code in the audio library, I think I am going to give up on teensy, I waste alot of time just making things work
    I'll se wht I can do with a RPI zero instead
    pfffff

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    Yup, seems to be better for you :-)

  7. #7
    Senior Member
    Join Date
    Feb 2017
    Posts
    343
    Read the PCM1802 datasheet again. 24 bits is the resolution of the L & R auto samples. That doesn't mean BCK has to equal 24 * Fs. Sections 7.4.3 and 7.4.4 (master and slave modes respectively) both say the device will work with BCK = 64 * Fs. That's exactly what Teensy audio library uses.

  8. #8
    Senior Member
    Join Date
    Feb 2017
    Posts
    343
    Quote Originally Posted by gfvalvo View Post
    Read the PCM1802 datasheet again. 24 bits is the resolution of the L & R auto samples. That doesn't mean BCK has to equal 24 * Fs. Sections 7.4.3 and 7.4.4 (master and slave modes respectively) both say the device will work with BCK = 64 * Fs. That's exactly what Teensy audio library uses.
    Correction:
    "That doesn't mean BCK has to equal 48 * Fs."

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    I'll try next week or so with a pcm1808.

  10. #10
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    Looks like it is not needed as other already done it
    No change to the code needed.

    https://forum.pjrc.com/threads/57267...l=1#post217492

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,282
    How did things go with the Raspberry Pi?

  12. #12
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    526
    Yes, the PCM1808 works out-of-the-box with the Teensy audio library, no problem and great audio !

    I do not know the differences between PCM1808 and PCM1802, however.

  13. #13
    as for the RPI Zero W solution, audio works nice, even able to use pure data

    and of course it cant be connected to my router via wlan0, maybe I broke the device when I soldered a header on it
    so I can't really embed it in my instrument

    why is it so god damn hard to DSP the s.. of an audio signal in 2020.... :-(

    arf...I'll try to find a PCM1808...

  14. #14
    Senior Member
    Join Date
    Feb 2017
    Posts
    343
    As I stated above, the PCM1802 will likely work with the T3.6 and Audio Library. RTFM.

  15. #15
    I DID RTFM, check the image below, afaik its 24 clock bits per channel -> 48 in total, not 64

    - I ordered a PCM1808

    meanwhile,I fiddled around again with the PCM1802,

    - I checked everything, managed to have a better input signal, allocated more audio memory
    - I figured I forgot the FMT0 solder, fixed it

    yet the sound is sliced here and there

    here is my setup, if anyone sees something wrong (board is 5V power supplied, wiring is quiet simple (on the right)



    here is an image of the two inputs, two outputs


    maybe I should check for ripples on the power supply...

  16. #16
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,504
    So, you read the manual and therefore you saw this

    7.3.5.1.1 Master Mode
    In master mode, BCK and LRCK work as output pins, timing which from the clock circuit of the PCM1808 device controls these pins. The frequency of BCK is constant at 64 BCK/frame.
    7.3.5.1.2 Slave Mode
    In slave mode, BCK and LRCK work as input pins. The PCM1808 device accepts 64-BCK/frame or 48BCK/frame format (only for a 384-fS system clock), not 32-BCK/frame format
    while one can easily write a device driver to have 48 BCK/frame for limited MCLK (needs only to read another manual and learn how to do DMA), it clearly says 64BCK/frame.

  17. #17
    while fig 23 and 25 clearly display 20 and 24 bits per frame
    btw I use a PCM1802

    I hate these discusions, I am more interested in how this can be fixed, I put a lot of work on the appliance I am building and so a lot of faith in that teensy board

    yet I find myself digging the dirt once more, while I should already be writing FFT based audio effects
    I even made a .NET application that is displaying my audio blocks graphicaly (I am a visual kind of guy)

  18. #18
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,155
    Quote Originally Posted by phil123456 View Post

    I hate these discusions.
    Me too.
    Click image for larger version. 

Name:	2020-02-15 13_54_21-Start.png 
Views:	7 
Size:	4.3 KB 
ID:	19072
    Click image for larger version. 

Name:	2020-02-15 17_25_10-Start.png 
Views:	3 
Size:	4.2 KB 
ID:	19073

  19. #19
    sorry about that I keep editing my posts while the delete button gets clicked (FFOX issue maybe) , so I have to rewrite my whole post again
    I preferred the previous forum, this one if really doddgy

  20. #20
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,504
    For the PCM1802, the relevant text is
    7.4.3 Master Mode
    In master mode, BCK, LRCK, and FSYNC work as output pins, and these pins are controlled by timing which is generated in the clock circuit of the PCM1802. FSYNC is used to designate the valid data from the PCM1802. The rising edge of FSYNC indicates the starting point of the converted audio data and the falling edge of this signal indicates the ending point of the data. The frequency of this signal is fixed at 2 LRCK. The duty cycle ratio depends on data bit length. The frequency of BCK is fixed at 64 LRCK. The 768-fS system clock is not available in master mode.
    7.4.4 Slave Mode
    In slave mode, BCK, LRCK, and FSYNC work as input pins. FSYNC enables the BCK signal, and the device can shift out the converted data while FSYNC is HIGH. The PCM1802 accepts the 64-fS BCK or the 48-fS BCK format. The delay of FSYNC from the LRCK transition must be within 16 BCKs for the 64-fS BCK format and within 12 BCKs for the 48-fS BCK format.
    I understand you hate this info, but the figures are only examples, in case you wanted to use 48BCK, but 64 bit is easier both for device driver and DMA.

  21. #21
    ok thanks for lighting the way, dude ;-) people think that reading the manual is an easy task,
    t's not lazyness, I am just not an english person, some datasheet are not always easy to figure

    - I'll make a real PCB, eurocards are "meh" in term of soldering
    - I'll try ordering another chip, maybe something's wrong with this one, I am so close to achieve my goal

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,282
    Those wrong waveforms have recognizable 1-2 ms chunks of the input waveform. So focusing on clock ratios is very likely a huge distraction from the real problem.

    My 2 guesses from looking at those waveforms would be not enough AudioMemory() in the code, or the PCM1802 is sending in a non-I2S format like left justified.

  23. #23
    Quote Originally Posted by Frank B View Post
    Me too.
    Click image for larger version. 

Name:	2020-02-15 13_54_21-Start.png 
Views:	7 
Size:	4.3 KB 
ID:	19072
    Click image for larger version. 

Name:	2020-02-15 17_25_10-Start.png 
Views:	3 
Size:	4.2 KB 
ID:	19073
    thanks for trying to help

  24. #24
    I have added > 800 buffers, adding more did not improve the output
    and I soldered the FMT0 pads


  25. #25
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,282
    Look, this isn't the first time. Over and over this same conversation has come up on this forum, where someone misreads the datasheet and believes their chip expects exactly 24 BCLK clocks per phase of LRCLK. It's a common misunderstanding, because these parts of the diagrams (highlighted yellow and green) aren't always clearly explained.

    Click image for larger version. 

Name:	is2.png 
Views:	4 
Size:	29.4 KB 
ID:	19074

    Rarely are they as adamant and hostile as you've been. It almost feels like you don't want help finding the real problem.

    But if you do, I want to communicate as clearly as possible that the real problem is almost certainly not the clock ratio. The sooner you can stop arguing this point and start listening to experts with a *lot* of experience on this platform, the sooner we can help you get this working. But you've just got to somehow let this wrong assumption about the problem go and let us help you to find the real cause of trouble.

Posting Permissions

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