[应用相关] STM32 RTS USART1使用注意事项 问题解决方法

[复制链接]
877|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.
  1. //其他配置都和普通的一样,串口加上这句,添加流控
  2.   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;
  3.   //复用
  4.   AFIO->MAPR=(AFIO->MAPR|AFIO_MAPR_CAN_REMAP_0|AFIO_MAPR_CAN_REMAP_1)&AFIO_MAPR_CAN_REMAP_0;
  5.   
  6.   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_12;
  7.   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  8.   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  9.   GPIO_Init(GPIOA, &GPIO_InitStructure);

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


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

本版积分规则

40

主题

370

帖子

4

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