下面我们进行几个串口通信的实际应用。

实验一:发信实验,让开发板通过串口向电脑发送信息:

#include <stdio.h>
#include <stm32f10x.h>
#include <led.h>
#include <button.h>
#include <systick.h>
#include <time.h>
#include <usart.h>
int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
led_configer();
button_configer();
usart_configer();
while()
{
USART1_SData(0x66);
}
}
//main.c

实验二:电脑向串口发送0x55时,开灯,电脑向串口发送0x66时,关灯。

#include <stdio.h>
#include <stm32f10x.h>
#include <led.h>
#include <button.h>
#include <systick.h>
#include <time.h>
#include <usart.h>
int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
led_configer();
button_configer();
usart_configer();
while()
{
if(RXData==0x55)
lightup(GPIO_Pin_1);
else if(RXData==0x66)
shutdown(GPIO_Pin_1);
}
}
//main.c

最新文章

  1. ASP.NET 在 Windows Azure 环境中使用基于 SQLServer 的 Session
  2. asp.net mvc 4 json大数据异常 提示JSON字符长度超出限制的异常
  3. JDBC基础一
  4. linux服务器git pull/push时提示输入账号密码之免除设置
  5. 使用PHP生成二维码的两种方法(带logo图像)
  6. java反射获取注解并拼接sql语句
  7. 使用canvas实现绚丽的时钟特效
  8. 全栈开发之HTML快速入门(一)
  9. python_继承supper错误
  10. 关于IOS开发的基本书籍推荐
  11. BZOJ.5467.[PKUWC2018]Slay the Spire(DP)
  12. CTSC2018 被屠记
  13. Lyrics来源
  14. 【C++】解析C++运行环境的搭建
  15. FPN-Feature Pyramid Networks for Object Detection
  16. oracle No more data to read from socket之ora-07445排查解决
  17. 20155201 网络攻防技术 实验八 Web基础
  18. iOS基础知识之排序
  19. es进行curl请求时报错:missing authentication token for REST request
  20. 关于map和hashmap

热门文章

  1. AndroidManifest.xml配置文件详解(转)
  2. CDQ分治&amp;整体二分学习个人小结
  3. 用 Flask 来写个轻博客 (13) — M(V)C_WTForms 服务端表单检验
  4. PHP面试 MySQL创建高性能索引考点
  5. Device Drivers
  6. PAT_A1131#Subway Map
  7. 关于原生js中ie的attacheEvent事件用匿名函数改变this指向后,不能用detachEvent删除绑定事件的解决办法?
  8. Python运维-获取当前操作系统的各种信息
  9. 初探Remoting双向通信(二)
  10. java爬取猫咪上的图片