你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

求帮忙分析问题可能出现在哪里?

[复制链接]
AnswerRaul 提问时间:2015-3-23 13:19 /
我使用的是STM32F427VG,现在做的部分是PC机通过串口配置3个传感器。
大致流程是这样的,PC机与板子通过UART4通信,然后将收到的数据转发给指定串口,取配置传感器。使用了UART4,USART1,USART3,USART6。UART4能够正常的向每个串口发送数据,但是USART3和USART6没有收到反馈,USART1能收到反馈。
单步调试,得到发现反馈数据进入了USART_SendData函数,但是数据没有输出来。
简化,只进行UART4与USART3之间相互透传,UART4收到数据可以通过USART3传出,而USART3收到的数据透传进入USART_SendData,但是收不到数据。USART6与USART3之间透传没问题,USART1与UART4之间透传没问题。
找到的可能线索,USART3与USART6在同一个max3223上,UART4与USART1在同一个max3223上。

串口配置代码:
  1. void UART_Configuration(void)
  2. {
  3.         USART_InitTypeDef USART_InitStructure;

  4.   /* USART resources configuration (Clock, GPIO pins and USART registers) ----*/
  5.   /* USART configured as follow:
  6.         - BaudRate = 115200 baud
  7.         - Word Length = 8 Bits
  8.         - One Stop Bit
  9.         - No parity
  10.         - Hardware flow control disabled (RTS and CTS signals)
  11.         - Receive and transmit enabled
  12.   */
  13.        
  14.         /*USART1 Configure*/
  15.         USART_DeInit(USART1);
  16.   USART_InitStructure.USART_BaudRate = 115200;
  17.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  18.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  19.   USART_InitStructure.USART_Parity = USART_Parity_No;
  20.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  21.   USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

  22.   /* USART configuration */
  23.   USART_Init(USART1, &USART_InitStructure);
  24.         USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);

  25.   /* Enable the USART1 */
  26.   USART_Cmd(USART1, ENABLE);
  27.        
  28.        
  29.         /*USART3 Configure*/
  30.         USART_DeInit(USART3);
  31.   USART_InitStructure.USART_BaudRate = 115200;
  32.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  33.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  34.   USART_InitStructure.USART_Parity = USART_Parity_No;
  35.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  36.   USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

  37.   /* USART configuration */
  38.   USART_Init(USART3, &USART_InitStructure);
  39.         USART_ITConfig(USART3,USART_IT_RXNE,ENABLE);

  40.   /* Enable the USART3 */
  41.   USART_Cmd(USART3, ENABLE);
  42.        
  43.         /*USART6 Configure*/
  44.         USART_DeInit(USART6);
  45.   USART_InitStructure.USART_BaudRate = 115200;
  46.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  47.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  48.   USART_InitStructure.USART_Parity = USART_Parity_No;
  49.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  50.   USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

  51.   /* USART configuration */
  52.   USART_Init(USART6, &USART_InitStructure);
  53.         USART_ITConfig(USART6,USART_IT_RXNE,ENABLE);

  54.   /* Enable the USART6 */
  55.   USART_Cmd(USART6, ENABLE);
  56.        
  57.         /*UART4 Configure*/
  58.         USART_DeInit(UART4);
  59.   USART_InitStructure.USART_BaudRate = 115200;
  60.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  61.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  62.   USART_InitStructure.USART_Parity = USART_Parity_No;
  63.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  64.   USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
  65.        
  66.         /* UART configuration */
  67.         USART_Init(UART4,&USART_InitStructure);
  68.         USART_ITConfig(UART4,USART_IT_RXNE,ENABLE);
  69.        
  70.   /* Enable the UART4 */
  71.         USART_Cmd(UART4, ENABLE);
  72.        
  73.         /*UART7 Configure*/
  74.         USART_DeInit(UART7);
  75.   USART_InitStructure.USART_BaudRate = 115200;
  76.   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  77.   USART_InitStructure.USART_StopBits = USART_StopBits_1;
  78.   USART_InitStructure.USART_Parity = USART_Parity_No;
  79.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  80.   USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
  81.        
  82.         /* UART configuration */
  83.         USART_Init(UART7,&USART_InitStructure);
  84.         USART_ITConfig(UART7,USART_IT_RXNE,ENABLE);
  85.        
  86.         /* Enable the UART7 */
  87.         USART_Cmd(UART7, ENABLE);
  88. }
复制代码


中断处理代码(设置标志位,然后再在while循环里处理)

  1. void USART1_IRQHandler(void)                //´®¿ÚÖжϴ¦Àíº¯Êý
  2. {
  3.         if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
  4.         {
  5.                 Buf1 = USART_ReceiveData(USART1);

  6.                 USART_ClearITPendingBit(USART1, USART_IT_RXNE);       
  7.                 Flag=1;
  8.         }
  9. }

  10. void USART3_IRQHandler(void)
  11. {
  12.         Buf3 = USART_ReceiveData(USART3);
  13.        
  14.         USART_ClearITPendingBit(USART3, USART_IT_RXNE);
  15.         Flag=1;
  16. }

  17. void UART4_IRQHandler(void)
  18. {
  19.         Buf4 = USART_ReceiveData(UART4);
  20.        
  21.         USART_ClearITPendingBit(UART4, USART_IT_RXNE);
  22. Flag=1;
  23. }

  24. void USART6_IRQHandler(void)
  25. {
  26.         Buf6= USART_ReceiveData(USART6);
  27.        
  28.         USART_ClearITPendingBit(USART6, USART_IT_RXNE);
  29.         Flag=1;
  30. }
复制代码


<
收藏 评论11 发布时间:2015-3-23 13:19

举报

11个回答
飞翔的起点 回答时间:2015-3-23 13:42:48
你是想将PC发给USART1的数据转发到其它的USART?1,你直接在USART1的接收中断里,将接收到的字符直接发送到对应的串口就是了。
回答时间:2015-3-23 14:20:12
测试一下波形,看看是否能够输出数据。
AnswerRaul 回答时间:2015-3-23 15:14:28
飞翔的起点 发表于 2015-3-23 13:42
你是想将PC发给USART1的数据转发到其它的USART?1,你直接在USART1的接收中断里,将接收到的字符直接发送到对 ...

我开始就是这么做的,可是能发不过去,我才试这种的
AnswerRaul 回答时间:2015-3-23 15:15:28
安 发表于 2015-3-23 14:20
测试一下波形,看看是否能够输出数据。

找到原因的,是max3223芯片的forceon脚的问题。
stary666 回答时间:2015-3-23 15:37:46
支持一下!
earnest 回答时间:2015-3-23 16:05:45
stm32F103的飘过!
左岸右岸 回答时间:2015-3-23 18:36:46
没用过F4
小蚂蚁快溜跑 回答时间:2015-3-23 20:39:40
跟着学习。。。。
zfz0122 回答时间:2015-3-24 00:07:59
跟着学习 14.gif
12下一页

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版