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

CC2530 P0.4和P0.5工作异常

基于3.0.2协议栈例程,使用了2530的串口0(P0.2和P0.3)

P0.4和P0.5作为普通IO使用,当串口0使用的时候P0.4和P0.5作为IO工作就异常了,

流控制已经关了uartConfig.flowControl = FALSE;请问可能是什么原因?

  P0SEL &= ~BV(4);  P0SEL &= ~BV(5); 
  P0DIR |= BV(4);
  P0DIR |= BV(5);
  P0_4 = 0;
  P0_5 = 0;

YiKai Chen:

把uartConfig.intEnable也設置成FALSE看看

user5367314:

回复 YiKai Chen:

uartConfig.intEnable設置成FALSE还是一样的现象,
P0_5接的是LED,LED一直闪烁,当串口没数据的时候,P0_5是正常的

Susan Yang:

若是可以的话,请给出您的串口初始化代码

user5367314:

回复 Susan Yang:

void initUart0()
{halUARTCfg_t uartConfig;/* Initialize APP ID */App_TaskID = 0;uartConfig.configured = TRUE;uartConfig.baudRate = HAL_UART_BR_4800;//HAL_UART_BR_9600;uartConfig.flowControl = FALSE;uartConfig.flowControlThreshold = 256;uartConfig.rx.maxBufSize = 512;//默认128;uartConfig.tx.maxBufSize = 512;//默认128;uartConfig.idleTimeout = 6;uartConfig.intEnable = FALSE;uartConfig.callBackFunc = uartRxCb;HalUARTOpen (HAL_UART_PORT_0, &uartConfig);
}
void uartRxCb( uint8 port, uint8 event )
{while (Hal_UART_RxBufLen(port)){// Read one byte from UART to chHalUARTRead (port, &UartDataBuf[Head++], 1);}
}

Susan Yang:

回复 user5367314:

那HAL_UART /HAL_UART_ISR以及 HAL_UART_DMA您是如何设置的呢?

user5367314:

回复 Susan Yang:

/* Set to TRUE enable UART usage, FALSE disable it */
#ifndef HAL_UART
#if (defined ZAPP_P1) || (defined ZAPP_P2) || (defined ZTOOL_P1) || (defined ZTOOL_P2)
#define HAL_UART TRUE
#else
#define HAL_UART FALSE
#endif
#endif#if HAL_UART
#ifndef HAL_UART_DMA
#if HAL_DMA
#if (defined ZAPP_P2) || (defined ZTOOL_P2)
#define HAL_UART_DMA2
#else
#define HAL_UART_DMA1
#endif
#else
#define HAL_UART_DMA0
#endif
#endif#ifndef HAL_UART_ISR
#if HAL_UART_DMA// Default preference for DMA over ISR.
#define HAL_UART_ISR0
#elif (defined ZAPP_P2) || (defined ZTOOL_P2)
#define HAL_UART_ISR2
#else
#define HAL_UART_ISR1
#endif
#endif#if (HAL_UART_DMA && (HAL_UART_DMA == HAL_UART_ISR))
#error HAL_UART_DMA & HAL_UART_ISR must be different.
#endif// Used to set P2 priority - USART0 over USART1 if both are defined.
#if ((HAL_UART_DMA == 1) || (HAL_UART_ISR == 1))
#define HAL_UART_PRIPO0x00
#else
#define HAL_UART_PRIPO0x40
#endif#else
#define HAL_UART_DMA0
#define HAL_UART_ISR0
#endif/* USB is not used for CC2530 configuration */
#define HAL_UART_USB0
#endif

赞(0)
未经允许不得转载:TI中文支持网 » CC2530 P0.4和P0.5工作异常
分享到: 更多 (0)