Hi team,
I configure the uart in fifo poll mode and loopback mode without edma or interrupt. I sent successfully 1024 bytes in Tx side but only 18 bytes in the RX side.
void KeyStone_UART_loopback_with_throughput(Bool bInternalLoopback)
{
int i;
unsigned int rxCount, correct;
unsigned int startCycle, cycles;
Uint32 throughput;
Uint32 baudRate;
Uint8 testData=0;
CSL_UartRegs *localUartRegs = gpUartRegs[TEST_UART_NUM];
KeyStone_UART_Interrupts_Init(FALSE, TRUE);
for(baudRate= DEFAULT_BAUD_RATE; baudRate<5000000; baudRate*=2)
{
KeyStone_UART_config(baudRate, bInternalLoopback, UART_USE_CORE_TO_TX);
/* Fill the Tx and Rx buffer with inversed data*/
for(i=0; i<UART_TEST_BUF_BYTE_SIZE; i++)
{
UART_Test_Tx_Buf[i]= testData+i;
UART_Test_Rx_Buf[i]= ~(testData+i);
}
KeyStone_UART_write(UART_Test_Tx_Buf, UART_TEST_BUF_BYTE_SIZE, TEST_UART_NUM);
startCycle = TSCL;
/* poll data from Rx side */
rxCount= 0;
correct= 0;
while(1)
{
while(!(localUartRegs->LSR & CSL_UART_LSR_DR_MASK))
{
//timeout if the time is more than 4 times of the expected time
if(TSC_count_cycle_from(startCycle)>
4*UART_TEST_BUF_BYTE_SIZE*10*(gDSP_Core_Speed_Hz/baudRate))
{
printf("UART%d timeout: Tx %d bytes, Rx %d bytes\n",
TEST_UART_NUM, UART_TEST_BUF_BYTE_SIZE, rxCount);
return;
}
}
UART_Test_Rx_Buf[rxCount++] = localUartRegs->RBR;
if(rxCount == UART_TEST_BUF_BYTE_SIZE)
break;
}
void KeyStone_UART_write(unsigned char *buffer, unsigned int byteLen, Uint32 uartNum)
{
for (i = 0; i < byteLen; i++)
{
//wait for UART FIFO empty
while(!((localUartRegs->LSR) & CSL_UART_LSR_THRE_MASK));
localUartRegs->THR = buffer[i];
}
}