基于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;
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
基于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;
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 ch
HalUARTRead (port, &UartDataBuf[Head++], 1);
}
}
/* 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_DMA 2 #else #define HAL_UART_DMA 1 #endif #else #define HAL_UART_DMA 0 #endif #endif #ifndef HAL_UART_ISR #if HAL_UART_DMA // Default preference for DMA over ISR. #define HAL_UART_ISR 0 #elif (defined ZAPP_P2) || (defined ZTOOL_P2) #define HAL_UART_ISR 2 #else #define HAL_UART_ISR 1 #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_PRIPO 0x00 #else #define HAL_UART_PRIPO 0x40 #endif #else #define HAL_UART_DMA 0 #define HAL_UART_ISR 0 #endif /* USB is not used for CC2530 configuration */ #define HAL_UART_USB 0 #endif