单片机的C语言程序设计.pdf
《单片机的C语言程序设计.pdf》由会员分享,可在线阅读,更多相关《单片机的C语言程序设计.pdf(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1/8 单片机的 C 语言程序设计一阶段序号姓名方廷宇学号30802089 专业班级电信 0802组号指导老师一实验目的学习掌握单片机的语言编程方法;2熟悉并掌握Protues仿真软件的按章,使用及调试方法;3熟悉 keil c 的编译环境使用及调试方法;4学习 protell 的画图二思考作业设计一个LED 灯 1 秒闪烁的程序,绘制电路图,用两种方法给出程序。#include“reg51.h”#define uchar unsigned char#define uint unsigned int Sbit P1_0=P10。Void m(unsigned int d unsigned in
2、t i=0。For(。d0。d-For(i=0。i。Void main(for(。P1_0=!P1_0。m(1000。#includereg51.h sbit P1_0=P10。2/8 void main(int a=0。P1=0 xff。TMOD=0 x01。TH0=(65536-20000/256。TL0=(65536-20000%256。TR0=1。for(。if(TF0=1 TF0=0。TH0=(65536-20000/256。TL0=(65536-20000%256。a+。if(a=25 P1_0=!P1_0。a=0。2用 C 语言设计流水灯的程序,绘制电路图,用两种方法给出程序#i
3、nclude”reg51.h”#include”strins.h”#define uchar unsigned char#define uint unsigned int Void m(unsigned int d unsigned int i=0。For(。d0。d-For(i=0。i。Void main(0 unsigned char o=0 xfe。For(。P1=o。o=_crol_(o,1。m(1000。文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y
4、8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L
5、2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9
6、A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU
7、8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY
8、4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2
9、W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:
10、CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V13/8#includereg51.h#define uchar unsigned char uchar m=0,i=0。sbit P3_0=P30。void main(P1=0 xff。TMOD=0 x01。TH0=(65536-50000/256。TL0=(65537-50000%256。TR0=1。EA=1。ET0=1。while(1。void timer(interrupt 1 TH0=(65536-50000/256。TL0=(655
11、37-50000%256。m+。if(m=20 m=0。P3=(0 x01。if(+i=8 i=0。3针对下图,用单片机语言编程实现时钟,并利用Protues 仿真演示。1 秒钟的定时使用定时器中断方式)1)硬件原理图文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8
12、K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V
13、1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2
14、G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1
15、D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F
16、6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8
17、Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V14/8 图 1 定时电路原理图2)软件流程图3
18、)程序清单 P2=0 x3f。P3=0 x3f。TMOD=0 x01。TH0=(65536-40000/256。TL0=(65536-40000%256。TR0=1。EA=1。ET0=1。for(。void timer(interrupt 1 文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G1
19、0P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8
20、K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V
21、1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2
22、G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1
23、D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F
24、6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V15/8 TH0=(6
25、5536-40000/256。TL0=(65536-40000%256。b+。if(b=25 b=0。P3=ai。i+。if(i=10 i=0。P2=aj。j+。if(j=6 P2=0 x3f。j=0。针对图2,用单片机语言编程按键按下,显示数据增加,并用Protues 仿真运行1)硬件原理图文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9 ZC2W9A3F6V1文档编码:CU8Y8Z2G10P1 HY4L2C1D8K9
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机 语言程序设计
限制150内