MT6250D uart2能接收不能发送
时间:10-02
整理:3721RD
点击:
如题, 正在用50D的UART2进行数据通信。9600波特率
RX能正常接收,TX发送不了数据.
已经做过初始化了。 能正常接收。
发送函数如下:
void TEST_uart_tx(kal_uint8 *data, kal_uint16 length)
{
DCL_HANDLE handle;
#ifdef __DMA_UART_VIRTUAL_FIFO__
UART_CTRL_PUT_UART_BYTE_T data1;
#else
UART_CTRL_PUT_BYTES_T BMTPutBytes;
#endif
kal_uint8 *bp;
kal_uint16 dataleng;
//data copy
mEMSet( uart_tx_buff, 0, TEST_UART_TX_BUFF_SIZE);
meMCPy( uart_tx_buff, data, tx_buff_len);
handle = DclSerialPort_Open( TEST_UART_PORT, 0);
if(UARTPort[TEST_UART_PORT].power_on == KAL_FALSE)
{
UART_TurnOnPower( TEST_UART_PORT, KAL_TRUE);
}
dataleng = tx_buff_len;
#ifdef __DMA_UART_VIRTUAL_FIFO__
for(bp = uart_tx_buff; dataleng > 0; bp++,dataleng--)
{
data1.uData = (DCL_UINT8)(*bp);
DclSerialPort_Control(handle, SIO_CMD_PUT_UART_BYTE, (DCL_CTRL_DATA_T*)&data1);
}
#else
BMTPutBytes.puBuffaddr = (kal_uint8 *)uart_tx_buff;
BMTPutBytes.u2Length = dataleng;
DclSerialPort_Control( handle, UART_CMD_BMT_PUT_BYTES, (DCL_CTRL_DATA_T*)&BMTPutBytes);
#endif
}
RX能正常接收,TX发送不了数据.
已经做过初始化了。 能正常接收。
发送函数如下:
void TEST_uart_tx(kal_uint8 *data, kal_uint16 length)
{
DCL_HANDLE handle;
#ifdef __DMA_UART_VIRTUAL_FIFO__
UART_CTRL_PUT_UART_BYTE_T data1;
#else
UART_CTRL_PUT_BYTES_T BMTPutBytes;
#endif
kal_uint8 *bp;
kal_uint16 dataleng;
//data copy
mEMSet( uart_tx_buff, 0, TEST_UART_TX_BUFF_SIZE);
meMCPy( uart_tx_buff, data, tx_buff_len);
handle = DclSerialPort_Open( TEST_UART_PORT, 0);
if(UARTPort[TEST_UART_PORT].power_on == KAL_FALSE)
{
UART_TurnOnPower( TEST_UART_PORT, KAL_TRUE);
}
dataleng = tx_buff_len;
#ifdef __DMA_UART_VIRTUAL_FIFO__
for(bp = uart_tx_buff; dataleng > 0; bp++,dataleng--)
{
data1.uData = (DCL_UINT8)(*bp);
DclSerialPort_Control(handle, SIO_CMD_PUT_UART_BYTE, (DCL_CTRL_DATA_T*)&data1);
}
#else
BMTPutBytes.puBuffaddr = (kal_uint8 *)uart_tx_buff;
BMTPutBytes.u2Length = dataleng;
DclSerialPort_Control( handle, UART_CMD_BMT_PUT_BYTES, (DCL_CTRL_DATA_T*)&BMTPutBytes);
#endif
}
已经解决了。 是数据长度溢出了。 上面函数是可用的。