TI工程师,您们好!CC2541的串口波特率自己定义为2400,1200或者4800都没有任何问题,一旦我设置为一个特殊的波特率,就出错!
由于我特殊应用,串口波特率需要设置为6000,所以就按照用户手册,计算了UXbaud=137,UxGCR=7. 添加到程序里面以后,用串口调试软件进行通信,数据总是出错的,串口调试软件为accessport,我已经验证串口调试助手是没有任何问题的,我在程序中修改如下:
static 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工程师帮助下!谢谢!
Are you target to have Baud Rate 6144 instead of 6000
You may try UxBAUD = 147;UxGCR = 7;
多谢了,问题找到了,不是单片机的问题,是我程序问题,谢谢~
請教一下,我用 TI CC2541 BLE 1.3.2 protocol stack, 並且用了 http://processors.wiki.ti.com/index.php/SimpleBLEPeripheral_SerialInterface 當範本參考,加入了 serial port 的功能,在 115200 bps 的時候傳送出來的資料是正確的,但是 19200 bps 就有一堆錯誤,不知道可能是哪裡有問題?謝謝!
我的 e-mail 是 alberthuang314@gmail.com
這是我設定的 code:
HalUARTInit();
// configure UART
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_19200;
uartConfig.flowControl = HAL_UART_FLOW_OFF;
uartConfig.flowControlThreshold = 0;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 256;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = (halUARTCBack_t)cSerialPacketParser;
// start UART
// Note: Assumes no issue opening UART port.
(void)HalUARTOpen( HAL_UART_PORT_0, &uartConfig );
试下把这条语句注释掉:HCI_EXT_ClkDivOnHaltCmd( HCI_EXT_ENABLE_CLK_divIDE_ON_HALT );