Post Go back to editing

Dma copy between SPORTs

Category: Hardware
Product Number: ADSP-21593

Hello guys,

I'm now having a setup with ADSP 21593 and A2B device, the SPORT 1A is set as TDM TX and SPORT 1B is set as TDM RX, and they all have a DMA list, when we are trying to apply a loopback feature, we want the data from SPORT1B directly going to the SPORT1A, the way we are using now is use a while(1) loopback and copy the data from buffer RX to buffer TX, but this will block the main function. Is there an non-blocking method to copy the data from one DMA to the other one? the TDM config are all the same one. by the way ,we try to let the adi_sport_DMATransfer of TX using the RX's DMA, but it seems not work.

//SPORT CONFIG

    /* SPORT return code */
    ADI_SPORT_RESULT    eResult;

    /* Open the SPORT Device 1A */
    eResult = adi_sport_Open(SPORT_DEVICE_1A,ADI_HALF_SPORT_A,ADI_SPORT_DIR_TX, ADI_SPORT_MC_MODE, SPORTMemory1A,ADI_SPORT_MEMORY_SIZE,&hSPORTDev1ATx);
    CHECK_RESULT(eResult);
    /* Open the SPORT Device 1B*/
    eResult = adi_sport_Open(SPORT_DEVICE_1B,ADI_HALF_SPORT_B,ADI_SPORT_DIR_RX, ADI_SPORT_MC_MODE, SPORTMemory1B,ADI_SPORT_MEMORY_SIZE,&hSPORTDev1BRx);
    CHECK_RESULT(eResult);

    /* Configure the data,clock,frame sync and MCTL of SPORT Device 1A*/
    eResult = adi_sport_ConfigData(hSPORTDev1ATx,ADI_SPORT_DTYPE_SIGN_FILL,15,false,true,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigClock(hSPORTDev1ATx,0,false,true,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigFrameSync(hSPORTDev1ATx,512,true,false,false,false,false,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigMC(hSPORTDev1ATx,0u,15u,0u,true);
    CHECK_RESULT(eResult);
    eResult = adi_sport_SelectChannel(hSPORTDev1ATx,0u,15u);
    CHECK_RESULT(eResult);

    /* Configure the data,clock,frame sync and MCTL of SPORT Device 1B*/
    eResult = adi_sport_ConfigData(hSPORTDev1BRx,ADI_SPORT_DTYPE_SIGN_FILL,15,false,true,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigClock(hSPORTDev1BRx,0,false,true,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigFrameSync(hSPORTDev1BRx,512,true,false,false,false,false,false);
    CHECK_RESULT(eResult);
    eResult = adi_sport_ConfigMC(hSPORTDev1BRx,0u,15u,0u,true);
    CHECK_RESULT(eResult);
    eResult = adi_sport_SelectChannel(hSPORTDev1BRx,0u,15u);
    CHECK_RESULT(eResult);


    /* Register SPORT Callback function */
    eResult = adi_sport_RegisterCallback(hSPORTDev1ATx,SPORTCallback,NULL);
    CHECK_RESULT(eResult);
    /* Register SPORT Callback function */
    eResult = adi_sport_RegisterCallback(hSPORTDev1BRx,SPORTCallback,NULL);
    CHECK_RESULT(eResult);

    /* Submit the first buffer for Rx.  */
    eResult = adi_sport_DMATransfer(hSPORTDev1BRx,&iRX_LIST_1_SP1B,(DMA_NUM_DESC),ADI_PDMA_DESCRIPTOR_LIST, ADI_SPORT_CHANNEL_PRIM_SEC);
    CHECK_RESULT(eResult);
    eResult = adi_sport_DMATransfer(hSPORTDev1ATx,&iTX_LIST_1_SP1A,(DMA_NUM_DESC),ADI_PDMA_DESCRIPTOR_LIST, ADI_SPORT_CHANNEL_PRIM_SEC);
    CHECK_RESULT(eResult);
//DMA COPY
void SPT1_DMA_copy()
{
    memcpy(int_SP1ABuffer1,int_SP1BBuffer1,sizeof(int_SP1ABuffer1));
    memcpy(int_SP1ABuffer2,int_SP1BBuffer2,sizeof(int_SP1ABuffer2));
}
//CALL DMA COPY
while(1)
{
    SPT1_DMA_copy();
}
  • Hi,


    We would suggest you to refer the "SPORT_TDM_Mode" example from ADSP-21593 BSP.
    This example demonstrates the data transfer between SPORT0A & SPORT0B in TDM(16 channel) mode. SPORT transfers in case of DMA mode are non-blocking and application can register a callback through which completion of DMA transfer can be tracked. So, you can take this as a reference.

    Download the BSP of ADSP-21593 from the attached .zip file

    After installation, you can navigate the example from the below mentioned installation path.
    path: \Analog Devices\EV-SC59x_EZ-KIT-Rel3.0.0\EV-SC59x_EZ-KIT\Examples\drivers\sport\

    5852.ADI_EV-SC59x_EZ-KIT-Rel3.0.0.exe.zip

    Regards,
    Nandini C

  • Hello, 

    Thanks to your suggestion, The one you suggest is not fit our application, in the  "SPORT_TDM_Mode" example in 21593 BSP pack, the SPORT0A is config as TX and SPORT0B is config as RX, but data is from TX to RX, and it can use SRU to transmit the data. however, what we want is data form external going into 21593 through the SPORT0B(RX), and data flow transmit to SPORT0A(TX) and let another external device recive the data. Is there other ways to trans data between two DMA instead of copy in a loop?

    Thanks,

    Siyu

  • Hi Siyu,

    We would like to suggest you refer to the "Audio_Talkthrough_TDM" examples from the ADSP-21593 BSP.

    This example demonstrates using buffers int_SP0ABuffer1, int_SP0ABuffer2, int_SP0ABuffer4 and int_SP0ABuffer5 as user defined buffers. The input data received from the ADC is written into int_SP0ABuffer4 and int_SP0ABuffer5 buffer via SPORT4B.

    The data in int_SP0ABuffer4 is copied to int_SP0ABuffer1 and data in int_SP0ABuffer5 is copied to int_SP0ABuffer2. As ADAU1979 has only 4 ADC, so in example code 4 channel input data is copied to 8 channel DAC output, you can see it in SPORT call back in source code. Then the copied data (int_SP0ABuffer1, int_SP0ABuffer2) is transmitted to DAC via SPORT4A.

    You can navigate the example from the below mentioned installation path.
    path: \Analog Devices\EV-SC59x_EZ-KIT-Rel3.0.0\EV-SC59x_EZ-KIT\Examples\drivers\adc

    Regards,
    Nandini C