欢迎来到天天文库
浏览记录
ID:57274516
大小:727.00 KB
页数:10页
时间:2020-08-08
《华工单片机IO口流水灯实验1报告.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、华南理工大学XXX课程实验报告实验题目:__________单片机I/O口--流水灯_______________班级:___09信安(5)__指导教师:________张齐_________实验概述【实验目的及要求】1.学习单片机各I/O口结构特点及相关寄存器的使用方法。2.掌握一个简单具体的单片机项目的开发流程。3.了解ProteusISIS软件及使用方法。4.熟悉ProteusISIS与μVision2IDE开发环境的互连调试。实验内容【实验方案设计】实验电路编程实现:1)从VD1~VD32逐次
2、点亮每个LED,然后熄灭。每个Led亮灯时间约为200ms。2)点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。3)在全部灯亮的情况下,从VD1~VD32逐次熄灭LED,熄灭VD1,延时200ms;然后熄灭VD2,延时200ms……熄灭VD32,全部灯熄灭。4)重复上述过程。 【实验过程】程序如下:#include#defineLED_PORT0P0#defineLED_PORT1P1#defineLED_PORT2P2#defineLED_PORT3P
3、3voidtime(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;ucTimes<8;ucTimes++){LED_PORT0=LED_P
4、ORT0-(0x80>>ucTimes);time(DELAY_TIME);LED_PORT0=0xff;}for(ucTimes=0;ucTimes<8;ucTimes++){LED_PORT1=LED_PORT1-(0x80>>ucTimes);time(DELAY_TIME);LED_PORT1=0xff;}for(ucTimes=0;ucTimes<8;ucTimes++){LED_PORT2=LED_PORT2-(0x80>>ucTimes);time(DELAY_TIME);LED_POR
5、T2=0xff;}for(ucTimes=0;ucTimes<8;ucTimes++){LED_PORT3=LED_PORT3-(0x80>>ucTimes);time(DELAY_TIME);LED_PORT3=0xff;}//点亮VD32,200ms后再点亮VD31……最后点亮VD1,直到全部灯被点亮。temp=0xff;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp-(0x01<6、ME);}temp=0xff;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp-(0x01<7、s++){temp=temp-(0x01<>ucTimes);LED_PORT0=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(08、x80>>ucTimes);LED_PORT1=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_PORT2=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_POR
6、ME);}temp=0xff;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp-(0x01<7、s++){temp=temp-(0x01<>ucTimes);LED_PORT0=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(08、x80>>ucTimes);LED_PORT1=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_PORT2=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_POR
7、s++){temp=temp-(0x01<>ucTimes);LED_PORT0=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0
8、x80>>ucTimes);LED_PORT1=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_PORT2=temp;time(DELAY_TIME);}temp=0x00;for(ucTimes=0;ucTimes<8;ucTimes++){temp=temp+(0x80>>ucTimes);LED_POR
此文档下载收益归作者所有