This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x McASP PCM

Other Parts Discussed in Thread: PCM1690, AM5728, DIR9001

Hi,
I am working with am335x and would like to use McASP (Creating human signal generator :)). I think I almost did it but it's not working properly yet.

With a help form Ti-wiki. I do:
- create driver for PCM1690
- build driver to kernel
- configure ALSA machine layer
- add everything to Device Tree
- then enable it in kernel

As a platform I use sitarta-TI Linux Image and SDK from TI (great tools thx :P).

What is coming out from my processor (measure by oscilloscope):
-AHCLKX (~24MHz ~ 512xfs)
-FSX (50kHz)
-ACLKX(1.6MHz ~ 32xfs)
-AXR0 (Some data)

And my PCM1690 have register 69 (0x45) which is changing if PCM see any inputs. It's works but I still see no output from my DAC.

From beginning I have 3 questions:
1. When I play 48kHz wav files (example /usr/share/sound/alsa/Front_left.wav   or   speaker-test -c 2. My 'fs' is 48kHz right? So why my FSX is 50kHz? Shouldn't be 48kHz?

2. How to set properly AHCLKX? In wiki there was no need to even turn it on. My DAC needs it and I lunch it by adding this 2 lines in davinci-mcasp.c file to section:
        "case SND_SOC_DAIFMT_CBS_CFS:
        /* codec is clock and frame slave */"
        //my code
        mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX);
        mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);

But It's let me only to output 24MHz, but I want to change it depends on my fs rate (I should have exactly 512xfs, now its only close to this) I guess It should be in davinci-evm.c where I set ACLKX. Here is my code where I do this:
   
    unsigned int bclk_freq = evm_get_bclk(params);
    unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
               snd_soc_card_get_drvdata(soc_card))->sysclk;
    int ret;
    ret = snd_soc_dai_set_clkdiv(cpu_dai, 1, sysclk/bclk_freq);

So I set divider from my sysclk (default 24MHz in sitara-TI procesors). So how to change also AHCLKX (Is there a mirror divider as I do with ACLKX?)

3.Why my PCM not working? xD Or more precise where you advise me to look for mistakes or answers? Maybe I should try with polarity of my signals? Or with PCM169 configuration?

If you need any more outputs, informations or even screen from oscilloscope, do not hesitate to ask me. I will replay as fast as I can and with all my knowledge I have/will get.

  • Hi Pawel,

    Please read section 22.2.5 from the AM335X TRM Rev. K, where Clock and Frame Sync Generators are explained.

  • For #2, you can divide down AHCLK using the davinci_mcasp_set_clkdiv with div_id 0.  Look at this section of the audio dac guide for details.

  • there is no 22.2.5 section in my file.
    how can I find whether the doc is rev. K or not?
  • It's 22.3.5 in the latest TRM.
  • Hi Pawel!
    Have you got it all working finally?

    I'm trying to attach PCM1690 DAC to AM5728 (using compulab dev kit www.compulab.co.il/.../
    This dev kit is using Linux kernel 4.4

    If possible - could you please help with the driver source code
    Or, if it is not possible, may be you can write a few words about the problems you had during implementation and solutions you found for these problems.
    Thanks!
  • Hi Sergey,

    Yes I have manage to make it working but with 2 channels only. I have no time yet to make all 8 available, but will take care in free time (form tomorrow to never :D).

    PCM1690 is "quite easy" to work with since to achieve working configuration I2S You can use default registers configuration.

    I was using external MCLK source (24.576MHz clock), configure MCLK as an input (both PCM and processor), and internally divide MCLK to achieve others clocks (Processor set as master). Hardware is done.

    As it comes to software things, are as usually a bit tricky. I manage to get it working on kernel 3.12 (have compiled kernel only), but with recent version kernel I develop with my product (3.8) I have also sources. Since I was evaluating form one of evalboards, I take basic kernel, create my own device tree (enable it in slots) and change existing I2S driver to do my job. I am not familiar with kernel 4.x (since was working on 3.2-3.12 only) so don't know if they mess sth with ALSA compare to old way. If You wish I can search for original driver and my files, to give You a brief background how to achieve Your goals in easiest way, but what I learnd from past - new kernel, new headache :D

    The biggest problem I had was to generate MCLK clock. I was able to do it easly in kernel 3.9 but since it is different compare to 3.8 I couldn't get it working. so they fastest way for me was enable external clock. For Your design I recommend to connect external clock with external DNM resistor, so You can check both solutions.

  • Thanks!

    I figured out that for 24 bit TDM mode with only one data line used - I can pass same 256 x Fs to both MCLK at BCLK (bit-clock)
    So I'll try to connect them together and use single McASP TX clock for it

    It would be great to see your PCM1690 ALSA driver code to see how you have done all the configuration and connection to McASP and ALSA
  • Hi Sergey!

    Long time since I was writing to You but I don't have time to release my project before. Now it is done :)

    Have manage to add support to more serializers and now have all 8 channels working!!! (Thanks to commits and documentation on ALSA procjet git)

    The source code is available from my git:

    git@gitlab.com:Krzyzanowski_Pawel/biosignal_gen.git

    Feel free to ask questions. I may take time but I am responding to them :)

  • Hi Paweł,

    I have just started a similar project. I'm working on a board with a PCM1690 and want to connect it to my Beagle Bone black/green (AM335x) SoC.

    Your git repo doesn't seem to exist (anymore). Is your code still around?

    (the additional part of my project it a TOSLINK input using DIR9001 chip, so that I can receive DTS/AC3/AAC, decode with ffmpeg, and output the DAC in analog surround).