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.

TLV320DAC3120 - clock on GPIO1

Other Parts Discussed in Thread: TLV320DAC3120EVM-U

Dear all,

we're currently trying to set up a TLV320DAC3120. I found this thread which gives a good idea on how to initialize the IC. Alas, we did not connect the MCLK as we assume(d) that you can use the PLL together with BCLK, WCLK or GPIO1 in order to generate the necessary clocks within the DAC.

Therefore, we adjusted the examples from the thread above to use the GPIO1 as an input to the PLL:

	// PLL ON. GPIO1 20 MHz, PLL_CLK = 9.6 MHz, Fs = 96000 Hz
	// P 5, R 2, J 6, NDAC 2, MDAC 5, DOSR 50.
	dac_writePageAddress(0, 4, 0x0B);  // 0x8 (PLL_CKLIN = GPIO1) + 0x3 (CODEC_CLKIN = PLL_CLK)
	dac_writePageAddress(0, 5, 0xD2);  // 0x80 (PLL on) + 0x50 (PLL divider P = 5) + 0x02 (PLL multiplier R = 2)
	dac_writePageAddress(0, 6, 0x06);  // 0x6 (J-VAL 6)
	dac_writePageAddress(0, 7, 0x00);  // 0 (D-VAL MSB)
	dac_writePageAddress(0, 8, 0x00);  // 0 (D-VAL LSB)

	// NDAC = 2, MDAC = 8, dividers powered on
	dac_writePageAddress(0, 11, 0x82);  // 0x80 (DAC NDAC divider on) + 0x02 (DAC NDAC divider = 2)
	dac_writePageAddress(0, 12, 0x85);  // 0x80 (DAC MDAC divider on) + 0x01 (DAC MDAC divider = 5)

	// DOSR = 128
	dac_writePageAddress(0, 13,  0);  //  0 (DOSR MSB)
	dac_writePageAddress(0, 14, 50);  // 50 (DOSR LSB)

Sadly, when we try to play said beep (with adjusted registers for the frequency of course), the speaker just remains silent.

So, question 1: Is it possible to use GPIO1 instead of MCLK and to keep the latter one floating?
And question 2: Is there any way to test whether the PLL runs at all?

We tried

	dac_writePageAddress(0, 27, 0x08);  // output BCLK
	dac_writePageAddress(0, 30, 0x80 + 100);  // Divide BCLK by 100
	dac_writePageAddress(0, 29, 0x01);  // Output DAC_MOD_CLK on BCLK

which leads to the rather unexpected result that the connected speaker plays some scratchy noise while we can see that the clock on GPIO1 no longer works (as if the IC pulls it down). At least, we get some clock-like signal on BCLK with 35 to 40 kHz (instead of the expected 48 kHz).

Thanks,

Sebastian

  • Hi, Sebastian,

    There are few steps that you need to ensure in order to determine if the PLL is working correctly. First of all, you need to configure the DAC3120 in master mode (BCLK/WCLK as outputs). Then, it is necessary to configure and power on the PLL and dividers. Once this is configured correctly, the BCLK output must be configured as you did on your last code lines. Finally, it is important to power on the DAC to generate the WCLK and BCLK. If the DAC is disabled, there won't be any clock at WCLK and BCLK outputs.

    The processing block PRB_R25 needs some BCLK pulses in order to be initialized.

    Regarding your question about the use of GPIO1 instead MCLK, it is possible. MCLK can be left floated when another clock is taken as the CODEC_CLKIN.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi Luis,

    thanks you for your confirmation on GPIO1. It also turned out meanwhile that the chosen volume level (0.0 dB) of the beep was enough to scare the power supply which explains why we lost the clock on GPIO1 (the controlling MSP430 restarted). So we have something which should sound like a beep on the speaker - although it sounds rather scratchy/noisy and not the way we'd expect it.

    We already have implemented the other parts of the initialization sequence you mentioned (except for WCLK, just added that now) but I didn't post it to prevent a flood of code. You can find it here [0], if it helps. Still, it helped us to check that we did all the necessary steps, so thanks anyway! Still, another question came up here: You said "master mode" - so when I do not switch WCLK and BCLK to outputs, I run in slave mode? And what if I only set one of both?

    Apart from that, the BCLK still shows a frequency of 39.9 KHz instead of the expected 48 KHz (DAC Fs of 96000 x DOSR of 50) and the WCLK line doesn't show anything at all, so I'm not sure what wen't wrong now. Additionally, the beep (96000 samples -> 1 second) is in reality about 3,2 seconds long - another indicator that I probably still haven't set up the PLL correctly, I guess?

    Thanks
    Sebastian

    [0] http://pastebin.com/5p6aUUcz
  • Hi, Sebastian,

    You're right, if WCLK and BCLK are configured as inputs, the device would be in slave mode. If you only set one of both, it is considered as an hybrid mode. Please take a look at the following document for details:

    http://www.ti.com/lit/an/slaa469/slaa469.pdf

    Regarding the BCLK frequency, normally the BCLK frequency should be BCLK = (# channels) * WCLK * (# bits). So, it seems strange to me that it is smaller than the sample rate. I suggest to take a look at the PLL section of datasheet. It explains all the necessary conditions to make the PLL works. Also, I suggest to use a DOSR value of 128.

    Please let me know if you have more questions or comments.

    Best regards,
    Luis Fernando Rodríguez S.

  • Hi Luis,

    is there a specific reason why you suggest a DOSR value of 128? Because when I use Fs = 96 kHz (as I intend to do), taking a DOSR of 128 would result in a DAC_MOD_CLK of more than 12 MHz - while the datasheet says that the maximum is 6.758 MHz (Table 5-22).

    Still, due to checking that, I found that my PLL_CLK was also not within the boundaries (48 MHz vs. 80 MHz minimum according to the datasheet), so thanks :-)
    But now that I doubled my R and my NDAC-values, my BCLK-frequency halved and I'm at 20 kHz ... I don't really understand why, but I guess I just didn't understand the datasheet well enough yet.

    I'll try some different values later to see if I can get the PLL running with those ...

    Thanks
    Sebastian
  • I did some more testing and found that NDAC, MDAC and DOSR correctly work, but that CODEC_CLKIN is at 40 MHz - instead of the expected 98 MHz from the PLL. 

    I currently use the following code to get the PLL up:

    	dac_writePageAddress(0,  4, 0x0B);  // 0x8 (PLL_CKLIN = GPIO1) + 0x3 (CODEC_CLKIN = PLL_CLK)
    
    	dac_writePageAddress  (0,  6, 0x04);  // 0x4 (J-VAL 4)
    	dac_writePageAddress16(0,  7, 0x23C0);  // 0x23 (D-VAL MSB), 0xC0 (D-VAL LSB) = 9152d
    
    	dac_writePageAddress(0,  5, 0x91);  // 0x80 (PLL on) + 0x10 (PLL divider P = 1) + 0x01 (PLL multiplier R = 1)

    (scripted, that would be "w 30 04 0B 91 04 23 C0").

    Is there anything that I missed? I double checked the datasheet but didn't find anything else...

  • There is. Register 0/51 to be more precise which controls the use/direction of GPIO1. Default value: disabled ... With that fixed, only one problem remains: why does the computed beep length and beep frequency not match the length and frequency of beep played by the DAC ...
  • Hi, Sebastian,

    I'm glad to read that the first issue was solved. The GPIO pins require additional configurations to work. Also, when the PLL is used, it is required to follow all the necessary conditions as you may see on the PLL section. I suggested DOSR value since the DAC works better with 128 or 256 value. For these cases, it would be required to modify the rest of the dividers for this change.

    Regarding the beep frequency, you would need to ensure that the Fs is being configured correctly. If WCLK is configured as output, you may take a look at the Fs frequency on that pin (WCLK = Fs).

    Please let me know if you have more questions or comments.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi Luis,

    I read the PLL section of the datasheet several times (and I think I also have covered all boundaries and special cases etc. in my code by now) but didn't find any reference to said register (just that it can be used, but neither that it won't be set automatically nor that I have to set it at all).

    Also, I' sorry but I still don't see how I can raise DOSR that high, given that the DAC_MOD_CLK can't go that high.

    About the beep: I verified my WCLK as well as the BCLK - both frequencies were exactly what I expected them to be (WCLK was 96 kHz, BCLK was 3.072 MHz (96 kHz * 16 Bit per Sample * 2 channels). Still, both, duration and frequency of the beep were off.

    I now try to get the sample playback to work in order to check whether it's just the beep generator or some other setting.

    Thanks
    Sebastian
  • Hi, Sebastian,

    The WCLK and BCLK configuration are in order. So, there shouldn't be problem on the beep generator. So, is it possible to provide a comparison between the expected duration and frequency of the beep with the real duration and frequency? Just few tests with the respective beep register configuration to have a better approach to this issue.

    Thank you.

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi Luis,

    given these values:
    f_DAC 96000
    f_beep 1000
    periods 1000)

    I should write the following values:
    SINE 085Fh
    COSINE 7FBAh
    LENGTH 17700h

    But that gives me a sound of - roughly - 2.5 seconds @ 390 Hz.
    If I set LENGTH to 9000h, the duration is at - roughly - one second. I didn't try playing with the sin/cos-values yet since I do not yet fully understand how the frequency is derived from those.

    Thanks for bearing with me :-)
    Sebastian
  • Hi, Sebastian,

    I would recommend to use the TLV320DAC3120EVM-U CodecControl. This tool is actually used to configure the EVM. However, it can be used in simulation mode.

    You may configure the beep through the Beep block on the main window. It has the option of configure the frequency and duration. Also, if you need to review the registers that are being written, the command window on the view menu can be used to record the registers that are being changed.

    This tool can be downloaded on the EVM product folder: http://www.ti.com/tool/tlv320dac3120evm-u. Search for ACEV-1A EVM Software (Rev. A).

    Please let me know if you have more questions or comments.

    Best regards,
    Luis Fernando Rodríguez S.

  • Hi Luis,

    thank you for pointing at that tool; I previously searched for it but didn't find it yet.

    I downloaded the tool now and tried to set up my configuration. Still, I am rather confused as

    1) it won't let me set some values (e.g. I can't set DOSR to anything but 128; neither can I set Instructions" to anything above 384 - although IDAC can be 1024 according to the datasheet)

    2) the generates scriptes write into registers which are marked as "Reserved. Do not write to these registers." in the datasheet. For example:

    # Select Page 0
    w 30 00 00
    
    # Some other registers, but no other page select - command ...
    
    # NADC = 2, MADC = 8, dividers powered on
    w 30 12 82 88

    Still, the datasheet says: Page 0 / Registers 17–24: Reserved. It also doesn't mention NADC or MADC at all.

    3) some settings are not correctly shown when exporting them as a script - for example, setting GPIO1 as the clock input is correctly displayed in the software itself, but it still sets the register to "use MCLK-pin" when exporting the script.

    I'm not sure whether there's something wrong with the datasheet or the software or if it's just me who still doesn't understand the datasheet yet.

    Thank you for your ongoing support

    Sebastian

  • Hi, Sebastian,

    1) There are several values that cannot be changed with this tool due to the EVM limitations. This software is actually designed to use the EVM without problems. DOSR = 128 and IDAC are limited to avoid any wrong behavior of the device.

    2) These code lines are an error on this software. The NADC and MADC values are actually used in other codecs. We don't recommend to write on reserved registers of the devices even if there are mistakes like this.

    3) In some cases the software indicators are not updated correctly when the script is exported. So, we suggest to take a look at the register inspector (View Menu) in order to ensure that the correct values were written.

    Please let me know if you have more questions or comments.

    Best regards,
    Luis Fernando Rodríguez S.