我这有两个板子,使用485通讯,发送数据的板子不是我设计的,不能更改,但是这是使用中的,没有问题的。新的板子我使用stm32单片机,在测试中串口接收数据出现规律性错误,发送11接收DD,发送22接收BB,发送33接收99.以此类推,可以看出接收的数据,0变1,1变了0,并且全部左移了1位。我的串口设置是
USART_InitStructure.USART_BaudRate = 38400;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_Clock = USART_Clock_Disable;
USART_InitStructure.USART_CPOL = USART_CPOL_Low;//
USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;//
USART_InitStructure.USART_LastBit = USART_LastBit_Disable;//;
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);//接收中断
USART_Init(USART1, &USART_InitStructure);
不知道哪里设置不对,请指教
|