野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11052|回复: 2

求助:关于陀螺仪例程3想改成USART2失败

[复制链接]
发表于 2016-5-6 09:36:34 | 显示全部楼层 |阅读模式
我用陀螺仪例程3(上位机是匿名地面站),上位机里的飞机是能够随着板子的姿态变化的。
但是,我需要把例程中的USART1改成USART2,却不行了,症状是LED绿灯亮,但是液晶屏停在“MPU6050 detected!”,并不显示三轴坐标等信息,然后串口也不发送数据。
例程中bsp_debug_usart.h原本是这么写的:
  1. #define DEBUG_USART                             USART1
  2. #define DEBUG_USART_CLK                         RCC_APB2Periph_USART1
  3. #define DEBUG_USART_BAUDRATE                    115200

  4. #define DEBUG_USART_RX_GPIO_PORT                GPIOA
  5. #define DEBUG_USART_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
  6. #define DEBUG_USART_RX_PIN                      GPIO_Pin_10
  7. #define DEBUG_USART_RX_AF                       GPIO_AF_USART1
  8. #define DEBUG_USART_RX_SOURCE                   GPIO_PinSource10

  9. #define DEBUG_USART_TX_GPIO_PORT                GPIOA
  10. #define DEBUG_USART_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
  11. #define DEBUG_USART_TX_PIN                      GPIO_Pin_9
  12. #define DEBUG_USART_TX_AF                       GPIO_AF_USART1
  13. #define DEBUG_USART_TX_SOURCE                   GPIO_PinSource9
复制代码
我试了把PA3/PA2接到CH340的RX、TX,并改成以下代码,结果就不行,症状如上描述:
  1. #define DEBUG_USART                             USART2
  2. #define DEBUG_USART_CLK                         RCC_APB1Periph_USART2
  3. #define DEBUG_USART_BAUDRATE                    115200

  4. #define DEBUG_USART_RX_GPIO_PORT                GPIOA
  5. #define DEBUG_USART_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
  6. #define DEBUG_USART_RX_PIN                      GPIO_Pin_3
  7. #define DEBUG_USART_RX_AF                       GPIO_AF_USART2
  8. #define DEBUG_USART_RX_SOURCE                   GPIO_PinSource3

  9. #define DEBUG_USART_TX_GPIO_PORT                GPIOA
  10. #define DEBUG_USART_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOA
  11. #define DEBUG_USART_TX_PIN                      GPIO_Pin_2
  12. #define DEBUG_USART_TX_AF                       GPIO_AF_USART2
  13. #define DEBUG_USART_TX_SOURCE                   GPIO_PinSource2
复制代码
又试了把PD6/PD5接到CH340的RX、TX,并改成以下代码,结果也不行,症状如上描述:
  1. #define DEBUG_USART                             USART2
  2. #define DEBUG_USART_CLK                         RCC_APB1Periph_USART2
  3. #define DEBUG_USART_BAUDRATE                    115200

  4. #define DEBUG_USART_RX_GPIO_PORT                GPIOD
  5. #define DEBUG_USART_RX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
  6. #define DEBUG_USART_RX_PIN                      GPIO_Pin_6
  7. #define DEBUG_USART_RX_AF                       GPIO_AF_USART2
  8. #define DEBUG_USART_RX_SOURCE                   GPIO_PinSource6

  9. #define DEBUG_USART_TX_GPIO_PORT                GPIOD
  10. #define DEBUG_USART_TX_GPIO_CLK                 RCC_AHB1Periph_GPIOD
  11. #define DEBUG_USART_TX_PIN                      GPIO_Pin_5
  12. #define DEBUG_USART_TX_AF                       GPIO_AF_USART2
  13. #define DEBUG_USART_TX_SOURCE                   GPIO_PinSource5
复制代码
请问:陀螺仪例程3要改成其他的USART,还需要修改什么?
回复

使用道具 举报

发表于 2016-5-6 10:52:40 | 显示全部楼层
PA3/PA2接到CH340的RX、TX

反了,正确是:PA3/PA2接到CH340的TX/ RX
回复 支持 反对

使用道具 举报

 楼主| 发表于 2016-5-6 11:27:44 | 显示全部楼层
flyleaf 发表于 2016-5-6 10:52
PA3/PA2接到CH340的RX、TX

反了,正确是:PA3/PA2接到CH340的TX/ RX

两个引脚对换过来也试过,还是不行。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-10-2 16:29 , Processed in 0.035878 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表