for(baudRate= DEFAULT_BAUD_RATE; baudRate<5000000; baudRate*=2)
{
KeyStone_UART_config(baudRate, bInternalLoopback, UART_USE_EDMA_TO_TX);
/* Fill the Tx and Rx buffer with inversed data*/
#if 1
for(i=0; i<UART_TEST_BUF_BYTE_SIZE; i++)
{
UART_Test_Tx_Buf[i]= i+testData+'0';
UART_Test_Rx_Buf[i]=0;
}
#else
memset(UART_Test_Tx_Buf, testData, sizeof(UART_Test_Tx_Buf));
memset(UART_Test_Rx_Buf, ~testData, sizeof(UART_Test_Rx_Buf));
#endif
/* Send the data through EDMA */
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))//DATA IS not READY
{
//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;
}
cycles = TSC_count_cycle_from(startCycle);
//verfiy the receive data
for(i = 0; i < rxCount; i++)
{
if(UART_Test_Rx_Buf[i] == UART_Test_Tx_Buf[i])
{
correct++; //count the number of correct data
}
}
throughput = (unsigned long long)rxCount*8*gDSP_Core_Speed_Hz/
((unsigned long long)cycles*1000);
printf("UART%d: Tx %d bytes, Rx %d bytes, %d correct bytes. Consumes %d cycles, throughput is %dKbps\n",
TEST_UART_NUM, UART_TEST_BUF_BYTE_SIZE, rxCount, correct, cycles, throughput);
testData++; //change test data
}
代码跟例程一模一样,DOC文档的结果跟我一模一样,但是我觉得例程有问题,
for(i = 0; i < rxCount; i++)
{
if(UART_Test_Rx_Buf[i] == UART_Test_Tx_Buf[i])
{
correct++; //count the number of correct data
}
}
这个函数明显是统计正确的个数,代码写成错误的个数了,能请问下工程师大神需要怎么配置,然后使RX的数据跟TX的数据一样呢,用的EDMA传输的,我怀疑:传输时正常的,但是TX第二次传到THR的数据没有成功,导致RX接收THR的数据不变,随意接收到的数据总是第一次的数据,工程师大神能给我详细说下吗
Andy Yin1:
我使用如下例程测试internal loopback是正确的,我在KeyStone_UART_loopback_with_throughput函数末尾打点,在ccs memory view中观测UART_Test_Rx_Buf接收到的buffer数据是在更新的,并且与发送的数据一致。
http://www.deyisupport.com/question_answer/dsp_arm/c6000_multicore/f/53/t/47664.aspx