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.

Clocking issue with AIC3107 and dsPIC

We are using a dsPIC33 (as Master) to drive a TI AIC 3107 Codec, and are not
able to get them to properly get in sync with each other. 
About 1/3 of the samples (sometimes more) end up being garbage,
and generate copious amounts of loud static. 
Analysis of the dsPIC's RAM shows the received "corrupted " CODEC sample values ranging
around 0xFFA4, 0xFE38, 0xFD40 for about 1/3 the samples in an 80 word set of samples.

Enclosed are the initialization sequences we are sending to the
AIC 3107. Could you please look at them and give
us some wise words of advice as to what PLL ratios, etc need
to be re-tweaked in the init sequence, to get the two chips
to play nice with each other.

The dsPIC is acting as Master. It is supplying a 512 KHz clock to BCLK
and using a frame clock (WCLK) of 16 KHz. We are using
it to clock two 16-bit words (left channel, then right channel)
from the AIC3107 to the dsPIC. We have tried using it in both
DSP mode and I2S mode, and both fail in similar ways, as described above.

We are sending the following initialization sequence to the
AIC3107 via the I2C port:

Provide hardware reset, then:
  w 30 00 00     Reset to page 0
  w 30 01 80     Software reset
  w 30 07 00     Set default Fsref = 48 kHz, channels off
  w 30 02 44     Set Fsref dividers for ADC/DAC to 16 KHz
                 (we've also tried other ratios of 0x11, 0x33, 0xAA
                  with no successful results)
  w 30 03 11     Set Q=2,P=1 with PLL disabled
  w 30 04 80     Set J=32
  w 30 05 00     Set D=0000 (high bits)
  w 30 06 00     Set D=0000 (low bits)
  w 30 08 00     Set BCLK/WCLK as inputs (AIC 3107 acts as slave)
  w 30 09 40     Set into DSP mode, word length = 16 bits
                 (we've also tried I2S mode, without success)
  w 30 0B 01     Set R=1
  w 30 66 A5     Set N=5, and use BCLK as PLL clock source
  w 30 65 00     Set CODEC_CLKIN to PLL
  w 30 03 91     Enable PLL, using Q=2,P=1
    .  .  .      Setup ADC and DAC parameters   . . .
  w 30 07 0A     Use Fsref = 48Hz and setup channel to DAC paths
    .  .  .      Powerup/un-mute ADCs and DACs   . . .
Please advise.  Thanks much.
---------------------------------------------------------------
  • For best results, try to set Fs(ref) to 48 kHz. With a MCLK of 512 kHz (coming from BCLK) you can use P=1, J.D=32, and R=6. Register 2 would be set to 0x44. This should give you a final sample rate of 16 kHz. 

    If BCLK is started and stopped, there could be an issue while waiting for the PLL to lock., you could try having the AIC3104 be the master, this way you would be sure that WCLK is properly derived from BLCK.

     

    Let me know if that doesn't fix it.

  • Changed the R value to 6.

    All the other parameters you suggested (P=1, J.D=32, Fsref=48kHz) were already set in the script that was previously posted.

    512 kHz BCLK from the dsPIC's DCI module is already up and running, before the initialization sequence is issued to the AIC3107.

    Still no joy. Just a nice noisy buzz.

    Is there a potential sequencing issue in the script, such that I need to change any sequencing in how the initialization is performed ?

     

  • The sequence looks ok. It might be better if there was no BCLK until after init. Can your system work with the AIC3107 as the master. This is often much easier to insure that everything is clocked correctly.