[STM32F1] stm32串口接收数据有规律的错,求帮助

[复制链接]
1270|2
 楼主| andiwxz 发表于 2014-12-8 09:46 | 显示全部楼层 |阅读模式
我这有两个板子,使用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);


不知道哪里设置不对,请指教
mmuuss586 发表于 2014-12-8 12:21 | 显示全部楼层

拿示波器看看,是不是波特率不对;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

166

主题

258

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部