《华工单片机IO口流水灯实验1报告(共10页).doc》由会员分享,可在线阅读,更多相关《华工单片机IO口流水灯实验1报告(共10页).doc(10页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上华南理工大学XXX课程实验报告实验题目:_单片机I/O口流水灯_ 班级: _09信安(5)_ 指导教师: _张齐_ 实验概述【实验目的及要求】1.学习单片机各I/O口结构特点及相关寄存器的使用方法。2.掌握一个简单具体的单片机项目的开发流程。3.了解Proteus ISIS软件及使用方法。4.熟悉Proteus ISIS与 Vision2 IDE开发环境的互连调试。实验内容【实验方案设计】实验电路编程实现:1) 从VD1VD32 逐次点亮每个LED,然后熄灭。每个Led 亮灯时间约为200ms。2) 点亮VD32,200ms后再点亮VD31最后点亮VD1,直到全部灯被
2、点亮。3) 在全部灯亮的情况下,从VD1VD32逐次熄灭LED,熄灭VD1,延时200ms;然后熄灭VD2,延时200ms熄灭VD32,全部灯熄灭。4) 重复上述过程。【实验过程】程序如下:#include #define LED_PORT0 P0#define LED_PORT1 P1#define LED_PORT2 P2#define LED_PORT3 P3void time(unsigned int ucMs);void main(void)unsigned int ucTimes;unsigned int temp;#define DELAY_TIME 200 while(1) L
3、ED_PORT0=0xff;LED_PORT1=0xff;LED_PORT2=0xff;LED_PORT3=0xff;time(DELAY_TIME);/从VD1VD32 逐次点亮每个LEDfor(ucTimes=0;ucTimesucTimes);time(DELAY_TIME);LED_PORT0=0xff;for(ucTimes=0;ucTimesucTimes);time(DELAY_TIME);LED_PORT1=0xff;for(ucTimes=0;ucTimesucTimes);time(DELAY_TIME);LED_PORT2=0xff;for(ucTimes=0;ucTim
4、esucTimes);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
5、;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);/在全部灯亮的情况下,从VD1VD32逐次熄灭LEDtemp=0x00;for(ucTimes=0;ucTimesucTimes);LED_PORT0 = temp;time(DELAY_TIME)
6、;temp=0x00;for(ucTimes=0;ucTimesucTimes);LED_PORT1 = temp;time(DELAY_TIME);temp=0x00;for(ucTimes=0;ucTimesucTimes);LED_PORT2 = temp;time(DELAY_TIME);temp=0x00;for(ucTimes=0;ucTimesucTimes);LED_PORT3 = temp;time(DELAY_TIME);/重复上述过程void time(unsigned int ucMs)#define DELAYTIMES 239unsigned char ucCounter;while(ucMs!=0) for(ucCounter=0;ucCounterDELAYTIMES;ucCounter+)ucMs-;调试步骤:1.从VD1VD32 逐次点亮每个LED,每点亮一个断点一次2.点亮VD32,200ms后再点亮VD31最后点亮VD1,直到全部灯被点亮。,每点亮一个断点一次3.在全部灯亮的情况下,从VD1VD32逐次熄灭LED,每熄灭一个断点一次指导教师评语及成绩评语:成绩: 指导教师签名: 批阅日期:专心-专注-专业