{"rsdb":{"rid":"155998","subhead":"","postdate":"0","aid":"117106","fid":"54","uid":"1","topic":"1","content":"

\u505a\u4e86\u4e00\u5355\u7247\u673a\u8bbe\u8ba1\uff0c\u8981\u7528C\u8bed\u8a00<\/a>\u4e0e\u6c47\u7f16\u8bed\u8a00\u540c\u65f6\u5b9e\u73b0\uff0c\u73b0\u5c06\u8fd9\u6b21\u8bbe\u8ba1\u7684\u611f\u53d7\u548c\u6536\u83b7\uff0c\u8fd8\u6709\u9047\u5230\u7684\u95ee\u9898\u5199\u4e0b\uff0c\u6b22\u8fce\u611f\u5174\u8da3\u7684\u670b\u53cb\u4ea4\u6d41\u60f3\u6cd5\uff0c\u63d0\u51fa\u5efa\u8bae\u3002<\/p>

\u5355\u7247\u673a\u8bbe\u8ba1\uff1a\u57fa\u4e8e51\u5355\u7247\u673a\u768499\u7801\u8868\u8bbe\u8ba1<\/p>

\u8f6f\u4ef6\u73af\u5883\uff1aProteus8.0 + Keil4<\/p>

\u8981\u6c42\uff1a1\uff0c\u5f00\u5173\u6309\u4e00\u4e0b\uff0c\u6570\u7801\u7ba1\u5f00\u59cb\u8ba1\u65f6\u30022\uff0c\u6309\u4e24\u4e0b\uff0c\u6570\u7801\u7ba1\u663e\u793a\u9759\u6b62\u30023\uff0c\u6309\u4e09\u4e0b\uff0c\u6570\u7801\u7ba1\u6570\u503c\u6e05\u96f6\u3002<\/p>

C\u8bed\u8a00<\/a>\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>

#include
#define uint unsigned int
#define uchar unsigned char
uchar shi,ge,aa,keycount=0,temp;
sbit anjian=P1^7;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void display(shi,ge);
void key ();
void init();
void delay(uint z);
\/*-----\u4e3b\u7a0b\u5e8f-----*\/
void main()
{
init(); \/\/\u521d\u59cb\u5316
while(1)
{
key ();
if(keycount==1)
TR0=1; \/\/\u5f00\u4e2d\u65ad
if(keycount==2)
TR0=0;
if(keycount==3)
{
temp=0;
keycount=0;
}
if(aa==10){aa=0;
if(temp<=99)
{
temp++;display(shi,ge);
}
else
temp=0;}
}
}<\/p>


\/*------\u521d\u59cb\u5316\u7a0b\u5e8f-------*\/
void init()
{
keycount=0;
temp=0;
TMOD=0x01;
TH0=(65536-50000)\/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
\/\/TR0=0;
}
\/*-----\u5b9a\u65f6\u5668\u4e2d\u65ad-----*\/
void timer0() interrupt 1
{
TH0=(65536-50000)\/256;
TL0=(65536-50000)%256;
aa++;
}
\/*-----\u663e\u793a\u5b50\u7a0b\u5e8f-----*\/
void display(shi,ge)
{
shi=temp\/10;
ge=temp%10;
P0=table[shi];;delay(70);
P2=table[ge]; ;delay(70);
}
\/*-----\u6309\u952e\u68c0\u6d4b\u5b50\u7a0b\u5e8f-----*\/
void key ()
{
if(anjian==0)
{
delay(5); \/\/\u6d88\u6296
if(anjian==0)
keycount++;
}
\/\/while(anjian==0);
\/\/display(shi,ge); \/\/\u7b49\u5f85\u6309\u952e\u5f39\u8d77
}
\/*-----\u5ef6\u65f6\u5b50\u7a0b\u5e8f-----*\/
void delay(uint z) \/\/\u5ef6\u65f6\u7ea61ms
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}<\/p>

\u7535\u8def\u4eff\u771f\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>

\"\"<\/p>

\u597d\u4e86\uff0c\u90a3\u4e48\u63a5\u4e0b\u6765\u6211\u4eec\u5c31\u5f00\u59cbC\u8bed\u8a00\u2014\u2014>\u6c47\u7f16\u8bed\u8a00\u4e4b\u65c5^_^<\/p>

\uff081\uff09C\u8bed\u8a001-10\u884c\u6539\u4e3a<\/p>

ORG 0000H \/\/\u6c47\u7f16\u8d77\u59cb\u4f2a\u6307\u4ee4\uff0c\u529f\u80fd\u662f\u89c4\u5b9a\u7a0b\u5e8f\u5b58\u50a8\u5668\u4e2d\u6e90\u7a0b\u5e8f\u6216\u6570\u636e\u5757\u5b58\u653e\u7684\u8d77\u59cb\u5730\u5740
ajmp STAR \/\/ajmp\u65e0\u6761\u4ef6\u8df3\u8f6c\u6307\u4ee4
ORG 000bh
ajmp timer0
anjian equ P1.7 \/\/\u4f4d\u5b9a\u4e49
keycount equ 40h
shi equ 41h
gewei equ 42h
aa equ 43h
temp equ 44h
tab: db 3fh,6h,5bh,4fh,66h \/\/\u5efa\u8868
db 6dh,7dh,7h,7fh,6fh<\/p>

\uff082\uff09C\u8bed\u8a00\u4e2d\u7684\u521d\u59cb\u5316\u51fd\u6570 12-14\u884c\u548c39-49\u884c\u6539\u4e3a<\/p>

init:
mov keycount,#0 \/\/keycount=0
mov temp,#0 \/\/temp=1
mov tmod,#01h \/\/TMOD=0x01
mov TH0,#60
mov TL0,#176
setb EA \/\/\u4f4d\u7f6e\u4f4d\u6307\u4ee4\uff0c\u5bf9\u64cd\u4f5c\u6570\u6240\u6307\u51fa\u7684\u4f4d\u8fdb\u884c\u7f6e1\u64cd\u4f5c
setb ET0
setb TR0
ret<\/p>

acall\u4e3a\u5b50\u7a0b\u5e8f\u8fd1\u7a0b\u8c03\u7528\u6307\u4ee4\uff0c\u8fd4\u56de\u7528ret\u3002<\/p>

\uff083\uff09C\u8bed\u8a00\u4e2d15-35\u884c\u662f\u4e2awhile\u5faa\u73af\uff0c\u903b\u8f91\u6bd4\u8f83\u7e41\u7410\uff0c\u6ce8\u610f\u4e86\uff01<\/p>

START:
acall display
inc temp \/\/\u52a01\u6307\u4ee4\uff0c\u5c06\u64cd\u4f5c\u6570\u6240\u6307\u5b9a\u7684\u5355\u5143\u6216\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5bb9\u52a01
acall delay70 \/\/\u8fd1\u7a0b\u8c03\u7528delay70
x8: mov r0,keycount
cjne r0,#2,F1 \/\/cjne\u6bd4\u8f83\u8df3\u8f6c\u6307\u4ee4\uff0c\u82e5r0=2\u5219\u8df3\u8f6c\u5230x8\uff0c\u5426\u5219\u8df3\u8f6c\u5230F1\u3002
ajmp x8
F1: mov r0,temp
cjne r0,#99,START \/\/\u82e5r0<99\u65f6\uff0c\u91cd\u590d\u5faa\u73af\uff0c\u5426\u5219temp=0
mov temp,#0
ajmp START
F9:
acall key
mov r0,keycount
cjne r0,#0,F2 \/\/keycount=0\u987a\u5e8f\u6267\u884c\uff0c\u5426\u5219\u8df3\u8f6c\u5230F1
CLR P1.3 \/\/\u6e050
SETB TR0

F2: mov r0,keycount \/\/\u7b2c\u4e8c\u6b21\u6309\u952e
cjne r0,#2,F2
clr TR0
reti
mov r0,keycount \/\/\u7b2c\u4e09\u6b21\u6309\u952e
cjne r0,#3,F3
mov temp,#0
mov keycount,#0<\/p>

inc\u589e\u91cf\u6307\u4ee4\uff0c\u529f\u80fd\u662f\u5c06\u64cd\u4f5c\u6570\u6240\u6307\u5b9a\u7684\u5355\u5143\u6216\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5bb9\u52a01\uff0c\u5176\u7ed3\u679c\u8fd4\u8fd8\u56de\u539f\u64cd\u4f5c\u6570\u5355\u5143\u4e2d\u3002<\/p>

clr\u4f4d\u590d\u4f4d\uff0c\u529f\u80fd\u662f\u5bf9\u64cd\u4f5c\u6570\u6240\u6307\u51fa\u7684\u4f4d\u8fdb\u884c\u6e05\u201c0\u201d\u64cd\u4f5c\u3002<\/p>

\u6216\u8005\u5728\u4e2d\u65ad\u51fd\u6570\u4e2d<\/p>

timer0:
w1:
acall key
mov TH0,#60
mov TL0,#176
cpl p1.0
JB keycount,x2
ajmp x3
x2:
ajmp START
clr p1.0
ajmp w1
ajmp w1<\/p>

x3: mov r0,keycount
cjne r0,#3,w1 \/\/\u82e5r0=3\u5219\u987a\u5e8f\u6267\u884c\uff0c\u5426\u5219\u8df3\u8f6c\u5230w1
mov temp,#0
mov keycount,#0
ret<\/p>

\uff084\uff09C\u8bed\u8a0058-64\u884cdisplay\u51fd\u6570\u6539\u4e3a<\/p>

display:
mov a,temp
mov b,#10
div ab \/\/\u9664\u6cd5\u6307\u4ee4\uff0c\u5b9e\u73b0\u4e24\u4e2a\u516b\u4f4d\u65e0\u7b26\u53f7\u6570\u7684\u9664\u6cd5\u64cd\u4f5c\u3002
mov r2,A
mov r3,B
mov dptr,#tab \/\/16\u4f4d\u6570\u636e\u4f20\u9001\u4f7f\u7528\u65b9\u5f0f
mov a,r2
movc a,@a+dptr \/\/\u67e5\u8868\uff0c\u5148\u5c06\u7d2f\u52a0\u5668A\u7684\u5185\u5bb9\u4e0e\u6570\u636e\u6307\u9488\u5bc4\u5b58\u5668DPTR\u7684\u5185\u5bb9\u76f8\u52a0\uff0c\u518d\u4ee5\u5176\u7ed3\u679c\u4e3a\u5730\u5740\uff0c\u5c06\u8be5\u5730\u5740\u7684\u7ed3\u679c\u9001\u5165A\u4e2d
mov P0,a
acall delay70
nop \/\/\u7a7a\u6307\u4ee4
mov a,r3
movc a,@a+d","orderid":"0","title":"\u6d45\u8c08\u5355\u7247\u673a\u4e2dC\u8bed\u8a00\u4e0e\u6c47\u7f16\u8bed\u8a00\u7684\u8f6c\u6362(\u4e00)","smalltitle":"","mid":"0","fname":"linux\u7f16\u7a0b\u57fa\u7840","special_id":"0","bak_id":"0","info":"0","hits":"164","pages":"2","comments":"0","posttime":"2017-01-02 08:15:18","list":"1483316118","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"http:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"
\u5355\u7247\u673a<\/A> \u8bed\u8a00<\/A> \u6c47\u7f16\u8bed\u8a00<\/A> \u8f6c\u6362<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.31","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"\u6d45\u8c08\u5355\u7247\u673a\u4e2dC\u8bed\u8a00\u4e0e\u6c47\u7f16\u8bed\u8a00\u7684\u8f6c\u6362","lastview":"1500935365","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}