串口通信
这是结构体
调用串口接收数据
USARTRS
串口
TTL 只能在厘米之内
RS232 电平【+-12v】传输距离较远
RS485/422 用的是差分【距离长】1.5km
串口初始化
什么是串口通信(一个结构体)--->面向对象
有三个部分;NVIC
开机的输出、推挽式输出
浮空输入pc11
PA9/10 数据1的发送/接收端
最基础就是GPIO
PA9:发送,tim1的ch3通道
PA10:接收,tim1的ch3通道
定义的3个结构体
PA9/10 数据1的发送/接收端
最基础就是GPIO
PA9:发送,tim1的ch3通道
PA10:接收,tim1的ch3通道
定义的3个结构体
定义了异步通信的结构体
typedef struct
{
uint32_t USART_BaudRate; /*!< This member configures the USART communication baud rate.
The baud rate is computed using the following formula:
- IntegerDivider = ((PCLKx) / (16 * (USART_InitStruct->USART_BaudRate)))
- FractionalDivider = ((IntegerDivider - ((u32) IntegerDivider)) * 16) + 0.5 */
uint16_t USART_WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
This parameter can be a value of @ref USART_Word_Length */
uint16_t USART_StopBits; /*!< Specifies the number of stop bits transmitted.
This parameter can be a value of @ref USART_Stop_Bits */
uint16_t USART_Parity; /*!< Specifies the parity mode.
This parameter can be a value of @ref USART_Parity
@note When parity is enabled, the computed parity is inserted
at the MSB position of the transmitted data (9th bit when
the word length is set to 9 data bits; 8th bit when the
word length is set to 8 data bits). */
uint16_t USART_Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
This parameter can be a value of @ref USART_Mode */
uint16_t USART_HardwareFlowControl; /*!< Specifies wether the hardware flow control mode is enabled
or disabled.
This parameter can be a value of @ref USART_Hardware_Flow_Control */
} USART_InitTypeDef;
注意:
USART1在APB2总线上
USART2、3在APB1总线上
这样搜索通断号-37
这些都是外设库的,可以去查找
在汇编里---->对应到37里
把DR(数据寄存器)读出来
Comments | NOTHING