完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
代码是这个 #include #define uchar unsigned char #define uint unsigned int uchar receive[5]; uchar address=5; uchar i,j;uint ii;uchar ij=0; uchar effect_flag=0;//有效数据标志 ***it P31=P3^1;***it P32=P3^2;***it P33=P3^3;***it P34=P3^4;***it P35=P3^5;***it P37=P3^7; uchar code DSY_CODE[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x77,0x40}; // 所需的数码管编码 void delay(uint x) { for(i=x;i>0;i--) for(j=115;j>0;j--); } void main() { P31=0; //读取地址 delay(6000); address=P1; P31=1; SCON=0x50; //串口方式1,允许接受 TMOD=0x20; //T1工作于方式2 PCON=0x00; //波特率不倍增 TH1=TL1=0xfd; ES=1; //允许串口中断 TR1=1; //启动定时器1 receive[0]=11; //地址处理,准备显示 receive[1]=12; receive[2]=address/100; receive[3]=address/10%10; receive[4]=address%10; for(ii=0;ii<500;ii++) //显示地址 { P37=0;P35=1;P34=1;P33=1;P32=1;P1=DSY_CODE[receive[0]];delay(3); P37=1;P35=0;P34=1;P33=1;P32=1;P1=DSY_CODE[receive[1]];delay(3); P37=1;P35=1;P34=0;P33=1;P32=1;P1=DSY_CODE[receive[2]];delay(3); P37=1;P35=1;P34=1;P33=0;P32=1;P1=DSY_CODE[receive[3]];delay(3); P37=1;P35=1;P34=1;P33=1;P32=0;P1=DSY_CODE[receive[4]];delay(3); } for(i=0;i<5;i++){receive=0;}//清除地址 EA=1; //开总中断 RI=0; while(1) { P37=0;P35=1;P34=1;P33=1;P32=1;P1=DSY_CODE[receive[0]];delay(3); P37=1;P35=0;P34=1;P33=1;P32=1;P1=DSY_CODE[receive[1]];delay(3); P37=1;P35=1;P34=0;P33=1;P32=1;P1=DSY_CODE[receive[2]];delay(3); P37=1;P35=1;P34=1;P33=0;P32=1;P1=DSY_CODE[receive[3]];delay(3); P37=1;P35=1;P34=1;P33=1;P32=0;P1=DSY_CODE[receive[4]];delay(3); } } //----------------------------------------------------------------------- //串口接受中断函数 //----------------------------------------------------------------------- void Serial_INT() interrupt 4 { if(RI==0) return; ES=0; //关闭串口中断 if(effect_flag==1) { receive[ij]=SBUF; //读取字符 ij++;if(ij==5){ij=0;effect_flag=0;} } if(SBUF==address)effect_flag=1;//有效数据标志置位 RI=0; ES=1; //开串口中断 } 仿真图 |
|
相关推荐
1个回答
|
|
数码管亮吗
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1786 浏览 0 评论
【每周推荐】采用11代Intel CPU,基于youyeetoo X1开发板搭建少儿AI智能STEAM积木平台
982 浏览 0 评论
3094 浏览 2 评论
【youyeetoo X1 windows 开发板体验】+ 影音处理和AI模型移植
2733 浏览 5 评论
I.MX6ULL-飞凌 ElfBoard ELF1板卡- 移植zbar的方法
1831 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
6522 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-5-11 07:05 , Processed in 0.591992 second(s), Total 75, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号