采用485通讯,串口初始化如下,发送数据在串口调试助手中收不到数据,请问串口初始化哪里有问题? #define UART0_Rx_Pin 0x0100 #define UART0_Tx_Pin 0x0200 #define UART0_RE_DE_Pin 0x0040
UART_DeInit(UART0); /*Enable Clock for UART0*/ CFG_PeripheralClockConfig(CFG_CLK_UART0 , ENABLE); /*Enable Clock for GPIO6*/ CFG_PeripheralClockConfig(CFG_CLK_GPIO6 , ENABLE); /* CMU Initialization */
/*Configure CMU and switch to the external 4MHz Quartz*/ CMU_InitStruct.CMU_CKSEL0 = CMU_CKSEL0_CKOSC; CMU_Init (&CMU_InitStruct);
/* Configure the GPIO pins as alternate function push pull*/ GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP; GPIO6_InitStruct.GPIO_Pins = UART0_Tx_Pin ; GPIO_Init (GPIO6, &GPIO6_InitStruct); GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_IN_TRI_TTL; GPIO6_InitStruct.GPIO_Pins = UART0_Rx_Pin; GPIO_Init (GPIO6, &GPIO6_InitStruct);
GPIO6_InitStruct.GPIO_Mode = GPIO_Mode_OUT_PP; GPIO6_InitStruct.GPIO_Pins = UART0_RE_DE_Pin ; GPIO_Init (GPIO6, &GPIO6_InitStruct); /* UART Configuration */ UART_StructInit(&UART_InitStruct); /*Initialize Structure with default values*/ UART_InitStruct.UART_BaudRate = 9600; /* Baud rate value */ UART_InitStruct.UART_Mode = UART_Mode_8D; /*Set the UARTx Mode 8 bit Data + Parity */ UART_InitStruct.UART_Loop_Standard = UART_Standard; /*Disable LoopBack*/ UART_InitStruct.UART_StopBits = UART_StopBits_1; /* STOP bits number */ //UART_InitStruct.UART_Parity = UART_Parity_Even; /* Parity bit */ UART_InitStruct.UART_Rx = UART_Rx_Enable; UART_Cmd(UART0, ENABLE); UART_Init(UART0, &UART_InitStruct); /*Configure Uart0*/ // UART_FifoReset(UART0,UART_TxFIFO); //UART_FifoReset(UART0,UART_RxFIFO);
UART0_RE_DE_High(); //485发送使能 UART_ByteSend(UART0, 0xaa); //发送数据
|