BF533 I2S receiving

Hi,

I am using the Ez-lit ADSP-BF533 kit (REV 2.1) on which I would like to read I2S data. While writing from the device (Using sport 1 for easy acces) is possible, the data isnt fed back.

The code:

#include<cdefBF533.h>
#include<defBF533.h>
#include<sys/exception.h>
#include<stdio.h>

#define LOOP_BACK


#define BUFFER_LENGTH 8


//#define BOTH_CHANNELS

#ifdef WORD_32
#define SLEN 0x1f
#else
#define SLEN 0xf
#endif

//define read/write buffers

short int Tx_Buffer[BUFFER_LENGTH] = {0x1,0x2,0x3,0x4,0x5,0xffff,0xcc,0x8};
short int Rx_Buffer[BUFFER_LENGTH];

volatile unsigned int Tx_count;
volatile unsigned int Rx_count;
volatile unsigned int Interrupt_source;

EX_INTERRUPT_HANDLER(sport_isr);


void main()
{

*pSIC_IMASK |= 0x1800;
register_handler(ik_ivg9, sport_isr);
asm ("ssync;") ;

//configure clock divider
*pSPORT1_TCLKDIV = 0xff;
asm ("ssync;") ;

*pSPORT1_TFSDIV = 0x10;
asm ("ssync;") ;




//setup SPORT1 Rx

*pSPORT1_RCR2 = SLEN;
asm ("ssync;") ;

#ifdef BOTH_CHANNELS
*pSPORT1_RCR2 |= TXSE;
asm ("ssync;") ;
#endif

*pSPORT1_RCR2 |= TSFSE;
asm ("ssync;") ;


*pSPORT1_RCR1 = RFSR|RSPEN;
asm ("ssync;") ;


//setup SPORT1 Tx

*pSPORT1_TCR2 = SLEN;
asm ("ssync;") ;

*pSPORT1_TCR2 |= TSFSE;
asm ("ssync;") ;


*pSPORT1_TCR1 = TFSR|ITFS|ITCLK|TSPEN;
asm ("ssync;") ;



//----------------------------------------//
//-------setup done, enter main loop------//
//----------------------------------------//

int x = 0;
while(1)
{



}
}



EX_INTERRUPT_HANDLER(sport_isr){


Interrupt_source = *pSIC_ISR ;


//if there is data in Rx register, read it

if((Interrupt_source)&0x0800)
{

Rx_Buffer[Rx_count] = *pSPORT1_RX16;

Rx_count++;
printf("%d \n",Rx_Buffer[Rx_count] = *pSPORT1_RX16);

if(Rx_count==BUFFER_LENGTH)
{
*pSPORT1_RCR1 = 0;
*pSPORT1_TCR1 = 0;

}

}else{

if(Tx_count < BUFFER_LENGTH)
{

*pSPORT1_TX16 = Tx_Buffer[Tx_count];

Tx_count++;

}

}
}

The writing is verified using a Salae logic analyser. The interrupt does not change to a read flag. What am I doing wrong?

  • Hello,

    Sorry for the delayed response.

    I understand that you are using SPORT I2S mode in Loopback mode. The receiver is able to read data correctly but the received data is not fed back to transmitter(i.e. loopback does not occur). Is this correct? BTW, I am attaching a simple SPORT code. In this code if the label "LOOP_BACK" is defined, the Rx port will also be enabled. This can be used to perform an external loopback between Tx and Rx ports of SPORT1. Though this example is provided for ADSP-BF561, you can easily modify this for ADSP-BF533.

    Best Regards,

    Jithul

    SPORT_Loop Back.zip