由于我特殊应用,串口波特率需要设置为6000,所以就按照用户手册,计算了UXbaud=137,UxGCR=7. 添加到程序里面以后,用串口调试软件进行
通信,数据总是出错的,串口调试软件为accessport,我已经验证串口调试助手是没有任何问题的,我在程序中修改如下:
sta
tic void HalUARTOpenDMA(halUARTCfg_t *config)
[
dmaCfg.uartCB = config->callBackFunc;
// Only supporting subset of baudrate for code size - other is possible.
HAL_ASSERT((config->baudRate == HAL_UART_BR_9600) ||
(config->baudRate == HAL_UART_BR_19200) ||
(config->baudRate == HAL_UART_BR_38400) ||
(config->baudRate == HAL_UART_BR_57600) ||
(config->baudRate == HAL_UART_BR_115200) ||
(config->baudRate == HAL_UART_BR_6144));
if((config->baudRate == HAL_UART_BR_6144))
[
UxBAUD = 137;
UxGCR = 7;
else
[
if (config->baudRate == HAL_UART_BR_57600 ||
config->baudRate == HAL_UART_BR_115200)
[
UxBAUD = 216;
]
else
[
UxBAUD = 59;
]
switch (config->baudRate)
[
case HAL_UART_BR_9600:
UxGCR = 8;
break;
case HAL_UART_BR_19200:
UxGCR = 9;
break;
case HAL_UART_BR_38400:
case HAL_UART_BR_57600:
UxGCR = 10;
break;
default:
// HAL_UART_BR_115200
UxGCR = 11;
break;
]
]
if (DMA_PM || config->flowControl)
[
UxUCR = UCR_FLOW | UCR_STOP; // 8 bits/char; no parity; 1 stop bit; stop bit hi.
PxSEL |= HAL_UART_Px_CTS; // Enable Peripheral control of CTS flow control on Px.
]
else
[
UxUCR = UCR_STOP; //2013年8月9日15:44:17 修改 为了适应iso7816
]
UxCSR = (CSR_MODE | CSR_RE);
if (DMA_PM)
[
PxIFG = 0;
PxIF = 0;
IENx |= IEN_BIT;
]
else if (UxUCR & UCR_FLOW)
[
// DMA Rx is always on (self-resetting). So flow must be controlled by the S/W polling the
// circular Rx queue depth. Start by allowing flow.
HAL_UART_DMA_SET_RDY_OUT();
PxDIR |= HAL_UART_Px_RTS;
]
#if HAL_UART_TX_BY_ISR
UTXxIF = 1; // Prime the ISR pump.
#endif
]
其它规范的波特率如1200,2400,4800等均没有问题,一旦设置为特殊波特率,就出现问题。
请TI工程师帮助下!谢谢!