51单片机蓝牙无线下载程序

在这里插入图片描述

蓝牙模块:HC05
波特率:9600
校验位:无
停止位:1

HC05与电脑的蓝牙配对后生成传入传出两个COM口,使用传出COM口

蓝牙与单片机接线:
5V–5V
GND–GND
TX–3.0
RX–3.1

第一次需要用常规方式将下方代码写入

main.c
#include <reg52.h>
#include “stc_isp_download.h”

sbit LED = P0^0;

void main()
{
Init_Iap_Download();
LED = 1;
while (1)
{
LED = 0;
}
}

stc_isp_download.c
#include “stc_isp_download.h”

void Init_Iap_Download()
{
TMOD=0X20;
SM0=0;
SM1=1;
REN=1;
TH1=0XFD;
TL1=0XFD; //波特率 9600
TR1=1; //校验位 无
EA=1; //停止位 1
ES=1;
}
void Rceive()interrupt 4
{
unsigned char i=0;
unsigned int j,k;

if(TI==1)
{
	TI=0;
}
else
{
	RI=0;
	i=SBUF;
	if(i==Download_command)
	{
		for(j=1000;j>0;j--)
		for(k=123;k>0;k--);
		Iap_Download =0x60;
	}
}

}

stc_isp_download.h
#ifndef stc_isp_download
#define stc_isp_download

#include <reg52.h>
#define Download_command 0xf1 //功能码
sfr Iap_Download=0xE7;//软复位地址
void Init_Iap_Download();

#endif

  • 6
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值