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.

Tone example question

Hi,

I have a question regarding the tone application of DSK 6455

Code snippet from tone.c example:

/* Generate a 1KHz sine wave for 5 seconds */
    for (msec = 0; msec < 5000; msec++)
    {
        for (sample = 0; sample < SINE_TABLE_SIZE; sample++)
        {
            /* Send a sample to the left channel */
            while (!DSK6455_AIC23_write32(hCodec, sinetable[sample]));

            /* Send a sample to the right channel */
            while (!DSK6455_AIC23_write32(hCodec, sinetable[sample]));
        }
    }

Compare to this of EVM 6418:

for ( msec = 0 ; msec < 5000 ; msec++ )
{
  for ( sample = 0 ; sample < SINE_TABLE_SIZE ; sample++ )
  {
    /* Send a pair of stereo samples left high & right low */
    while ( ! EVM6418_AIC23_write( hCodec,
           (sinetable[sample]<<16) | sinetable[sample]));
  }
}

While 6455 example writes "sinetable[sample]" twice, 6418 writes "sinetable[sample]<<16) | sinetable[sample]" once.
What I was confused here is 6455 writes a same 16-bits value twice. So how do I know which one is for the left and which one for the right channel???
EVM 6418 example makes more sense to me since it write only one 32-bit value although the high 16-bit and low 16-bit values have the same value.

Thanks in advance,
Pete.

  • Pete,

    The comments are wrong in C6455 tone example, it is just sending the same thing twice to left and right.

  • Hi Mariana,

    From the code above, let's take an example. If  the sinetable[sample] value at a certain time is 0x1234

    EVM 6418 writes only 1 32-bit value: 0x12341234. The high part is for left and low is for right channel.

    In C6455 code example, the first command:

    while (!DSK6455_AIC23_write32(hCodec, sinetable[sample]));

    writes 0x00001234

    once to the left and once to the right? OR only to the left?

    How about the second command?? It is the same as the first one.

    Thanks,

    Pete.

  • Both the AIC23 and the McBSP are very flexible in how they can be used for data transfer.

    In the case of the EVM6418, the data is formatted into a single 32-bit serial transfer that is received by the AIC23 and then split into two 16-bit samples.

    In the case of the EVM6455, the data is formatted as two 16-bit serial transfers that are received by the AIC23 and accepted as two 16-bit samples.

    If you looked at the serial lines, the clock and data would be identical in the two cases. For the EVM6418, the Frame Sync will pulse active once per 32-bit word; for the EVM6455, the Frame Sync will pulse once per 16-bit half-word or twice for every 32 bits transfered.

    Both methods end up with the same result at the analog outputs of the AIC23.

    My opinions on the two different methods of achieving the same goal:

    • The EVM6418 is the more efficient implementation in terms of CPU MIPS usage since it only writes once per sample pair.
    • The EVM6455 is the better teaching example because it clearly shows the communication occurring with separate objects being transfered for the separate channels.

    But both will get the job done. And in your case, you have the added advantage of understanding both and can now make a tradeoff for your application to use one or the other.

  • RandyP said:
    If you looked at the serial lines, the clock and data would be identical in the two cases.

    What documents about serial lines should I look for?

  • The McBSP User's Guide can be found in the product folder for each of the DSPs under Technical Documents or User Guides. This will show you how the Frame Sync and Clock and data lines behave.

    My reference to look at the serial lines meant with a logic analyzer or oscilliscope. But the point is that both will be the same, and that looking at them would just confirm that.

    Both methods of writing to the AIC23 will work fine, which is why both examples work correctly.