当前位置:网站首页>51单片机学习笔记(1)
51单片机学习笔记(1)
2022-07-25 14:19:00 【这世界比瞳孔还漆黑】
程序编写环境——KEIL软件的安装
前提:准备好keil 4安装程序与相应注册机

- 打开C51V901.exe(Keil 4 安装程序)

* 点击Next

* 勾选 I agree all the terms of···
* 点击Next

* 设置安装路径,根据自己的情况选中安装目录,重新设置请点击Browse进行浏览与选取,建议安装路径不要包含中文,设置好安装路径后点击Next

* 输入相关信息,随便输入即可,输入完毕后点击Next

* 开始安装,等待安装结束

* 安装完成,点击Finish结束
激活keil 4
- 打开注册机软件KEIL_Lic.exe,界面如下

* 从桌面打开刚刚安装好的Keil 4软件的快捷方式进入keil 4(注意,要以管理员模式运行)

* 点击左上角File菜单选择Lincense Management,如下图所示


- 复制CID码到剪切板,切换至注册机

* 从注册机中获取注册码后,复制进License Management界面下方的New License ID Code中,并点击Add LIC,即可完成软件激活。
* 成功激活显示如下

* 至此软件已经安装完毕。接下来可以进行程序的学习与实践。
工程创建
- 打开安装好的编辑环境Keil,进入如下界面
!
* 点击上方Project栏目选择New uVision Project进入如下界面

* 选择工程存放路径后,输入工程名字(如template),点击保存,进入如下界面

* 选择Atmel 并在其子目录下选取AT89C51点击OK以及后续弹出窗口选择否,如下所示



* 点击左上角新建文件如下所示


* 点击保存按钮,选取刚刚新建工程路径,命名为led.c并保存

- 点击如下按钮,进入工程文件管理界面


* 点击Add Files,将刚刚建立的led.c加入该工程中,如下所示


* 添加成功后可在工程下查看

点亮第一个LED
- Keil 4是以C语言为代码编辑语言的编辑环境,故其语法以C为标准。编辑代码如下所示

#include "reg51.h" //亦可写成#include <reg51.h> 该行作用为引入51单片机库文件 sbit LED = P2^0; //定义单片机管脚(IO)P2^0为LED,该管脚与一个LED连接,并且该LED一段已经接入正极
void main() //定义主函数,程序从从此处进入
{
while (1) //定义while循环,条件为1,即while一直在循环
{
LED = 0; //设置P2^0管脚为低电平,形成回路,LED点亮
}
}- 点击编译按钮,查看代码是否出错

* 如果代码没问题,设置生成hex文件(写入单片机的文件格式),操作如下


* 设置完成后,重新编译一边代码如下所示

将代码写入单片机
- 前提 准备烧录软件,由单片机开发商提供,以下以普中科技单片机为例

至此,恭喜你,点亮了第一个LED,开启了自己的单片机人生
边栏推荐
- That day, I installed a database for my sister... Just help her sort out another shortcut
- Famous handwritten note taking software recruit CTO · coordinate Shenzhen
- Pytorch uses tensorboard to realize visual summary
- 关于左值和右值的一些问题总结[通俗易懂]
- Word set paste to retain only text
- AI model risk assessment Part 1: motivation
- Goldfish rhca memoirs: cl210 management storage -- object storage
- 新唐NUC980设置DHCP或者静态IP
- 苹果手机端同步不成功,退出登录,结果再也登录不了了
- Reverse Integer
猜你喜欢

Vs2017 large factory ERP management system source code factory general ERP source code

Working mode and sleep mode of nlm5 series wireless vibrating wire sensor acquisition instrument

Okaleido生态核心权益OKA,尽在聚变Mining模式

Why do China Construction and China Railway need this certificate? What is the reason?
![Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]](/img/22/17250eabf067b5b1b9b71e6e0ff14e.png)
Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]

为什么中建、中铁都需要这本证书?究竟是什么原因?

That day, I installed a database for my sister... Just help her sort out another shortcut

飞沃科技IPO过会:年营收11.3亿 湖南文旅与沅澧投资是股东

Doris learning notes integration with other systems

Multidimensional pivoting analysis of CDA level1 knowledge points summary
随机推荐
[cartographer_ros] VIII: Official demo parameter configuration and effect
基于PaddleOCR开发uni-app离线身份证识别插件
~4.2 CCF 2021-12-1 sequence query
Save the image with gaussdb (for redis), and the recommended business can easily reduce the cost by 60%
einsum(): operands do not broadcast with remapped shapes [original->remapped]: [1, 144, 20, 17]->[1,
Gateway 网关报错 SERVICE_UNAVAILABLE
Setting of parameter configuration tool for wireless vibrating wire collector
Doris学习笔记之与其他系统集成
Business analysis report and data visualization report of CDA level1 knowledge point summary
飞沃科技IPO过会:年营收11.3亿 湖南文旅与沅澧投资是股东
Structure size
MySQL and Navicat installation and stepping on pits
手把手教你申请SSL证书
Opencv video tracking "suggestions collection"
Write an esp32 Watchdog with Arduino
轻松入门自然语言处理系列 12 隐马尔可夫模型
[original] nine point calibration tool for robot head camera calibration
opencv视频跟踪「建议收藏」
RuntimeError: CUDA out of memory(已解决)[通俗易懂]
Apple failed to synchronize on its mobile terminal, and logged out. As a result, it could not log in again