串口
直接上代码吧
void USART_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE); //开启串口时钟
//设置usart2 tx引脚工作模式PA2
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//设置usart2 rx引脚工作模式PA3
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //浮空输入
GPIO_Init(GPIOA, &GPIO_InitStructure);
//usart2 工作模式配置
USART_InitStructure.USART_BaudRate = 19200; //波特率
USART_InitStructure

本文介绍了在蓝桥杯嵌入式学习中,关于串口(USART)和模拟数字转换器(ADC)的使用。重点讲解了如何配置GPIO为模拟输入模式,以及ADC_RegularChannelConfig函数的参数含义,强调了在多通道采集和DMA应用中的作用。
最低0.47元/天 解锁文章
1268

被折叠的 条评论
为什么被折叠?



