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.

setting the MCASP and TLV320AIC3106 to 8 kHz sampling rate

hi,

I am using the Logic PD Experimenter with OMAP-L138 SOM, i built my code on the example of the training workshop Sol3_THREADS. i modified the initialization of the MCASP to make clock source AUXCLK (24 MHz) by setting CLKXM=1 and HCLKXM=1. but it appears that is impossible if we used 16 or 32 slot size because 24000000/(8000*32)= 93.75 or 24000000/(8000*64)= 46.875 . i tried to change the slot size on the reg RFMT and XFMT to 20 because  24000000/(8000*40)=75 but i failed to get any output.

is there any solution to set the McASP to 8 KHz without replacing the external AHCLKX to smaller value such as 3.072?

here is my initialization of the McASP:

// configure receive registers for I2S
   MCASP->RMASK      = 0xFFFFF000;        // 24-bits NOT masked
   MCASP->RFMT       = 0x00018098;        // MSB first, align left, slot=20bits, 1-bit delay, no rotation
   MCASP->AFSRCTL    = 0x00000112;        // int'l gen'd, FS/word, 2 SLOT TDM = I2S
   MCASP->ACLKRCTL   = 0x000000A0;        // rising edge, clkrm internal, /16 CLKRDIV
   MCASP->AHCLKRCTL  = 0x0000804a;        // HCLKRDIV = 1
   MCASP->RTDM       = 0x00000003;        // SLOT 0 & 1 active I2S
   MCASP->RINTCTL    = 0x00000000;        // ints disabled (enabled later though)
   MCASP->RCLKCHK    = 0x00FF0008;        // RMAX = FF, RPS = /256

   // configure transmit registers for I2S - all same as above
   MCASP->XMASK      = 0xFFFFF000;
   MCASP->XFMT       = 0x00018098;        
   MCASP->AFSXCTL    = 0x00000112;
   MCASP->ACLKXCTL   = 0x000000A0;
   MCASP->AHCLKXCTL  = 0x0000804a;
   MCASP->XTDM       = 0x00000003;
   MCASP->XINTCTL    = 0x00000000;
   MCASP->XCLKCHK    = 0x00FF0008;

   // config serializers (11 = xmit, 12 = rcv)
   MCASP->SRCTL11    = 0x000D;                    // XMT
   MCASP->SRCTL12    = 0x000E;                    // RCV

   // config pin function and direction.
   MCASP->PFUNC      = 0;
   MCASP->PDIR       = 0x14000800;

   MCASP->DITCTL     = 0x00000000;
   MCASP->DLBCTL     = 0x00000000;
   MCASP->AMUTE      = 0x00000000;

  • Hi, I don't know this EVM in particular.  But as you've seen, you can use that 24.0 MHz AUXCLK to mathematically get to 48k sample rate, but your problem comes in generating a bit clock, given your choices for slot size.  Unfortunately there isn't much to do about this other than:

    1. Set the AIC device as a master, McASP as slave.

    2. See if you can get the AIC device to feed a master clock (24.576 MHz is a good choice) into AHCLKX, then you can generate bit clocks and frame sync based upon that; this is pretty typical in apps such as A/V receivers.

    3. Replace the 24.0 MHz crystal with a 24.576 MHz crystal.  Obviously there are consequences--this will not allow you to get proper frequencies internally for USB and RMII, and you may have to play with PLL settings to get appropriate DDR and CPU clocks.  Depending on what your application is, that may be an option.  But this is a last resort.

    Bobby T.

  • thanks Tufino,

    i replaced the 24.576 MHz to smaller value 2.048 MHz and the loopback audio project worked well. but when i entered my algorithm at the middle(my algorithm should receive 8 KHz sampling rate and it gives good result when i entered the input speech from .pcm file each sample represented with 16 bit ), the output is not so clear.it just like when someone talking with a mic so close to his mouth. here is my initialization of the codec main registers:

    AIC3106_writeRegister(3, 0x22);

    AIC3106_writeRegister(2, 0xaa);

    AIC3106_writeRegister(7, 0x0a);

    AIC3106_writeRegister(8, 0x00);

    AIC3106_writeRegister(9, 0x00);

    AIC3106_writeRegister(10, 0x00);

    AIC3106_writeRegister(15, 0x00);

    AIC3106_writeRegister(16, 0x00);

    AIC3106_writeRegister(19, 0x04);

    AIC3106_writeRegister(22, 0x04);

    AIC3106_writeRegister(27, 0x00);

    AIC3106_writeRegister(30, 0x00);

    AIC3106_writeRegister(37, 0xE0);

    AIC3106_writeRegister(43, 0x00);

    AIC3106_writeRegister(44, 0x00);

    AIC3106_writeRegister(82, 0x80);

    AIC3106_writeRegister(86, 0x09);

    AIC3106_writeRegister(92, 0x80);

    AIC3106_writeRegister(93, 0x09);

    AIC3106_writeRegister(101, 0x1);

    AIC3106_writeRegister(102, 0x00);

    is there any wrong with this initialization or any extra registers need to be initialized ?

  • Hi, unfortunately I can't help with AIC3106 code.

    Sounds like you are describing distortion on the input signal, but it's very difficult to guess what could be causing it.  If you're getting reasonable output when using a pcm file, then the probably is more than likely on the input side.  It could be gain applied excessively to the input.  Could be a data formatting issue on the input side, as well.

    Have you used an oscilloscope to look at clock signals and determine that they are correct?  Have you looked at data with respect to ACLKX/R and AFSX/R?  You should really do this to determine if data is sitting correctly within the frame, that you're seeing as many bits of data as you expect, etc.

    I don't understand what you mean by this:

    "i replaced the 24.576 MHz to smaller value 2.048 MHz"

    What did you replace?  Where does that clock come from?

    Bobby T.