打印
[应用相关]

STM32 RTS USART1使用注意事项 问题解决方法

[复制链接]
714|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
Luis德华|  楼主 | 2015-9-29 22:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
USART1的RTS引脚和CAN的TX引脚复用,需要使用AFIO重新映射。
具体操作可以看下面的英文解释。

USART1_RTS and CAN_TX
Conditions
● USART1 is clocked
● CAN is not clocked
● I/O port pin PA12 is configured as an alternate functionoutput.

Description
Even if CAN_TX is not used, this signal is set by default to 1 ifI/O port pin PA12 is
configured as an alternate function output.
In this case USART1_RTS cannot be used.
Workaround
When USART1_RTS is used, the CAN must be remapped to eitheranoth

When USART1_RTS is used, the CAN must be remapped to either anotherIO configuration
when the CAN is used, or to the unused configuration(CAN_REMAP[1:0] set to “01”) when
the CAN is not used.
//其他配置都和普通的一样,串口加上这句,添加流控
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;
  //复用
  AFIO->MAPR=(AFIO->MAPR|AFIO_MAPR_CAN_REMAP_0|AFIO_MAPR_CAN_REMAP_1)&AFIO_MAPR_CAN_REMAP_0;
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_12;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOA, &GPIO_InitStructure);


发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

40

主题

370

帖子

4

粉丝