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.

串口接收问题



我用串口接收到的数据和用串口调试助手接收到的数据不一样,串口调试助手接收到的是正确的数据,串口调试助手的设置如下:波特率9600,数据位8,停止位1

我用示波器测过信号,空闲的时候是高电平,下面是我的程序,请大家帮我看看是哪儿出了问题

void  ConfigUART(void)
{
/* UART/SPI Peripheral configuration */

uint8 baud_exponent;
uint8 baud_mantissa;
CLKCONCMD&=~(1<<6);
while(CLKCONCMD&(1<<6));
CLKCONCMD&=~((1<<6)|(7<<0));

/* Set SPI on UART 0 alternative 2 */
PERCFG |= 0x02;

/* Configure clk, master out and master in lines */
HAL_CONFIG_IO_PERIPHERAL(HAL_GPS_TX_PORT, HAL_GPS_TX_PIN);
HAL_CONFIG_IO_PERIPHERAL(HAL_GPS_RX_PORT, HAL_GPS_RX_PIN);

P2DIR&=~(3<<6);//优先级设置
/* Set SPI speed to 1 MHz (the values assume system clk of 32MHz)
* Confirm on board that this results in 1MHz spi clk.
*/
baud_exponent = 8;
baud_mantissa = 59;
/* Configure SPI */
U1UCR = 0x80; /* Flush and goto IDLE state. 8-N-1. */
U1UCR = 0x02;
U1CSR |= 1<<7; /* UARTmode, */
U1GCR = HAL_SPI_TRANSFER_MSB_FIRST | baud_exponent;
U1BAUD = baud_mantissa;
UTX1IF=0;
U1CSR |= 1<<6;

URX1IE=1;
EA=1;
}