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.

I don't know where I should edit.. I have to get input 2channel and output 1 channel control..

I downloaded the loopback project from the Lyrtech, but because I'm not good at coding,

I don't know where I should edit..

All I want is, I have to get input 2channel and output 1 channel control..

for example,

in1= 2*ADC_ch1;
in2= 0.5*ADC_ch2;

out1=in1+in2;

 

And the basic loopback program is 4ch in-->4ch out. (to the same number, 1-->1, 2-->2, 3-->3, 4-->4)

Could you let me know?

in the analogloopback main.c, should i edit the section below?

interrupt void dmax_isr( void )
{
 unsigned PP;
    volatile unsigned *GPTransferEntry;
    static int *pDac = (int *)dmaxDacBuffer[0];
    static int *pAdc = (int *)dmaxAdcBuffer[0];
 
 // Verify if a DAC transfer completed
 if( hDmaxDac->regs->DTCR0 & (1<<DAC_TCC) )
 {
  hDmaxDac->regs->DTCR0 = (1<<DAC_TCC);

  // Save the pointer of the audio buffer that has just been transmitted
     GPTransferEntry  = (unsigned *)&hDmaxDac->regs->HiPriorityEventTable;
  GPTransferEntry += ((*(hDmaxDac->hiTableEventEntryPtr)>>8)&0x07F);
     PP = GPTransferEntry[2] >> 31;      
  pDac = (int *)dmaxDacBuffer[!PP];
 }
 // Verify if a ADC transfer completed
 if( hDmaxAdc->regs->DTCR0 & (1<<ADC_TCC) )
 {
  hDmaxAdc->regs->DTCR0 = (1<<ADC_TCC);

  // Save the pointer of the audio buffer that has just been filled
  GPTransferEntry  = (unsigned *)&hDmaxAdc->regs->HiPriorityEventTable;
  GPTransferEntry += ((*(hDmaxAdc->hiTableEventEntryPtr)>>8)&0x07F);
     PP = GPTransferEntry[2] >> 31;      
  pAdc = (int *)dmaxAdcBuffer[!PP];

  // Copy new samples in transmit buffer
  memcpy( pDac, pAdc, FRAME_SIZE*NUM_CHANNEL*2*sizeof(int) );
 }
}

 

  • For a quick and dirty implementation, you can replace the memcpy instruction with you desired Tx DAC data.  Instead of a straight loopback with exact data copy, you would just set the first FRAME_SIZE bytes of pDac to whatever values you like.

    Hayeong Oh said:

      // Copy new samples in transmit buffer

      memcpy( pDac, pAdc, FRAME_SIZE*NUM_CHANNEL*2*sizeof(int) );

    However, you should be aware that this is a dirty implementation because the McASP-dMAX modules are still configured to transmit and receive 4 channels worth of data.  To fix this, you will need to update the McASP and dMAX settings to eliminate the unused channels.

    -Tommy

  • I've tried something, but eventually I failed to eliminate the channels..

    and I should have tested the simple multiplication, but it failed either. ( just in1= 2*ADC_ch1 )

    I inserted the sentence between

      pAdc = (int *)dmaxAdcBuffer[!PP];

      // Copy new samples in transmit buffer
      memcpy( pDac, pAdc, FRAME_SIZE*NUM_CHANNEL*2*sizeof(int) );

    to

      pAdc = (int *)dmaxAdcBuffer[!PP];

    pAdc[0]=2*pAdc[0];

    pAdc[1]=2*pAdc[1];

    pAdc[2]=2*pAdc[2];

    ...

    pAdc[15]=2*pAdc[15];

      // Copy new samples in transmit buffer
      memcpy( pDac, pAdc, FRAME_SIZE*NUM_CHANNEL*2*sizeof(int) );

    but it failed too. I don't know what to do..

    first, simple multiplication,

    second, decreasing channel..

     

     

  • Hayeong Oh said:

    pAdc[0]=2*pAdc[0];

    pAdc[1]=2*pAdc[1];

    pAdc[2]=2*pAdc[2];

    This will not work because pAdc and pDac are pointing to multiple dimension arrays:

    int dmaxDacBuffer[PINGPONG][STEREO][NUM_CHANNEL][FRAME_SIZE];
    int dmaxAdcBuffer[PINGPONG][STEREO][NUM_CHANNEL][FRAME_SIZE];

    pDac = (int *)dmaxDacBuffer[!PP];
    pAdc = (int *)dmaxAdcBuffer[!PP];