stm32快速学习4——串口发送字符
设定发送脚功能
串口设置,使能
#include"stm32f10x.h"
voidRCC_Configuration(void);
voidGPIO_Configuration(void);
voidUSART_Configuration(void);
unsignedcharstr[]="A";
intmain(void)
{
RCC_Configuration();
GPIO_Configuration();
USART_Configuration();
USART_SendData(USART1,str[0]);
while(1);
}
voidRCC_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 |RCC_APB2Periph_GPIOA,ENABLE);
}
voidGPIO_Configuration(void)
{
GPIO_InitTypeDefGPIO_InitStructure;
/*只设定了发送*/
GPIO_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);
}
voidUSART_Configuration(void)
{
USART_InitTypeDefUSART_InitStructure;
USART_InitStructure.USART_BaudRate=115200;
USART_InitStructure.USART_WordLength=USART_WordLength_8b;
USART_InitStructure.USART_StopBits=USART_StopBits_1;
USART_InitStructure.USART_Parity=USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode=USART_Mode_Tx;/*只设定了发送*/
USART_Init(USART1,&USART_InitStructure);
USART_Cmd(USART1,ENABLE);
}
stm32串口发送字 相关文章:
- Stm32串口发送字符串数据(11-09)
- Stm32串口发送字节数据(11-09)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)