My code could work with no dma mode, but lost one byte some time. So I want to use dma mode to avoid the lost of data.
The new code refer to the example "C:\ti\mmwave_sdk_03_06_00_00-LTS\packages\ti\drivers\uart\test\xwr68xx".
The init code:
// let uart b work with tx/rx extern UART_Config UART_config[]; UartSci_HwCfg* hwcfg = (UartSci_HwCfg*) UART_config[1].hwAttrs; hwcfg->duplexity = UartSci_Duplexity_FULL; #if UART_WIFI_USE_DMA DMA_init (); #endif UART_init(); UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_BINARY; uartParams.readDataMode = UART_DATA_BINARY; uartParams.readReturnMode = UART_RETURN_FULL; uartParams.readEcho = UART_ECHO_OFF; uartParams.clockFrequency = gFdMCB.cfg.platformCfg.sysClockFrequency; uartParams.baudRate = gFdMCB.cfg.platformCfg.commandBaudRate; uartParams.isPinMuxDone = 1U; uartParams.readTimeout = 50; #if UART_WIFI_USE_DMA DMA_Params dmaParams; DMA_Params_init(&dmaParams); DMA_Handle DMAHandle; DMAHandle = DMA_open(1, &dmaParams, &errCode); if (DMAHandle == NULL) { printf ("Error: Unable to open the DMA Instance [Error code %d]\n", errCode); log_write_fmt ("Error: Unable to open the DMA Instance [Error code %d]\n", errCode); return; } uartParams.dmaHandle = DMAHandle; uartParams.txDMAChannel = 1; uartParams.rxDMAChannel = 2; #endif /* Open the wifi UART Instance: */ UART_Handle uartHandle = UART_open(1, &uartParams); if (uartHandle == NULL) { //System_printf("Error: Unable to open the Wifi UART Instance\n"); log_write("Error: Unable to open the Wifi UART Instance\n"); tvt_debugAssert (0); return; }
I use UART_write and UART_read to tx/rx, and Uart A to write log. So I could see that UART_read always return 0, while my PC could receive data from the 6843.
When disable dma by
#define UART_WIFI_USE_DMA 0
the code would work fine.