stm32串口间通信实验

发布时间:2023-04-15 19:15:07

STM32串口间通信该工程主要实现了两块实验板之间的通信以及接收实验板和PC间的通信,通过发送实验板串口1发送数据,然后由接受实验板串口3接收数据后再又串口1发送出去通过PC查看实验效果。发送串口及子函数配置:#include"sys.h"#include"usart.h"//////////////////////////////////////////////////////////////////////////////////charUSART_TX_BUF[12]={"0123456789\r\n"};//发送缓冲voiduart_init(u32bound{//GPIO端口设置GPIO_InitTypeDefGPIO_InitStructure;USART_InitTypeDefUSART_InitStructure;
//NVIC_InitTypeDefNVIC_InitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE;//USART1_TXPA.9GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_Init(GPIOA,&GPIO_InitStructure;//USART1_RXPA.10GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;GPIO_Init(GPIOA,&GPIO_InitStructure;//Usart1NVIC配置//NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQn;

stm32串口间通信实验

相关推荐