STM32f103
寄存器配置串口通信
主程序接收数据,上位机串口发送的数据已回车键结束,单片机接之后将所有数据发回。
#include "stm32f10x_lib.h"
#include "sys.h"
//#include "ioshezhi_jb.h"
unsigned char res;
//
串口接受数据临时存储
unsigned char enddd=0;
//
接受完成标志
unsigned int len=0;
//
数据长度
unsigned char shubiao[200];
//
数据存储表
,
限制长度为
200
字节
unsigned int t;
//
通信数据操作
for
循环控制
unsigned long i=0;
int main()
{
Stm32_Clock_Init();
//
系统时钟设置
//
io_init();
//io
时钟以及输入输出选项设置
RCC->APB2ENR|=0x4000;
//
开启
USART1
时钟;
○
1
RCC->APB2ENR|=0x0004;
//
<