请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:IWR6843AOP 我的代码可以在没有 DMA 模式的情况下工作、但某个时候会丢失一个字节。 因此、我想使用 DMA 模式来避免数据丢失。
新代码参考示例"C:\ti\mmwave_sdk_03_06_00_00-LTS。\packages\ti\drivers\uart\test\xwr68xx"。
初始化代码:
// 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;
}
我使用 UART_WRITE 和 UART_READ 写入 TX/Rx、并使用 UART A 写入日志。 我可以看到 UART_read 始终返回0、而我的 PC 可以接收来自6843的数据。
当通过
#define uart_WIFI_USE_DMA 0
则代码将正常工作。