基于51单片机的频率计设计-c语言程序PDF.pdf

上传人:荣*** 文档编号:5958521 上传时间:2022-01-26 格式:PDF 页数:19 大小:13.87KB
返回 下载 相关 举报
基于51单片机的频率计设计-c语言程序PDF.pdf_第1页
第1页 / 共19页
基于51单片机的频率计设计-c语言程序PDF.pdf_第2页
第2页 / 共19页
点击查看更多>>
资源描述

《基于51单片机的频率计设计-c语言程序PDF.pdf》由会员分享,可在线阅读,更多相关《基于51单片机的频率计设计-c语言程序PDF.pdf(19页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、基于 51 单片机的频率计设计,c 语言程序代码 1:#include #define uint unsigned int #define uchar unsigned char #define ulong unsigned long sbit dula=P26; sbit wela=P27; sbit key1=P10; sbit key2=P11; sbit key3=P12; uchar tt=0,mode; ulong num,num1; uchar code shu=0 x3f,0 x06,0 x5b,0 x4f, 0 x66,0 x6d,0 x7d,0 x07,0 x7f,0 x6

2、f,0 x77, 0 x7c,0 x39,0 x5e,0 x79,0 x71; void delay(uint z) uint i,j; for(i=z;i0;i-) for(j=110;j0;j-); void display(uchar a,uchar b,uchar c,uchar d,uchar e,uchar f) dula=1; P0=shua; dula=0; P0=0 xff; wela=1; P0=0 xfe; wela=0; delay(3); dula=1; P0=shub; dula=0; P0=0 xff; wela=1; P0=0 xfd; wela=0; dela

3、y(3); dula=1; P0=shuc; dula=0; P0=0 xff; wela=1; P0=0 xfb; wela=0; delay(3); dula=1; P0=shud; dula=0; P0=0 xff; wela=1; P0=0 xf7; wela=0; delay(3); dula=1; P0=shue; dula=0; P0=0 xff; wela=1; P0=0 xef; wela=0; delay(3); dula=1; P0=shuf; dula=0; P0=0 xff; wela=1; P0=0 xdf; wela=0; delay(3); ulong read

4、() uchar t1,th1,th2; uint val; while(1) th1=TH1; t1=TL1; th2=TH1; if(th1=th2) break; val=th1*256+t1; return val; void keyscan() if(key1=0) mode=1; TMOD=0X90; TH1=0; TL1=0; ET1=1; TR1=1; EX1=1; EA=1; IT1=1; ET0=0; if(key2=0) mode=2; TMOD=0X51; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=0; TL1=

5、0; ET0=1; ET1=1; TR1=1; TR0=1; EX1=0; EA=1; if(key3=0) mode=3; TMOD=0X51; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=0; TL1=0; ET0=1; ET1=1; TR1=1; TR0=1; EX1=0; EA=1; void main() uint aa,bb,cc,dd,ee,ff; while(1) keyscan(); if(mode = 1) aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/1

6、00%10; ee=num/10%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); if(mode =2) num=num1*2; aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/100%10; ee=num/10%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); if(mode=3) num=500000/num1; aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/100%10; ee=num/10

7、%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); void T0_time() interrupt 1 TH0=(65536-50000)/256; TL0=(65536-50000)%256; tt+; if(tt=10) tt=0; num1=read(); TH1=0; TL1=0; void exter() interrupt 2 num=read()+1; TH1=0; TL1=0; 代码 2:#include #define uint unsigned int #define uchar unsigned char #define ulong

8、unsigned long sbit dula=P26; sbit wela=P27; sbit key1=P10; sbit key2=P11; sbit key3=P12; uchar tt=0,mode; ulong num,num1; uchar code shu=0 x3f,0 x06,0 x5b,0 x4f, 0 x66,0 x6d,0 x7d,0 x07,0 x7f,0 x6f,0 x77, 0 x7c,0 x39,0 x5e,0 x79,0 x71; void delay(uint z) uint i,j; for(i=z;i0;i-) for(j=110;j0;j-); vo

9、id display(uchar a,uchar b,uchar c,uchar d,uchar e,uchar f) dula=1; P0=shua; dula=0; P0=0 xff; wela=1; P0=0 xfe; wela=0; delay(3); dula=1; P0=shub; dula=0; P0=0 xff; wela=1; P0=0 xfd; wela=0; delay(3); dula=1; P0=shuc; dula=0; P0=0 xff; wela=1; P0=0 xfb; wela=0; delay(3); dula=1; P0=shud; dula=0; P0

10、=0 xff; wela=1; P0=0 xf7; wela=0; delay(3); dula=1; P0=shue; dula=0; P0=0 xff; wela=1; P0=0 xef; wela=0; delay(3); dula=1; P0=shuf; dula=0; P0=0 xff; wela=1; P0=0 xdf; wela=0; delay(3); ulong read() uchar t1,th1,th2; uint val; while(1) th1=TH1; t1=TL1; th2=TH1; if(th1=th2) break; val=th1*256+t1; ret

11、urn val; void keyscan() if(key1=0) mode=1; TMOD=0X90; TH1=0; TL1=0; ET1=1; TR1=1; EX1=1; EA=1; IT1=1; ET0=0; if(key2=0) mode=2; TMOD=0X51; TH0=(65536-50000)/256; TL0=(65536-50000)%256; TH1=0; TL1=0; ET0=1; ET1=1; TR1=1; TR0=1; EX1=0; EA=1; if(key3=0) mode=3; TMOD=0X51; TH0=(65536-50000)/256; TL0=(65

12、536-50000)%256; TH1=0; TL1=0; ET0=1; ET1=1; TR1=1; TR0=1; EX1=0; EA=1; void main() uint aa,bb,cc,dd,ee,ff; while(1) keyscan(); P1=0 xff; if(mode = 1) key1=0; aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/100%10; ee=num/10%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); if(mode =2) key2=0; num=nu

13、m1*2+3; aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/100%10; ee=num/10%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); if(mode=3) key3=0; num=500000/num1; aa=num/100000; bb=num/10000%10; cc=num/1000%10; dd=num/100%10; ee=num/10%10; ff=num%10; display(aa,bb,cc,dd,ee,ff); void T0_time() interrupt 1 TH0=(65536-50000)/256; TL0=(65536-50000)%256; tt+; if(tt=10) tt=0; num1=read(); TH1=0; TL1=0; void exter() interrupt 2 num=read()+1; TH1=0; TL1=0;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 施工组织

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁