TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2530用z-stack怎么使用双串口

用z-stack 2.5.1a,想同时使用2个串口,怎么配置呢,不使用流控的情况下,可以两个串口都放在P0上吗

Yue TANG:

参考这个帖子

https://e2e.ti.com/support/wireless_connectivity/zigbee_6lowpan_802-15-4_mac/f/158/t/169089

void initUart(halUARTCBack_t pf){  halUARTCfg_t uartConfig;  uartConfig.configured           = TRUE;  uartConfig.baudRate             = HAL_UART_BR_19200;  uartConfig.flowControl          = FALSE;  uartConfig.flowControlThreshold = 48;  uartConfig.rx.maxBufSize        = 128;  uartConfig.tx.maxBufSize        = 128;  uartConfig.idleTimeout          = 6;     uartConfig.intEnable            = TRUE;                uartConfig.callBackFunc         = pf;  HalUARTOpen (HAL_UART_PORT_0, &uartConfig);}

And, the followings are the source code that use to initialized UART1 (P1_6/P1_7)

void initUart1(halUARTCBack_t pf){  halUARTCfg_t uartConfig;  uartConfig.configured           = TRUE;                uartConfig.baudRate             = HAL_UART_BR_115200;  uartConfig.flowControl          = FALSE;  uartConfig.flowControlThreshold = 48;  uartConfig.rx.maxBufSize        =128;  uartConfig.tx.maxBufSize        = 128;  uartConfig.idleTimeout          = 6;     uartConfig.intEnable            = TRUE;                uartConfig.callBackFunc         = pf;  HalUARTOpen (HAL_UART_PORT_1, &uartConfig);}

I don't do anything special. Just wondering that is it possible that your TX/RX is revered. Do you want to change your HW from P0_2(RX)/P0_3(TX)  to P0_2(TX) and P0_3(RX)?

and change the Compile options ->C/C++ Compiler-> Preprocessor and Copy these lines in it.

HAL_UART=TRUEHAL_UART_ISR=1HAL_UART_DMA=2

Two uarts will start working

chong huang:

回复 Yue TANG:

TY您好,我参考您这个帖子以及TI论坛上的其他相关资料还有其他论坛上的资料。自己测试发现在协议栈里面跑  两个串口  特别困难。现在的情况是UART1(P1_6和P1_7)能够向外界发送数据,不能接收数据。但是通过测试发现UART1口的接收函数(回调函数)一旦触发就一直在运行。能不能请您或其他工作人员对在协议栈里面让两个串口同时工作做一个详细的总结。谢谢了。我参考的资料是:

协议栈:ZStack-CC2530-2.3.0-1.4.0

相关帖子:http://www.deyisupport.com/question_answer/wireless_connectivity/zigbee/f/104/t/97898.aspx

http://www.deyisupport.com/question_answer/wireless_connectivity/zigbee/f/104/t/106996.aspx

https://e2e.ti.com/support/wireless_connectivity/zigbee_6lowpan_802-15-4_mac/f/158/t/169089

http://www.feibit.com/forum.php?mod=viewthread&tid=9654

http://bbs.eeworld.com.cn/thread-298625-1-1.html

http://blog.csdn.net/shiwaxinbin/article/details/9004256

Yue TANG:

回复 chong huang:

理解。近期我会测试下,有结果会在这里post。

JiWei Gao:

回复 Yue TANG:

TY您好,根据此帖在Z-Stack Mesh 1.0.0中GenericApp例程中修改双串口工作,在编译选项中定义

HAL_UART=TRUE

HAL_UART_ISR=1

HAL_UART_DMA=2

代码中串口初始化

void Uart_Init(uint8 port){  halUARTCfg_t uartConfig;  uartConfig.configured           = TRUE;              // 2×30 don't care – see uart driver.  uartConfig.baudRate             = HAL_UART_BR_9600;  uartConfig.flowControl          = FALSE;  uartConfig.flowControlThreshold = 64; // 2×30 don't care – see uart driver.  uartConfig.rx.maxBufSize        = 128;  // 2×30 don't care – see uart driver.  uartConfig.tx.maxBufSize        = 128;  // 2×30 don't care – see uart driver.  uartConfig.idleTimeout          = 6;   // 2×30 don't care – see uart driver.  uartConfig.intEnable            = TRUE;              // 2×30 don't care – see uart driver.  if(port == HAL_UART_PORT_0)    uartConfig.callBackFunc         = UART0_CallBack;  else    uartConfig.callBackFunc         = UART1_CallBack;  HalUARTOpen (port, &uartConfig);}

static void UART0_CallBack(uint8 port, uint8 event){    uint16 len=0;  len=HalUARTRead(HAL_UART_PORT_0,RxBuf,128);  if(len > 0)  {    HalUARTWrite( HAL_UART_PORT_0, RxBuf, len );    len=0;  }}

static void UART1_CallBack(uint8 port, uint8 event){    uint16 len=0;  len=HalUARTRead(HAL_UART_PORT_1,RxBuf,128);  if(len > 0)  {    HalUARTWrite( HAL_UART_PORT_1, RxBuf, len );    len=0;  }}

UART0工作正常,但UART1发送数据给串口后,第一次回复正确,之后自己不断进入中断输出之前输入的数据,一直打印输出,不知道是哪里修改或设置不正确,能给些建议吗?

yao li3:

我也是找了好多资料都不成功 持续关注

yao li3:

HAL_UART=TRUEHAL_UART_ISR=2HAL_UART_DMA=1

这三条加上就开启了 P02 P03   和 P16 P17的双串口

如果想将串口1的引脚作用在P04 P05上则需要做以下修改

修改_hal_uart_isr.c中的宏定义

#define PxOUT P1 #define PxDIR P1DIR#define PxSEL P1SEL

改为

#define PxOUT P0#define PxDIR P0DIR#define PxSEL P0SEL

————————————————————————————————————

#define HAL_UART_Px_RX_TX          0xC0         // Peripheral I/O Select for Rx/Tx.

改为

#define HAL_UART_Px_RX_TX          0x30         // Peripheral I/O Select for Rx/Tx.

————————————————————————————————————

HalUARTInitISR函数中的#if (HAL_UART_ISR == 1) 改为 #if (HAL_UART_ISR == 2)

赞(0)
未经允许不得转载:TI中文支持网 » CC2530用z-stack怎么使用双串口
分享到: 更多 (0)