SPORT Transmit Interrupt Handler Issue - ADSP-21489

Hi All,

Code written to config Channel A and B of SPORT0 as Transmitters with interrupts enable and Chanel A of SPORT1 as Receiver with interrupt enable. PCG is used to generate clocks to SPORT0 and SPORT1 (external clock to SPORTs)

Transmit Interrupt handler used to load data in Transmit Buffers, pTXSP0A and pTXSP0B. After data loaded into these buffers expected that the program control comes back to Main() Function then stays in Main() till the loaded data into pTXSP0A and pTXSP0B is tranferred WHEREAS the program enters into the function : EX_DISPATCHED_HANDLER_NESTED(_adi_osal_stdWrapper, iid,  index, arg) then wait in this function till data loaded into pTXSP0A and pTXSP0B is transmitted then enters into SPORT0 Hndler function to load next data bytes. 

while above is happening if any data i received in SPORT1 then program control enters into SPORT1 Handler then goes to SPORT0 Handler ... but not entering into Main().

Notice that if program calls :  Status = adi_int_InstallHandler(ADI_CID_P3I,(ADI_INT_HANDLER_PTR ) SPORT1Handler,0,true); is before Status = (int) adi_int_InstallHandler(ADI_CID_P6I,(ADI_INT_HANDLER_PTR ) SPORT0Handler,0,true); then code works as above.

If the program calls : Status = (int) adi_int_InstallHandler(ADI_CID_P6I,(ADI_INT_HANDLER_PTR ) SPORT0Handler,0,true); is before Status = adi_int_InstallHandler(ADI_CID_P3I,(ADI_INT_HANDLER_PTR ) SPORT1Handler,0,true); then the SPORT1 Handler do not receive data. 

Code is attached herewith. Please help to resolve the issue/bug. 

/*****************************************************************************
 * SPORT_Tx_INTR.c
 *****************************************************************************/

#include <sys/platform.h>
#include "adi_initialize.h"
#include "SPORT_Tx_INTR.h"
#include "def21489.h"
#include "sru.h"
#include<stdio.h>
#include <services/int/adi_int.h>
#include<string.h>

#define SPORT_UART_BAUDRATE  9600 	// Defining the required UART Baud Rate
#define USE_SELF_NESTING

#define PCLK 200000000		// ADSP-21489 PCLK=200MHz, i.e input clock to Precision Clock Generator-PCG when CPU runs at 400MHz
#define	TxCLKDIV  PCLK/SPORT_UART_BAUDRATE		// Divisor factor of PCG-Channel-A to generate clocks to SPORTs Tx-Channels.
#define RxCLKDIV  PCLK/(SPORT_UART_BAUDRATE*3)	// Divisor factor of PCG-Channel-A to generate clocks to SPORTs Rx-Channels.

void Init_SPORT(void); 	//Initializes all SPORT channels as UART channels.
void InitPCG(void);		//Initializes Precision Clock Generator Module to generate baud rate clocks to SPORT Channels
void ConfigSRU(void);	//Initializes DAI Pins of ADSP-21489 as UART-Tx and Rx.

static void SPORT0Handler(uint32_t iid, void* handlerArg);
static void SPORT1Handler(void);

unsigned char SPORT_RxProcess(unsigned int temp);
unsigned short int SPORT_TxProcess(unsigned char tx1);

char strA[]="Hello";
int SPORT0ATxBuffLength;
char strB[]="Ananth";
int SPORT0BTxBuffLength;

int SPORT0A_TxByte=0xAB;
volatile int SPORT0ATxCompleted=0;

int SPORT0B_TxByte;
volatile int SPORT0BTxCompleted=0;

int SPORT1A_RxByte;
volatile int SPORT1A_RxByte_Available=0;

void main(void)
{
	unsigned char temp, TxData, RxData=0xAB; // to receive data from SPORT1 through UART Config
	volatile int dumm1=10, dumm2=20, dumm3;
	int Status;

	SPORT0ATxBuffLength=strlen(strA);
	SPORT0BTxBuffLength=strlen(strB);

	adi_initComponents();
	ConfigSRU();
	Init_SPORT();

	Status = adi_int_InstallHandler(ADI_CID_P3I,(ADI_INT_HANDLER_PTR ) SPORT1Handler,0,true);
	printf("S1 : %d \n", Status);

	Status = (int) adi_int_InstallHandler(ADI_CID_P6I,(ADI_INT_HANDLER_PTR ) SPORT0Handler,0,true);
	printf("S0 : %d \n", Status);

	while(1)
	{
		if(SPORT1A_RxByte_Available==1)
		{
			SPORT1A_RxByte_Available=0;
			SPORT0ATxBuffLength=strlen(strA);
			SPORT0BTxBuffLength=strlen(strB);

			RxData = SPORT_RxProcess(SPORT1A_RxByte);

			SPORT0ATxBuffLength=strlen(strA);
			SPORT0BTxBuffLength=strlen(strB);
			SPORT0ATxCompleted=0;
			SPORT0BTxCompleted=0;
			adi_int_EnableInt(ADI_CID_P6I, true);
		}

		dumm3=dumm1+dumm2;
	}

}


static void SPORT0Handler(uint32_t iid, void* handlerArg)
{
	volatile unsigned int status0, err;
	status0=*pSPCTL0;

	if(SPORT0ATxCompleted==0)
	{
		if((status0 & 0xC0000000) == 0x00000000)	// Check DXS_A 2-Bit-Field status for Channel-A Data Buffer Status
		{
			*pTXSP0A = SPORT_TxProcess((unsigned char)strA[SPORT0ATxBuffLength]); // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
			SPORT0ATxBuffLength--;
			if(SPORT0ATxBuffLength<0)
			//SPORT0ATxBuffLength=strlen(strA);
				SPORT0ATxCompleted=1;
		}
	}

	if(SPORT0BTxCompleted==0)
	{
		if((status0 & 0x180000000) == 0x00000000)	// Check DXS_B 2-Bit-Field status for Channel-A Data Buffer Status
		{
			//*pTXSP0B = SPORT0B_TxByte;	/* Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB*/

			SPORT0BTxBuffLength--;
			*pTXSP0B = SPORT_TxProcess((unsigned char)strB[SPORT0BTxBuffLength]); // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
			if(SPORT0BTxBuffLength==0)
			//SPORT0BTxBuffLength=strlen(strB);
				SPORT0BTxCompleted=1;
		}
	}

	if ((SPORT0ATxCompleted==1) && (SPORT0BTxCompleted==1))
	{
		//adi_int_EnableInt(ADI_CID_P6I, false);	// Disable SPORT0 interrupts which is high priority interrupt which blocks the SPORT2 interrupts
	}
}

static void SPORT1Handler(void)
{
	volatile unsigned int status1;
	status1=*pSPCTL1;

	if((status1 & 0xC0000000) != 0x00000000)	// Check DXS_A 2-Bit-Field status for Channel-A Data Buffer Status
	{
		SPORT1A_RxByte = *pRXSP1A; // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
		SPORT1A_RxByte_Available=1;
	}

	if(status1 & 0x180000000 != 0x000000000)	// Check DXS_B 2-Bit-Field status for Channel-A Data Buffer Status
	{
		//SPORT3B_RxByte = *pRXSP3B; // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
	}
}

unsigned char SPORT_RxProcess(unsigned int temp)
{
	unsigned char ch;
	unsigned int value=0;

	value+= ((temp>>23) &(1<<0));
	value+= ((temp>>19) &(1<<1));
	value+= ((temp>>15) &(1<<2));
	value+= ((temp>>11) &(1<<3));
	value+= ((temp>>7) &(1<<4));
	value+= ((temp>>3) &(1<<5));
	value+= ((temp<<1) &(1<<6));
	value+= ((temp<<5) &(1<<7));
	ch=(unsigned char)value;
	return ch;
}

unsigned short int SPORT_TxProcess(unsigned char tx1)
{
	unsigned short int tx=0x00;
	unsigned char temp=0;
	unsigned short int Ms1= 0x03FC;
	unsigned short int Ms2= 0x0401;
	tx = tx1;
	tx= tx<<2;
	tx = tx & Ms1;
	tx = tx | Ms2;
	return tx;
}


/*
 * This function initializes the SRU for below actions:
 * 1. Configure DAI-Pin-2 as SPORT0-UART Transmit Pin.
 * 2. Configure DAI-Pin-4 as SPORT1-UART Receive Pin.
 * 3. Call Precision Clock Generator Init Function to generate external clocks to SPORT-0 and 1.
 * 4. Configures the SPORT-0 and 1 for receiving external clock that is from PCG.
 * 5. Configure the DAI-Pin-4 as SPORT1 to received External Frame Sync signal from DAI-Pin-4 which is also act as UART/SPORT Data Pin
 */
void ConfigSRU(void)
{

	InitPCG();	// Precision Clock Generator generates Clocks to for Tx and Rx of SPORT0-7.

	/******* UART-1 Config:SPORT0-A with DAI_PB-2::EZ-BoardPin:15 as Tx & SPORT1-A with DAI_PB-1::EZ-BoardPin:13 as Rx **********/

		/* SPORT-0 Pins Config to transmit Data */
		SRU(HIGH,PBEN02_I);
		SRU(SPORT0_DA_O,DAI_PB02_I);

		/* SPORT-1 Pins Config to Receive Data*/
		SRU(LOW,PBEN01_I);
		SRU(DAI_PB01_O,SPORT1_DA_I);

		/* SPORT-0,1 and PCG Pins Config */

		InitPCG();

		SRU(PCG_CLKA_O,SPORT0_CLK_I);       //SPORT-0_CLK_I is same as PCG_CLKA_O.
		SRU(PCG_CLKB_O,SPORT1_CLK_I);       //SPORT-1_CLK_I is same as SPORT1_CLK_O.
		SRU(DAI_PB01_O,SPORT1_FS_I);    	//SPORT-1 Frame Sync is connected to DAI-Pin-4.

}

/*
 * This function initializes the SPORT0 Channel A to emulate the UART Transmit and SPORT1 Channel A to emulate the UART Receive.
 * The code is developed using the Analog Devices Application Notes: EE-191, EE-391, EE-1245
 */
void Init_SPORT()
{

	//Clearing the Buffers of SPORTs.
	*pSPCTL0 = 0;
	*pSPCTL1 = 0;

	//FSDIV needs to fix for SPORTs:: Set FSDIV as 32 or above for 29-Bits Receive and set 12 or above for 11-Bit transfer
	*pDIV0 = 0x000B0000|(1<<1);	/*Divisor register for FS and CLK for SPORT-0*/
	*pDIV1 = 0x001B0000|(1<<1);	/*Divisor register for FS and CLK for SPORT-1*/

	//UART-1 config uses SPORT1A and 2A.
	*pSPERRCTL0=0x00;		//Disable Error detection
	*pSPERRCTL1=0x00;		//Disable Error detection

	*pSPCTL0=SPEN_A | SPEN_B | SLEN11 | CKRE |  FSR | IFS | LFS | LAFS  | SPTRAN | LSBF; //Sets SPORT0-A&B as UART1-Tx & UART4-Tx.
	*pSPCTL1=LAFS | LFS | FSR | SLEN29 | SPEN_A;	//Sets SPORT1-A as UART1-Rx.
}

void InitPCG(void)
{
    unsigned char n;

    /*Disable PCG = Clearing the PCG Enable Bits in order to Config PCG */
    *pPCG_CTLA0 = 0x00;
    *pPCG_CTLB0 = 0x00;

    // Wait minimum 16 cycles after disable the PCG : to give enough time to stabilize PCG.
	for (n=0; n<100; n++)
    {
        asm("NOP;");
    }

    /*PCG CLK generation */
	*pPCG_SYNC1 = (*pPCG_SYNC1) | 0x00000004;	// Configuring the Channel-A input clock as PCLK=200MHz.
	*pPCG_SYNC1 = (*pPCG_SYNC1) | 0x00040000;	// Configuring the Channel-B input clock as PCLK=200MHz.

    *pPCG_CTLA1 = TxCLKDIV & CLKADIV;	// Configuring the Channel-A to generate Clock output suitable to UART-Transmit
    *pPCG_CTLB1 = RxCLKDIV & CLKBDIV;	// Configuring the Channel-B to generate Clock output suitable to UART-Receive = 03 times of Transmit Buad Rate

    /*Enable PCG = Setting the PCG Enable Bits in order to Config PCG */
    *pPCG_CTLA0 = ENCLKA;
    *pPCG_CTLB0 = ENCLKB;

}



Subject/Topic name is added with ADSP-21489
[edited by: Muni at 4:49 AM (GMT 0) on 1 May 2019]
  • +1
    •  Analog Employees 
    on Jun 8, 2019 12:48 PM over 1 year ago
    Hello ,

    Apologies for the delay. Were you able to get going.
    Please find the attached VisualDSP++ project file for ADSP-21489 SPORT0&1 loopback test. The example would directly run on ADSP-21489 Ezkit. Please make this code as a reference for your software development.

    Regards,
    Lalitha.S

  • Dear Latha,

    Thank you for spending time in sending me reply. 

    For your information I am using the Cross Core Embedded (CCE) Tool chain and to enable/register interrupts I am using the adi_int_InstallHandler() APIs available in CCE. 

    I tried with two SPORT channels to transmit data through interrupt handling WHEREAS the SPORT interrupts are not working. 

    Please have the code (.c file and also .h files of my CCE project)  here attached or your review ...

    
    /*****************************************************************************
     * SPORT_Tx_INTR.c
     *****************************************************************************/
    #include <sys/platform.h>
    #include "adi_initialize.h"
    #include "SPORT_Tx_INTR.h"
    #include "def21489.h"
    #include "sru.h"
    #include<stdio.h>
    #include <services/int/adi_int.h>
    #include<string.h>
    
    #define SPORT_UART_BAUDRATE  921600 	// Defining the required UART Baud Rate
    #define USE_SELF_NESTING
    
    #define PCLK 200000000	// ADSP-21489 PCLK=200MHz, i.e input clock to Precision Clock Generator-PCG when CPU runs at 400MHz
    #define	TxCLKDIV  PCLK/SPORT_UART_BAUDRATE		// Divisor factor of PCG-Channel-A to generate clocks to SPORTs Tx-Channels.
    #define RxCLKDIV  PCLK/(SPORT_UART_BAUDRATE*3)	// Divisor factor of PCG-Channel-A to generate clocks to SPORTs Rx-Channels.
    
    void main(void)
    {
    	unsigned char temp, TxData, RxData=0xAB; // to receive data from SPORT1 through UART Config
    	volatile int dumm1=10, dumm2=20, dumm3;
    
    	int Status;
    
    	adi_initComponents();
    	ConfigSRU();
    	//Init_SPORT();
    	BDL_SPORT_Init();
    
    	Status = adi_int_InstallHandler(ADI_CID_P7I,(ADI_INT_HANDLER_PTR ) SPORT2Handler,0,true);
    	printf("S2 : %d \n", Status);
    	Status = adi_int_InstallHandler(ADI_CID_P3I,(ADI_INT_HANDLER_PTR ) SPORT1Handler,0,true);
    	printf("S1 : %d \n", Status);
    	Status = (int) adi_int_InstallHandler(ADI_CID_P6I,(ADI_INT_HANDLER_PTR ) SPORT0Handler,0,true);
    	printf("S0 : %d \n", Status);
    
    
    	SPORT0ATxBuffLength=strlen(strA);
    	SPORT0BTxBuffLength=strlen(strB);
    	SPORT2ATxBuffLength=strlen(strA);
    
    	while(1)
    	{
    		dumm3++;
    		printf("\t %d",dumm3);
    	}
    
    }
    
    static void SPORT0Handler(uint32_t iid, void* handlerArg)
    {
    	volatile unsigned int status0, err;
    	status0=*pSPCTL0;
    
    	if(SPORT0ATxCompleted==0)
    	{
    		//if((status0 & 0xC0000000) == 0x00000000)	// Check DXS_A 2-Bit-Field status for Channel-A Data Buffer Status
    		{
    			*pTXSP0A = (unsigned char)strA[SPORT0ATxBuffLength]; // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
    			//for(int i=0; i<=1000; i++);
    			SPORT0ATxBuffLength--;
    			if(SPORT0ATxBuffLength<0)
    				SPORT0ATxBuffLength=strlen(strA);
    
    		}
    	}
    
    /*
    	if (SPORT0ATxCompleted==1)
    	{
    		adi_int_EnableInt(ADI_CID_P6I, false);	// Disable SPORT0 interrupts which is high priority interrupt which blocks the SPORT2 interrupts
    	}
    
     */
    }
    
    static void SPORT1Handler(void)
    {
    
    	volatile unsigned int status1;
    	status1=*pSPCTL1;
    
    	if((status1 & 0xC0000000) != 0x00000000)	// Check DXS_A 2-Bit-Field status for Channel-A Data Buffer Status
    	{
    		SPORT1A_RxByte = *pRXSP1A; // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
    		SPORT1A_RxByte_Available=1;
    		for(int i=0; i<=1000; i++);
    	}
    
    }
    
    static void SPORT2Handler(void)
    {
    	volatile unsigned int status2;
    	status2=*pSPCTL2;
    
    	if(SPORT2ATxCompleted==0)
    	{
    //		if((status2 & 0xC0000000) == 0x00000000)	// Check DXS_A 2-Bit-Field status for Channel-A Data Buffer Status
    		{
    			//*pTXSP2A = SPORT_TxProcess(SPORT2A_TxByte); /* Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB */
    			//SPORT2ATxCompleted=1;
    
    			*pTXSP2A = (unsigned char)strB[SPORT2ATxBuffLength]; // Read/Write data from/to Receive/Transmit Data Buffer : RXSPxB or TXSPxB
    			//for(int i=0; i<=1000; i++);
    			SPORT2ATxBuffLength--;
    			if(SPORT2ATxBuffLength<=0)
    				SPORT2ATxBuffLength=strlen(strB);
    				//SPORT2ATxCompleted=1;
    
    		}
    	}
    
    }
    
    /*
     * This function initializes the SRU for below actions:
     * 1. Configure DAI-Pin-2 as SPORT0-UART Transmit Pin.
     * 2. Configure DAI-Pin-4 as SPORT1-UART Receive Pin.
     * 3. Call Precision Clock Generator Init Function to generate external clocks to SPORT-0 and 1.
     * 4. Configures the SPORT-0 and 1 for receiving external clock that is from PCG.
     * 5. Configure the DAI-Pin-4 as SPORT1 to received External Frame Sync signal from DAI-Pin-4 which is also act as UART/SPORT Data Pin
     */
    void ConfigSRU(void)
    {
    
    	InitPCG();	// Precision Clock Generator generates Clocks to for Tx and Rx of SPORT0-7.
    
    	/******* Port-1 Config:SPORT0-A with DAI_PB-2::EZ-BoardPin:15 as uart Tx & SPORT1-A with DAI_PB-1::EZ-BoardPin:13 as uart Rx **********/
    
    		/* SPORT-0 Pins Config to transmit Data */
    		SRU(HIGH,PBEN02_I);             //Enable Pin-Buffer so that DAI-Pin-2 act as SPORT-0-UART Transmit Data Pin. Tx-Output from ADSP
    
    	/****Port-2 Config:SPORT2-A with DAI_PB-4::EZ-BoardPin:19 as Tx & SPORT3-A with DAI_PB-3::EZ-BoardPin:17 as Rx ****/
    
    		/* SPORT-0 Pins Config to transmit Data */
    		SRU(HIGH,PBEN04_I);             //Enable Pin-Buffer so that DAI-Pin-2 act as SPORT-0-UART Transmit Data Pin. Tx-Output from ADSP
    		SRU(SPORT2_DA_O,DAI_PB04_I);    //SPORT0 Data Pin is connected to DAI-Pin-2 as SPORT-0-UART Transmit Data Pin. Tx-Output from ADSP
    
    		/* SPORT-3 Pins Config to Receive Data*/
    		SRU(LOW,PBEN03_I);              //Disable Pin-Buffer so that DAI-Pin-4 act as SPORT-1-UART Receive Data Pin. Rx-Input to ADSP
    		SRU(DAI_PB03_O,SPORT3_DA_I);    //DAI-Pin-4 is connected as SPORT1 Data Pin which is configured to received data. Receive Data Pin.
    
    		/* SPORT-0,1 and PCG Pins Config */
    		SRU(PCG_CLKA_O,SPORT2_CLK_I);       //SPORT-0_CLK_I is same as SPORT2_CLK_O.
    		SRU(PCG_CLKB_O,SPORT3_CLK_I);       //SPORT-1_CLK_I is same as SPORT3_CLK_O.
    		SRU(DAI_PB03_O,SPORT3_FS_I);    	//SPORT-1 Frame Sync is connected to DAI-Pin-4.
    
    }
    
    /*
     * This function initializes the SPORT0 Channel A to emulate the UART Transmit and SPORT1 Channel A to emulate the UART Receive.
     * The code is developed using the Analog Devices Application Notes: EE-191, EE-391, EE-1245
     */
    void Init_SPORT()
    {
    
    	//Clearing the Buffers of SPORTs.
    	*pSPCTL0 = 0;
    	*pSPCTL1 = 0;
    	*pSPCTL2 = 0;
    	*pSPCTL3 = 0;
    
    	//FSDIV needs to fix for SPORTs:: Set FSDIV as 32 or above for 29-Bits Receive and set 12 or above for 11-Bit transfer
    	*pDIV0 = 0x000B0000|(1<<1);	/*Divisor register for FS and CLK for SPORT-0*/
    	*pDIV1 = 0x001B0000|(1<<1);	/*Divisor register for FS and CLK for SPORT-1*/
    	*pDIV2 = 0x00170000|(1<<1);	/*Divisor register for FS and CLK for SPORT-2*/
    
    
    	//Port-1 config uses SPORT1A and 2A.
    	*pSPERRCTL0=0x00;		//Disable Error detection
    	*pSPERRCTL1=0x00;		//Disable Error detection
    
    	*pSPCTL0=SPEN_A | SLEN11 | CKRE |  FSR | IFS | LFS | LAFS  | SPTRAN | LSBF; //Sets SPORT0-A&B as UART1-Tx & UART4-Tx.
    	*pSPCTL1=LAFS | LFS | FSR | SLEN29 | SPEN_A;	//Sets SPORT1-A as UART1-Rx.
    
    	//Port-2 config uses SPORT2A and 3A.
    	*pSPERRCTL2=0x00;		//Disable Error detection
    	*pSPERRCTL3=0x00;		//Disable Error detection
    	*pSPCTL2=SPEN_A | SLEN11 | CKRE |  FSR | IFS | LFS | LAFS  | SPTRAN | LSBF;   //Sets SPORT2-A as UART2-Tx.
    	*pSPCTL3=LAFS | LFS | FSR | SLEN29 | SPEN_A;	//Sets SPORT3-A as UART2-Rx.
    
    }
    
    void InitPCG(void)
    {
        unsigned char n;
    
        /*Disable PCG = Clearing the PCG Enable Bits in order to Config PCG */
        *pPCG_CTLA0 = 0x00;
        *pPCG_CTLB0 = 0x00;
    
        // Wait minimum 16 cycles after disable the PCG : to give enough time to stabilize PCG.
    	for (n=0; n<100; n++)
        {
            asm("NOP;");
        }
    
        /*PCG CLK generation */
    	*pPCG_SYNC1 = (*pPCG_SYNC1) | 0x00000004;	// Configuring the Channel-A input clock as PCLK=200MHz.
    	*pPCG_SYNC1 = (*pPCG_SYNC1) | 0x00040000;	// Configuring the Channel-B input clock as PCLK=200MHz.
    
        *pPCG_CTLA1 = TxCLKDIV & CLKADIV;	// Configuring the Channel-A to generate Clock output suitable to UART-Transmit
        *pPCG_CTLB1 = RxCLKDIV & CLKBDIV;	// Configuring the Channel-B to generate Clock output suitable to UART-Receive = 03 times of Transmit Buad Rate
    
        /*Enable PCG = Setting the PCG Enable Bits in order to Config PCG */
        *pPCG_CTLA0 = ENCLKA;
        *pPCG_CTLB0 = ENCLKB;
    
    }
    
    
    void BDL_SPORT_Init(void)
    {
    	int clkdiv,fsdiv;
    
    	*pSPCTL0 = 0;							        /*Clear out SPORT 0 registers*/
    	*pDIV0 = 0x003F0000|(SPORT_CLK_DIVISOR<<1);		/*Divisor register for FS and CLK*/
    	*pSPCTL0|= SPCTL0_SET;  				        /*SPORT0 as transmitting master*/
    	*pSPCTL1 = 0;
    	*pDIV1 = 0x003F0000|(SPORT_CLK_DIVISOR << 1);
    	*pSPCTL1 |= SPCTL1_SET;
    }
    
    /*****************************************************************************
     * SPORT_Tx_INTR.h
     *****************************************************************************/
    
    #ifndef __SPORT_TX_INTR_H__
    #define __SPORT_TX_INTR_H__
    
    /* Add your custom header content here */
    
    #define SPORT_CLK_DIVISOR 1//25MHZ
    #define SPCTL0_SET ( SPEN_A | SLEN32 | ICLK | CKRE |  FSR | IFS | LFS | LAFS  | SPTRAN | 0 ) //LSBF FOR lsb
    #define SPCTL2_SET ( SPEN_A | SLEN32 | ICLK | CKRE |  FSR | IFS | LFS | LAFS  | SPTRAN | 0 ) //LSBF FOR lsb
    
    #define SPCTL1_SET ( SPEN_A | SLEN32 | FSR  | LFS | LAFS | 0 )
    
    void Init_SPORT(void); 	//Initializes all SPORT channels as UART channels.
    void BDL_SPORT_Init(void);
    void InitPCG(void);		//Initializes Precision Clock Generator Module to generate baud rate clocks to SPORT Channels
    void ConfigSRU(void);	//Initializes DAI Pins of ADSP-21489 as UART-Tx and Rx.
    
    static void SPORT0Handler(uint32_t iid, void* handlerArg);
    static void SPORT1Handler(void);
    static void SPORT2Handler(void);
    
    char strA[]="Hello";
    int SPORT0ATxBuffLength;
    char strB[]="Ananth";
    int SPORT0BTxBuffLength;
    
    int SPORT0A_TxByte=0xAB;
    volatile int SPORT0ATxCompleted=0;
    int SPORT1A_RxByte;
    
    int SPORT2A_TxByte=0xAB;
    volatile int SPORT2ATxCompleted=0;
    int SPORT2ATxBuffLength;
    
    volatile int SPORT1A_RxByte_Available=0;
    
    #endif /* __SPORT_TX_INTR_H__ */
    
     

  • 0
    •  Analog Employees 
    on Jul 15, 2019 9:09 AM over 1 year ago in reply to Muni

    Hello,

    Apologies for the delay.

    We have ported CCES project file for ADSP-21489 SPORT0&1 loopback test. Can you please refer this.

    Regards,
    Lalitha.S

    SPORT_21489.zip

  • SPORT_21489.rarDear Latha,

    Thank you for sharing the code that uses DMA, but need more help on stated below :

    In the code that you have shared, I have done modification such that DMA is not used for data transfers then the Code do not enter into Receive Interrupt Handler of SPORT and also code in the main() is not executed. 

    See the output for the attached project. 

    Please let me know how to handles all interrupts (without using DMA) while all SPORTs are enabled in Interrupt Mode.

    My application needs all SPORTs with Interrupts enabled (without using DMA).

    Regards,

    Muni.

  • 0
    •  Analog Employees 
    on Aug 27, 2019 10:47 AM over 1 year ago in reply to Muni
    Hello,

    Please refer the attached code for SPORT core interrupt. This code is for ADSP-21479. Please take this code as reference and modify accroding to you requirement.

    Regards,
    Lalitha.S