?? 1.lst
字號:
C51 COMPILER V6.12 1 03/24/2009 18:40:42 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE 1
OBJECT MODULE PLACED IN .\1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\1.c DEBUG OBJECTEXTEND
stmt level source
1 //采用8位LED軟件譯碼動態顯示,P0為字段碼,P2為位選碼,數碼管共陽;
2 //key0為位選鍵;key1為加“1鍵;key2為減“1”鍵。
3
4 #include "reg51.h"
5 #define char unsigned char
6 char code
7 dis_7[12]={0xc0,0xf9,0xa4,0xb0, // 0, 1, 2, 3
8 0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf};//4,5,6,7,8,9,"滅”和“-”
9 char code scan_con[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//位的選擇
10 char _data_dis[8]={0x00,0x00,0x0b,0x00,0x00,0x0b,0x00,0x00};//顯示緩沖區,時,分和秒初始為0,0x0b為“-”的
-編碼
11 char data timedata[3]={0x00,0x00,0x00};
12 char data ms50=0x00,con=0x00,con1=0x00,con2=0x00;
13 sbit key0=P1^4;
14 sbit key1=P1^5;
15 sbit key2=P1^6;
16 //1ms延時
17 delay1ms(int t)
18 { int i,j;
19 1 for(i=0;i<t;i++)
20 1 for(j=0;j<120;j++);
21 1 }
22 void deep() //當有效按鍵被按下時,蜂鳴器響;
23 { int i;
24 1 for(i=.0;i<10;i++)
25 1 {P3^7 = 0;
*** ERROR C141 IN LINE 25 OF .\1.C: syntax error near '='
26 2 delay1ms(1);
27 2 P3^7 = 1;
*** ERROR C141 IN LINE 27 OF .\1.C: syntax error near '='
28 2 }
29 1 }
30 //按鍵處理
31 keycan()
32 { EA=0;
33 1 if(key0==0)
34 1 { delay1ms(10);deep();
35 2 while(key0==0);
36 2 con++;TR0=0;ET0=0;
37 2 if(con>=3)
38 2 { con=0;TR0=1;ET0=1;}
39 2 }
40 1 if(con!=0)
41 1 { if(key1==0)
42 2 { delay1ms(10);deep();
43 3 while(key1==0);
44 3 timedata[con]++;
*** ERROR C187 IN LINE 44 OF .\1.C: not an lvalue
45 3 if(con==2) con1=24;else con1=60;
46 3 if(timedata[con]>=con1)
47 3 { timedata[con]=0;}
*** ERROR C213 IN LINE 47 OF .\1.C: left side of asn-op not an lvalue
48 3 }
49 2 }
50 1 if(con!=0)
C51 COMPILER V6.12 1 03/24/2009 18:40:42 PAGE 2
51 1 { if(key2==0)
52 2 {delay1ms(10);deep();
53 3 while(key2==0);
54 3 timedata[con]--;
*** ERROR C187 IN LINE 54 OF .\1.C: not an lvalue
55 3 if(con==2) con2=23;else con2=59;
56 3 if(timedata[con]<=0)
57 3 { timedata[con]=con2;}
*** ERROR C213 IN LINE 57 OF .\1.C: left side of asn-op not an lvalue
58 3 }
59 2 }
60 1 EA=1;
61 1 }
62 //數碼管顯示
63 scan()
64 { char k;
65 1 _data_dis[0]=timedata[0]%10; _data_dis[1]=timedata[0]/10;
*** ERROR C193 IN LINE 65 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 65 OF .\1.C: '/': bad operand type
66 1 _data_dis[3]=timedata[1]%10; _data_dis[4]=timedata[1]/10;
*** ERROR C193 IN LINE 66 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 66 OF .\1.C: '/': bad operand type
67 1 _data_dis[6]=timedata[2]%10; _data_dis[7]=timedata[2]/10;
*** ERROR C193 IN LINE 67 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 67 OF .\1.C: '/': bad operand type
68 1 for(k=0;k<8;k++)
69 1 { P0=dis_7[ _data_dis[k]];P2=scan_con[k];delay1ms(1);P2=0xff;}
70 1
71 1 }
72 //主函數
73 main()
74 { TH0=0x3c;TL0=0xb0;
75 1 TMOD=0x01;ET0=1;TR0=1;EA=1;
76 1 while(1)
77 1 { scan();
78 2 keycan();
79 2 }
80 1 }
81 //定時器/記數器T0中斷服務
82 void time_intt0(void)interrupt 1
83 { ET0=0;TR0=0;TH0=0x3c;TL0=0xb0;TR0=1;
84 1 ms50++;
85 1 if(ms50==20)
86 1 { ms50=0x00;timedata[0]++;
*** ERROR C187 IN LINE 86 OF .\1.C: not an lvalue
87 2 if(timedata[0]==60)
88 2 { timedata[0]=0;timedata[1]++;
*** ERROR C213 IN LINE 88 OF .\1.C: left side of asn-op not an lvalue
*** ERROR C187 IN LINE 88 OF .\1.C: not an lvalue
89 3 if(timedata[2]==24)
90 3 {timedata[2]=0;
*** ERROR C213 IN LINE 90 OF .\1.C: left side of asn-op not an lvalue
91 4 }
92 3 }
93 2 } ET0=1;
94 1 }
C51 COMPILATION COMPLETE. 0 WARNING(S), 16 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -