完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include
#include #define uint unsigned int #define uchar unsigned char uchar table[6]="00.00V"; uchar num, temp; uint voltage; ***it ad_clk=P3^3; ***it ad_out=P3^4; ***it ad_cs=P3^5; ***it lcden=P2^4; ***it lcdrs=P2^5; void delayms(uint xms); void write_com(uchar com); void write_data(uchar date); void led_init(); void tlc549_ad(); void main () { led_init (); tlc549_ad (); } void led_init () { lcden=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); } void tlc549_ad () { ad_cs=1; ad_clk=0; ad_cs=0; _nop_ (); _nop_(); for(num=0;num<8;num++) { temp<<=1; temp|=ad_out; ad_clk=1; _nop_ (); ad_clk=0; } ad_cs=1; for(num=17;num>0;num--) _nop_ (); voltage=(uint)(5.0/256*temp*400); temp=0; table[0]=voltage/1000+48; table [1] =voltage%1000/100+48; table[3]=voltage%1000%100/10+48; table [4] =voltage%1000%100%10+48; write_com(0x80); for(num=0;num<6;num++) { write_data (table [num]); delayms (5); } delayms(2000); } void delayms (uint xms) { uint i, j; for (i=xms; i>0; i--) for (j=110; j>0; j--); } void write_com (uchar com) { lcdrs=0; P0=com; delayms (5); lcden=1; delayms (5); lcden=0; } void write_data (uchar date) { lcdrs=1; P0=date; delayms (5); lcden=1; delayms (5); lcden=0; } #include #define uint unsigned int #define uchar unsigned char #define ulong unsigned long #define PI 3.1415926 uchar code table1 [8] ="Welcome!"; uchar table2 [16] ="f (Hz) ="; uchar table3 [16] ="R (Ohm) ="; uchar table4 [16] ="C (pF) ="; uchar table5 [16] ="L (uH) ="; uchar num, a=0, th0, tl0; uint C, L; ulong f, R; ***it Lcden=P2^4; ***it Lcdrs=P2^5; ***it key_R=P1^5; ***it key_C=P1^6; ***it key_L=P1^7; ***it R_out=P1^2; ***it C_out=P1^3; ***it L_out=P1^4; void delayms1(uint xms); void write_com1(uchar com); void write_data1(uchar date); void led_init1(); void t_init1(); void keyscan1(); void display_f1(ulong f); void display_R1(ulong R); void display_C1(uint C); void display_L1(uint L); void main () { led_init1 (); t_init1 (); keyscan1 (); write_com (0x01); while (1) { display_f1 (f); switch (a) { case 1: R= (ulong) (5000000.0/0.6931472/f-150+0.5); display_R1(R); break; case 2: C= (int) (100000000.0/153/0.6931472/f+0.5); display_C1(C); break; case 3: L= (int) (1000000000000.0/0.1/PI/PI/f/f+0.5); display_L1 (L); break; } } } void T0_count () interrupt 1 { switch (a) { case 1: while (R_out); while (! R_out); TH0=0; TL0=0; while (R_out); while (! R_out); th0=TH0; tl0=TL0; TR0=0; break; case 2: while (C_out); while (! C_out); TH0=0; TL0=0; while (C_out); while (! C_out); th0=TH0; tl0=TL0; TR0=0; break; case 3: while (L_out); while (! L_out); TH0=0; TL0=0; while (L_out); while (! L_out); th0=TH0; tl0=TL0; TR0=0; break; } f=1000000.0/1.085069/(th0*256+tl0)+0.5; } void delayms1 (uint xms) { uint i, j; for (i=xms;i>0;i--) for (j=110;j>0;j--); } void write_com1(uchar com) { Lcdrs=0; P0=com; delayms (5); Lcden=1; delayms (5); Lcden=0; } void write_data1(uchar date) { Lcdrs=1; P0=date; delayms (5); Lcden=1; delayms (5); Lcden=0; } void led_init1 () { Lcden=0; write_com(0x38); write_com(0x0c); write_com(0x06); write_com(0x01); write_com(0x80); for (num=0; num<8; num++) { write_data (table1 [num]); delayms (5); } } void t_init1 () { TMOD=0x01; TH0=0; TL0=0; EA=1; ET0=1; TR0=1; } void keyscan1 () { if (key_R==0) { delayms (10); if (key_R==0) a=1; } else if (key_C==0) { delayms (10); if (key_C==0) a=2; } else if (key_L==0) { delayms (10); if (key_L==0) a=3; } else while(key_R&&key_C&&key_L); } void display_f1 (ulong f) { uchar count=0; ulong f0; f0=f; while (f) { f=f/10; count++; } for (num=5+count; num>5; num--) { table2 [num] =f0%10+48; f0=f0/10; } write_com (0x80); for (num=0; num<6+count; num++) { write_data (table2 [num]); delayms (5); } } void display_R1 (ulong R) { uchar count=0; ulong R0; R0=R; while(R) { R=R/10; count++; } for (num=6+count; num>6; num--) { table3 [num] =R0%10+48; R0=R0/10; } write_com (0x80+0x40); for (num=0; num<7+count; num++) { write_data (table3 [num]); delayms (5); } } void display_C1 (uint C) { uchar count=0; uint C0; C0=C; while(C) { C=C/10; count++; } for (num=5+count; num>5; num--) { table4 [num] =C0%10+48; C0=C0/10; } write_com (0x80+0x40); for (num=0; num<6+count; num++) { write_data (table4 [num]); delayms (5); } } void display_L2 (uint L) { uchar count=0; uint L0; L0=L; while (L) { L=L/10; count++; } for (num=5+count; num>5; num--) { table5 [num] =L0%10+48; L0=L0/10; } write_com (0x80+0x40); for (num=0; num<6+count; num++) { write_data (table5 [num]); delayms (5); } } *** FATAL ERROR L256: MODULE CONTAINS DUPLICATE SEGMENT NAMES SEGMENT: ?PR?MAIN?TEXT1 MODULE: Text1.obj (TEXT1) Target not created |
|
相关推荐
5个回答
|
|
我晕!
|
|
|
|
不说明,也没个注释,还这么长
|
|
|
|
路过。。。。。。。。。。。
|
|
|
|
赞一下楼主的无私精神,
|
|
|
|
路过。。。。。。。。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
4930 浏览 3 评论
6220 浏览 1 评论
6485 浏览 0 评论
Protues中自己封装的芯片元件无Program File、Clock Frequency选项怎么解决,求求大神了!
8237 浏览 1 评论
基于51单片机的车辆倒车雷达报警系统,HC-SR04超声波测距,全套资料
1241 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-2 02:10 , Processed in 0.587814 second(s), Total 85, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号