注意编译选项:
ZTOOL_P1
MT_TASK
HAL_UART=TRUE
SERIAL_APP_PORT=0
BUILD_ALL_DEVICES
1、使用ISR不使用DMA hal_board_cfg.h文件中
#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
改为
#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_ISR 1
#endif
#else
#define HAL_UART_DMA 0
#endif
#endif
1、修改优先级以及uart引脚设置 _hal_uart_isr.c文件
重要函数:
static void HalUARTInitISR(void)
{
// Set P2 priority - USART0 over USART1 if both are defined.
P2DIR &= ~P2DIR_PRIPO;
P2DIR |= HAL_UART_PRIPO;
#if (HAL_UART_ISR == 1)
PERCFG &= ~HAL_UART_PERCFG_BIT; // Set UART0 I/O location to P0.
#else
PERCFG |= HAL_UART_PERCFG_BIT; // Set UART1 I/O location to P1.
#endif
PxSEL |= HAL_UART_Px_RX_TX; // Enable Tx and Rx on P1.
ADCCFG &= ~HAL_UART_Px_RX_TX; // Make sure ADC doesnt use this.
UxCSR = CSR_MODE; // Mode is UART Mode.
UxUCR = UCR_FLUSH; // Flush it.
}
里面需要修改的参数
A)、HAL_UART_PRIPO 将0x00修改为0x40
B)、将PERCFG &= ~HAL_UART_PERCFG_BIT 的HAL_UART_PERCFG_BIT 值修改为0x02
C)、将 HAL_UART_Px_RX_TX的值修改为0x30
D)、将HAL_UART_Px_RTS 和HAL_UART_Px_CTS的值分别修改为0x80和0x40(这两个参数在宏定义中,不在这个函数中)
3、串口中断函数修改 _hal_uart_isr.c文件
串口发送和接收中断函数都按照以下修改:
#if (HAL_UART_ISR == 1)
HAL_ISR_FUNCTION( halUart0RxIsr, URX0_VECTOR )
#else
HAL_ISR_FUNCTION( halUart1RxIsr, URX1_VECTOR )
#endif
修改为
#if (HAL_UART_ISR == 1)
HAL_ISR_FUNCTION( halUart1RxIsr, URX1_VECTOR )
#else
HAL_ISR_FUNCTION( halUart1RxIsr, URX1_VECTOR )
#endif
3、设置流控选项 MT_UART.c文件
将MT_UartInit ()函数中参数MT_UART_DEFAULT_OVERFLOW修改为FALSE
4、寄存器修改_hal_uart_isr.c文件
#if (HAL_UART_ISR == 1)
#define PxOUT P0
#define PxDIR P0DIR
#define PxSEL P0SEL
#define UxCSR U0CSR
#define UxUCR U0UCR
#define UxDBUF U0DBUF
#define UxBAUD U0BAUD
#define UxGCR U0GCR
#define URXxIE URX0IE
#define URXxIF URX0IF
#define UTXxIE UTX0IE
#define UTXxIF UTX0IF
修改为
#define PxOUT P0
#define PxDIR P0DIR
#define PxSEL P0SEL
#define UxCSR U1CSR
#define UxUCR U1UCR
#define UxDBUF U1DBUF
#define UxBAUD U1BAUD
#define UxGCR U1GCR
#define URXxIE URX1IE
#define URXxIF URX1IF
#define UTXxIE UTX1IE
#define UTXxIF UTX1IF