Post Go back to editing

ADSP21565 use Sport0A can work, but Sport4A can't work.

Category: Software
Product Number: ADSP21565
Software Version: cces2.11.1

ADSP21565 use Sport0A can work, but Sport4A can't work.

I can capture data on the data line through a logic analyzer, but there is no data for this variable in the program.

The data of Sport0A is normal, but when switching to Sport4A, there is data on the data line, but the variable remains at 0

static void SPORTCallback(
		void        *pAppHandle,
		uint32_t     nEvent,
		void        *pArg
)
{
	ADI_SPORT_RESULT eResult;
	/* CASEOF (event type) */
	switch (nEvent)
	{
	/* CASE (buffer processed) */
	case ADI_SPORT_EVENT_BUFFER_PROCESSED:
		if(A2B_pingpong_flag==0){
			A2B_pingpong_flag=1;
			for(int kkk=0;kkk<30;kkk++){
				for(int kk=0;kk<ref_num;kk++){
					*(*(ref_blook+kk)+kkk)=*(A2B_in_Buffer1+kkk*16+ref_seq[kk]);
				}
				for(int kk=0;kk<mic_num;kk++){
					*(*(MIC_blook+kk)+kkk)=*(A2B_in_Buffer1+kkk*16+kk+9);
				}
			}
		}
		else if(A2B_pingpong_flag==1){
			A2B_pingpong_flag=0;
			for(int kkk=0;kkk<30;kkk++){
				for(int kk=0;kk<ref_num;kk++){
					*(*(ref_blook+kk)+kkk)=*(A2B_in_Buffer2+kkk*16+ref_seq[kk]);
				}
				for(int kk=0;kk<mic_num;kk++){
					*(*(MIC_blook+kk)+kkk)=*(A2B_in_Buffer2+kkk*16+kk+9);
				}
			}
		}

		A2BCallbackCount++;
		A2B_flag=1;
		break;
	default:
		break;
	}
}

static void PrepareDescriptors (void)
{

	iDESC_LIST_1_SP0A.pStartAddr	= (int32_t *)A2B_in_Buffer1;
	iDESC_LIST_1_SP0A.Config		= ENUM_DMA_CFG_XCNT_INT ;
	iDESC_LIST_1_SP0A.XCount		= COUNT;
	iDESC_LIST_1_SP0A.XModify		= 4;
	iDESC_LIST_1_SP0A.YCount		= 0;
	iDESC_LIST_1_SP0A.YModify		= 0;
	iDESC_LIST_1_SP0A.pNxtDscp		= &iDESC_LIST_2_SP0A;

	iDESC_LIST_2_SP0A.pStartAddr	= (int32_t *)A2B_in_Buffer2;
	iDESC_LIST_2_SP0A.Config		= ENUM_DMA_CFG_XCNT_INT ;
	iDESC_LIST_2_SP0A.XCount		= COUNT;
	iDESC_LIST_2_SP0A.XModify		= 4;
	iDESC_LIST_2_SP0A.YCount		= 0;
	iDESC_LIST_2_SP0A.YModify		= 0;
	iDESC_LIST_2_SP0A.pNxtDscp		= &iDESC_LIST_1_SP0A;

	iDESC_LIST_1_SP0B.pStartAddr	= (int32_t *)A2B_out_Buffer1;
	iDESC_LIST_1_SP0B.Config		= ENUM_DMA_CFG_XCNT_INT ;
	iDESC_LIST_1_SP0B.XCount		= COUNT;
	iDESC_LIST_1_SP0B.XModify		= 4;
	iDESC_LIST_1_SP0B.YCount		= 0;
	iDESC_LIST_1_SP0B.YModify		= 0;
	iDESC_LIST_1_SP0B.pNxtDscp		= &iDESC_LIST_2_SP0B;

	iDESC_LIST_2_SP0B.pStartAddr	= (int32_t *)A2B_out_Buffer2;
	iDESC_LIST_2_SP0B.Config		= ENUM_DMA_CFG_XCNT_INT ;
	iDESC_LIST_2_SP0B.XCount		= COUNT;
	iDESC_LIST_2_SP0B.XModify		= 4;
	iDESC_LIST_2_SP0B.YCount		= 0;
	iDESC_LIST_2_SP0B.YModify		= 0;
	iDESC_LIST_2_SP0B.pNxtDscp		= &iDESC_LIST_1_SP0B;

}
void Sport_Init()
{
	int delay11=0xffff;

	/* Open the SPORT Device 4A */
	adi_sport_Open(SPORT_DEVICE_4A,ADI_HALF_SPORT_A,ADI_SPORT_DIR_RX, ADI_SPORT_MC_MODE, SPORTMemory0A,ADI_SPORT_MEMORY_SIZE,&hSPORTDev4ARx);


	adi_sport_Open(SPORT_DEVICE_4A,ADI_HALF_SPORT_B,ADI_SPORT_DIR_TX, ADI_SPORT_MC_MODE, SPORTMemory0B,ADI_SPORT_MEMORY_SIZE,&hSPORTDev4BTx);


	/* Configure the data,clock,frame sync and MCTL of SPORT Device 4A*/
	adi_sport_ConfigData(hSPORTDev4ARx,ADI_SPORT_DTYPE_SIGN_FILL,31,false,false,false);

	adi_sport_ConfigClock(hSPORTDev4ARx,4,true,false,false);

	adi_sport_ConfigFrameSync(hSPORTDev4ARx,511,true,true,false,true,false,false);

	adi_sport_ConfigMC(hSPORTDev4ARx,1u,15u,0u,true);

	adi_sport_SelectChannel(hSPORTDev4ARx,0u,15u);



	adi_sport_ConfigData(hSPORTDev4BTx,ADI_SPORT_DTYPE_SIGN_FILL,31,false,false,false);

	adi_sport_ConfigClock(hSPORTDev4BTx,0,false,false,false);

	adi_sport_ConfigFrameSync(hSPORTDev4BTx,511,true,false,false,true,false,false);

	adi_sport_ConfigMC(hSPORTDev4BTx,1u,15u,0u,true);

	adi_sport_SelectChannel(hSPORTDev4BTx,0u,15u);


	/**************************************************Sport Global Group Array Handle***********************************************************/
	/*Tx group*/
	SportRxDai1Array[0]= hSPORTDev4ARx;
	SportTxDai1Array[0]= hSPORTDev4BTx;

	/* Prepare descriptors */
	PrepareDescriptors();

	/* Submit the first buffer for Rx.  */
	adi_sport_DMATransfer(hSPORTDev4ARx,&iDESC_LIST_1_SP0A,(DMA_NUM_DESC_SPORT),ADI_PDMA_DESCRIPTOR_LIST, ADI_SPORT_CHANNEL_PRIM);


	/* Submit the first buffer for Rx.  */
	adi_sport_DMATransfer(hSPORTDev4BTx,&iDESC_LIST_1_SP0B,(DMA_NUM_DESC_SPORT),ADI_PDMA_DESCRIPTOR_LIST, ADI_SPORT_CHANNEL_PRIM);


	adi_sport_CreateGlobalGroup(SportRxDai1Array,1u,&hDai1Group1Rx,false,true);


	adi_sport_CreateGlobalGroup(SportTxDai1Array,1u,&hDai1Group0Tx,false,true);


	/* Register Global callback for RX group*/
	adi_sport_GlobalRegisterCallback(hDai1Group1Rx,SPORTCallback,0);




	/* Global sport enable */
	adi_sport_GlobalEnable(true);


	/* wait for Codec to up */
	delay11=0xffff;
	while(delay11--)
	{
		asm("nop;");
	}

}

void SRU_Init()
{
	*pREG_PADS0_DAI0_IE = BITM_PADS_DAI0_IE_VALUE;
	*pREG_PADS0_DAI1_IE = BITM_PADS_DAI1_IE_VALUE;

	SRU2(SPT4_ACLK_O,DAI1_PB01_I); /*SPORT 4A to DAC clock*/
	SRU2(HIGH,DAI1_PBEN01_I);
	SRU2(DAI1_PB01_O,SPT4_BCLK_I); /*SPORT 4A to DAC clock*/

	SRU2(SPT4_AFS_O,DAI1_PB02_I);  /*DAC FS to SPORT 4A*/
	SRU2(HIGH,DAI1_PBEN02_I);
	SRU2(DAI1_PB02_O,SPT4_BFS_I); /*SPORT 4A to DAC clock*/


	SRU2(DAI1_PB04_O,SPT4_AD1_I); /*ADC to SPORT 4B*/
	SRU2(LOW,DAI1_PBEN04_I);

	SRU2(DAI1_PB03_O,SPT4_AD0_I); /*ADC to SPORT 4B*/
	SRU2(LOW,DAI1_PBEN03_I);

	SRU2(SPT4_BD0_O,DAI1_PB05_I); /*ADC to SPORT 4B*/
	SRU2(HIGH,DAI1_PBEN05_I);
	SRU2(SPT4_BD1_O,DAI1_PB05_I); /*ADC to SPORT 4B*/
	SRU2(HIGH,DAI1_PBEN06_I);
}
}

Edit Notes

edit c code
[编辑人: zyc115005 编辑时间: 24 Jul 2025 8:01 AM (GMT -4)]
Parents
  • Hi,

    We understand that the shared code works correctly when configured with SPORT 0A, but issues arise when it is changed to 4A. Please confirm.

    In the code, we noticed that in the adi_sport_Open() API, both Tx and Rx are currently configured as SPORT_DEVICE_4A. Could you please update the transmitter side to use SPORT_DEVICE_4B instead, and verify if that resolves the issue?

    Also, please make sure that the SPU registers are properly enabled.

    Have you had a chance to look at the example provided in the BSP? If not, we recommend checking out the example titled "SPT_GBL_Audio_Passthrough_TDM". It demonstrates how to use the ADAU1979 ADC and the ADAU1962a DAC in TDM mode for audio talkthrough, using the SPORT’s global enable feature.


    The BSP can be downloaded from the below link.
    download.analog.com/.../ADI_EV-2156x_EZ-KIT-Rel3.0.0.exe

    After installation, please navigate as below.
    <Installation path>:\Analog Devices\EV-2156x_EZ-KIT-Rel3.0.0\EV-2156x_EZ-KIT\Examples\drivers\adc\SPT_GBL_Audio_Passthrough_TDM

    Regards,
    Nandini C

  • Hi,

    1. This is my naming convention, but in reality, they are all Sport4 (4u).
    2. I have already enabled SPU, below is my code.

    #define SPORT_0A_SPU  					49
    #define SPORT_0B_SPU  					50
    
    #define SPORT_4A_SPU  					57
    #define SPORT_4B_SPU  					58
    
    #define SPORT_5A_SPU  					59
    #define SPORT_5B_SPU  					60
    
    int SPU_init(void)
    {
    	if(adi_spu_Init(0, SpuMemory, NULL, NULL, &ghSpu) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to initialize SPU service\n");
    		return FAILED;
    	}
    
    	if(adi_spu_EnableMasterSecure(ghSpu, SPI2_SPU_PID, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPI2\n");
    		return (FAILED);
    	}
    
    	/* Make SPI2 Tx DMA to generate secure transactions */
    	if(adi_spu_EnableMasterSecure(ghSpu, SPI2_TxDMA_SPU_PID, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPI2 Tx DMA\n");
    		return (FAILED);
    	}
    
    	/* Make SPI2 Rx DMA to generate secure transactions */
    	if(adi_spu_EnableMasterSecure(ghSpu, SPI2_RxDMA_SPU_PID, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPI2 Rx DMA\n");
    		return (FAILED);
    	}
    
    	/* Make SPORT 0A to generate secure transactions */
    	if(adi_spu_EnableMasterSecure(ghSpu, SPORT_4A_SPU, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPORT0A\n");
    		return FAILED;
    	}
    
    	if(adi_spu_EnableMasterSecure(ghSpu, SPORT_4B_SPU, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPORT0A\n");
    		return FAILED;
    	}
    
    	if(adi_spu_EnableMasterSecure(ghSpu, SPORT_5A_SPU, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPORT0A\n");
    		return FAILED;
    	}
    
    	if(adi_spu_EnableMasterSecure(ghSpu, SPORT_5B_SPU, true) != ADI_SPU_SUCCESS)
    	{
    		REPORT_ERROR("Failed to enable Master secure for SPORT0A\n");
    		return FAILED;
    	}
    	return SUCCESS;
    }

    3. My code was modified based on the example titled "SPT_GBL_Audio-Passflow_TDM".

  • Hi,

    Thanks for the clarification.

    Could you please provide your comments on the following points? Your input will be very helpful for us to isolate the issue:

    1. Regarding "ADSP21565 use Sport0A can work, but Sport4A can't work. I can capture data on the data line through a logic analyzer, but there is no data for this variable in the program. The data of Sport0A is normal, but when switching to Sport4A, there is data on the data line, but the variable remains at 0"

    >> It appears that your modified code works correctly with SPORT0A, but not with SPORT4A. Can you please confirm this?
    You also mentioned that data is visible on the data line when using a logic analyzer, but the corresponding variable in your code remains zero. Have you verified whether the captured data is valid? If possible, please share a screenshot or image from the logic analyzer.

    2. Could you please share a flow diagram of your application? From your description, it appears that you are using A2B in combination with multiple SPORT interfaces, but we would like to better understand your complete application flow.

    3. Are you encountering any specific errors or exceptions during operation?

    Regards,
    Nandini C

  • 1.Confirmed, Sport4 is not functioning properly.

    2.Below is my workflow.

    3.No other abnormalities exist.

    Below is the schematic diagram I've provided to facilitate your troubleshooting. Thank you!

  • Hi,

    Thanks for the sharing the details.

    We understand that you have already contacted our private support. To avoid duplication of efforts, please continue the discussion there.

    Regards,
    Nandini C

Reply Children
No Data