Part Number:CC2530Other Parts Discussed in Thread: CC2541
我在使用CC2530串口UART1时,使用的是ALT.1,P0_4和P0_5作为发送和接收。
预编译配置为HAL_DMA HAL_UART_DMA=2 ZTOOL_P2
配置完成后,串口助手接收不到数据。哪位大佬可以帮忙解决一下?
uint8 UART_Init(uint8 port)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_9600;
uartConfig.flowControl = HAL_UART_FLOW_OFF; uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.flowControlThreshold = 64;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = UART_CallBack; //回调函数
return HalUARTOpen (port, &uartConfig);
}
void UART_CallBack(uint8 port, uint8 event)
{
uint8 data_TxLen = 0;
uint8 data_TxBuf[64] = {0};
if ((event & (HAL_UART_RX_FULL | HAL_UART_RX_ABOUT_FULL | HAL_UART_RX_TIMEOUT)) && !data_TxLen)
{
data_TxLen = HalUARTRead( port, data_TxBuf, 80);
if(data_TxLen)
{ if(data_TxLen>64)
data_TxLen = 64;
memcpy(data_TxBuf, data_TxBuf, data_TxLen);
HalUARTWrite( port, data_TxBuf, data_TxLen);
memset(data_TxBuf, 0, 64);
data_TxLen = 0;
}
}
}
UART_Init(0x01);
HalUARTWrite(0x01, "UART1 can be used\n", sizeof("UART1 can be used\n"));
Kevin Qiu1:
只是使用串口不带协议栈是吧,参考CC2541的串口例程,配置都是类似的:
swrc257.zip
也可以在网上搜索,CC2530串口例程应该是由很多的
,
Jason Wang:
带协议栈,在初始化串口的时候,UART0和UART1是可以通过接口配置,但如果使用UART1的ALT.1怎么配置呢?