华工单片机IO口流水灯实验1报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

华南理工大学XXX课程实验报告实验题目:__________单片机I/O口--流水灯_______________班级:___09信安(5)__指导教师:________张齐_________实验概述【实验目的及要求】1.学习单片机各I/O口结构特点及相关寄存器的使用方法。2.掌握一个简单具体的单片机项目的开发流程。3.了解ProteusISIS软件及使用方法。4.熟悉ProteusISIS与μVision2IDE开发环境的互连调试。实验内容【实验方案设计】实验电路编程实现:1)从VD1~VD32逐次点亮每个LED,然后熄灭。每个Led亮灯时间约为200ms。2)点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。3)在全部灯亮的情况下,从VD1~VD32逐次熄灭LED,熄灭VD1,延时200ms;然后熄灭VD2,延时200ms……熄灭VD32,全部灯熄灭。4)重复上述过程。【实验过程】程序如下:#includeREG52.H#defineLED_PORT0P0#defineLED_PORT1P1#defineLED_PORT2P2#defineLED_PORT3P3voidtime(unsignedintucMs);voidmain(void){unsignedintucTimes;unsignedinttemp;#defineDELAY_TIME200while(1){LED_PORT0=0xff;LED_PORT1=0xff;LED_PORT2=0xff;LED_PORT3=0xff;time(DELAY_TIME);//从VD1~VD32逐次点亮每个LEDfor(ucTimes=0;ucTimes8;ucTimes++){LED_PORT0=LED_PORT0-(0x80ucTimes);time(DELAY_TIME);LED_PORT0=0xff;}for(ucTimes=0;ucTimes8;ucTimes++){LED_PORT1=LED_PORT1-(0x80ucTimes);time(DELAY_TIME);LED_PORT1=0xff;}for(ucTimes=0;ucTimes8;ucTimes++){LED_PORT2=LED_PORT2-(0x80ucTimes);time(DELAY_TIME);LED_PORT2=0xff;}for(ucTimes=0;ucTimes8;ucTimes++){LED_PORT3=LED_PORT3-(0x80ucTimes);time(DELAY_TIME);LED_PORT3=0xff;}//点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。temp=0xff;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp-(0x01ucTimes);LED_PORT3=temp;time(DELAY_TIME);}temp=0xff;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp-(0x01ucTimes);LED_PORT2=temp;time(DELAY_TIME);}temp=0xff;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp-(0x01ucTimes);LED_PORT1=temp;time(DELAY_TIME);}temp=0xff;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp-(0x01ucTimes);LED_PORT0=temp;time(DELAY_TIME);}//在全部灯亮的情况下,从VD1~VD32逐次熄灭LEDtemp=0x00;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp+(0x80ucTimes);LED_PORT0=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp+(0x80ucTimes);LED_PORT1=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp+(0x80ucTimes);LED_PORT2=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes8;ucTimes++){temp=temp+(0x80ucTimes);LED_PORT3=temp;time(DELAY_TIME);}}//重复上述过程}voidtime(unsignedintucMs){#defineDELAYTIMES239unsignedcharucCounter;while(ucMs!=0){for(ucCounter=0;ucCounterDELAYTIMES;ucCounter++){}ucMs--;}}调试步骤:1.从VD1~VD32逐次点亮每个LED,每点亮一个断点一次2.点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。,每点亮一个断点一次3.在全部灯亮的情况下,从VD1~VD32逐次熄灭LED,每熄灭一个断点一次指导教师评语及成绩评语:成绩:指导教师签名:批阅日期:

1 / 10
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功