📄 ledtest.lst
字号:
C51 COMPILER V7.09 LEDTEST 04/30/2007 09:35:14 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE LEDTEST
OBJECT MODULE PLACED IN ledtest.OBJ
COMPILER INVOKED BY: D:\Program Files\Keil\C51\BIN\C51.EXE ledtest.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*********************cmdexplain***********************************
2 //cmd
3 - 0xF0 全屏清屏
4 - 0xF1 全屏闪烁1
5 - 0xF2 全屏闪烁2
6 - 0xF3 全屏闪烁3
7 - 0xF4 全屏关屏
8 - 0xF5 全屏关闭闪烁
9
10 //type+data
11 - 0x0f 正常显示X
12 - 0x0e 闪烁1显示X
13 - 0x0d 闪烁2显示X
14 - 0x0c 闪烁3显示X
15
16 *******************************************************************/
17
18 #include<reg52.h>
19 #include<absacc.h>
20
21 sfr AXUR = 0X8E;
22
23 #define U1 bit
24 #define U8 unsigned char
25 #define U16 unsigned int
26 #define U32 unsigned long
27
28 #ifndef BIT
29 #define BIT(x) (1 << (x))
30 #endif
31
32 sbit irqport = P3^2;
33 sbit busyport = P3^3;
34 sbit typeport = P3^5;
35
36
37 #define LEDCOMPORT P1
38 //#define LEDBUFADDR 256
39
40 //#define ReatempedBuf(addr_) (*(volatile U8 pdata*)(addr_))
41 //#define WriteLedBuf(addr_,data_) (*(volatile U8 pdata*)(addr_) = (U8)(data_))
42 //#define PrintCLed(addr_,data_) (*(volatile U8 xdata*)(addr_) = (U8)(data_))
43
44 volatile U8 data addrbuf = 0;
45 volatile U8 data cmdbuf = 0;
46 U1 data FlashFlag_3 = 0;
47 U1 data FlashFlag_5 = 0;
48 U1 data FlashFlag_7 = 0;
49 U16 data TimeCount_3 = 0;
50 U16 data TimeCount_5 = 0;
51 U16 data TimeCount_7 = 0;
52
53 U8 pdata light_1 _at_ 120 ;
54 U8 pdata light_2 _at_ 121 ;
55 U8 pdata light_3 _at_ 122 ;
C51 COMPILER V7.09 LEDTEST 04/30/2007 09:35:14 PAGE 2
56
57 //U8 data led_code[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f,0x00,0x77,0x7c,0x39
-,0x1e,0x40};//0,1,2,3,4,5,6,7,8,9,灭,A,b,C,d,-
58 U8 data led_code[16] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f,0x00,0x01,0x02,0x04,0
-x1e,0x40};//0,1,2,3,4,5,6,7,8,9,灭,A,b,C,d,-
59 U16 data row_code[7] = { 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000};
60
61 void test(void)
62 {
63 1 U8 i = 0;
64 1 for(i = 0; i<128;i++)
65 1 {
66 2 PBYTE[i] = 0x3f;
67 2 }
68 1 }
69 void scan_led(void)
70 {
71 1 U8 i, j;
72 1 U8 temp;
73 1 U8 temp1;
74 1 U8 temp2;
75 1
76 1 for(i = 0; i < 16; i++)
77 1 {
78 2 XBYTE[0X8000] = 0; XBYTE[0X9000] = 0;
79 2 for(j = 0; j < 7; j++)
80 2 {
81 3 temp2 = j*16 + i;
82 3 temp = PBYTE[temp2];
83 3 if (temp2 == 93) temp1 = temp;
84 3 else if (temp2 == 94) temp1 = temp;
85 3 else if (temp2 == 95) temp1 = temp;
86 3 else
87 3 {
88 4 switch(temp&0xf0)
89 4 {
90 5 case 0xf0:
91 5 temp &= 0x0f;
92 5 temp1 = led_code[temp];
93 5 break;
94 5 case 0xe0:
95 5 if(FlashFlag_3) temp = 0x0a;
96 5 else temp &= 0x0f;
97 5 temp1 = led_code[temp];
98 5 break;
99 5 case 0xd0:
100 5 if(FlashFlag_5) temp = 0x0a;
101 5 else temp &= 0x0f;
102 5 temp1 = led_code[temp];
103 5 break;
104 5 case 0xc0:
105 5 if(FlashFlag_7) temp = 0x0a;
106 5 else temp &= 0x0f;
107 5 temp1 = led_code[temp];
108 5 break;
109 5 }
110 4 }
111 3 XBYTE[row_code[j]] = temp1;
112 3 }
113 2 if (i < 8) XBYTE[0X8000] = BIT(i);
114 2 else XBYTE[0X9000] = BIT(i - 8);
115 2 XBYTE[0XA000] = light_1;
C51 COMPILER V7.09 LEDTEST 04/30/2007 09:35:14 PAGE 3
116 2 XBYTE[0XB000] = light_2;
117 2 XBYTE[0XC000] = light_3;
118 2 if(++TimeCount_3 >= 1000) {FlashFlag_3 = ~FlashFlag_3; TimeCount_3 = 0;}
119 2 if(++TimeCount_5 >= 2000) {FlashFlag_5 = ~FlashFlag_5; TimeCount_5 = 0;}
120 2 if(++TimeCount_7 >= 3000) {FlashFlag_7 = ~FlashFlag_7; TimeCount_7 = 0;}
121 2 }
122 1 }
123
124 void scan_cmd(void)
125 {
126 1 U8 i, temp;
127 1
128 1 if (cmdbuf)
129 1 {
130 2 switch(cmdbuf)
131 2 {
132 3 case 0xf0 : for(i = 0; i < 128; i++) PBYTE[i] = 0X0; break;
133 3 case 0xf1 : for(i = 0; i < 128; i++) {temp = PBYTE[i]; temp &= 0x0f; temp |= 0xe0; PBYTE[i] =
- temp;} break;
134 3 case 0xf2 : for(i = 0; i < 128; i++) {temp = PBYTE[i]; temp &= 0x0f; temp |= 0xd0; PBYTE[i] =
- temp;} break;
135 3 case 0xf3 : for(i = 0; i < 128; i++) {temp = PBYTE[i]; temp &= 0x0f; temp |= 0xc0; PBYTE[i] =
- temp;} break;
136 3 case 0xf4 : for(i = 0; i < 128; i++) PBYTE[i] = 0x0a; break;
137 3 case 0xf5 : for(i = 0; i < 128; i++) {temp = PBYTE[i]; temp &= 0x0f; PBYTE[i] = temp;} break;
138 3 case 0xe0 : light_1 = 0xff; light_2 = 0xff; light_3 = 0xff; break;
139 3 case 0xe1 : light_1 = 0x0; light_2 = 0x0; light_3 = 0x0; break;
140 3 }
141 2 cmdbuf = 0;
142 2 }
143 1 }
144
145 void InitSys(void)
146 {
147 1 U8 i;
148 1
149 1 AXUR = 0x01;
150 1 P1 = 0xff; P2 = 0xff; P3 = 0xff;
151 1 EX0 = 1; IT0 = 1;
152 1 busyport = 0;
153 1 for(i = 0; i < 128; i++) PBYTE[i] = 0xfa;
154 1 PBYTE[93] = 0x0; PBYTE[94] = 0x0; PBYTE[95] = 0x0;
155 1 light_1 = 0x0; light_2 = 0x0; light_3 = 0x0;
156 1 while(!irqport);
157 1 busyport = 1; IE0 = 0; EA = 1;
158 1 }
159
160 void main(void)
161 {
162 1
163 1 InitSys();
164 1 test();
165 1 while(1)
166 1 {
167 2 scan_led();
168 2 scan_cmd();
169 2 }
170 1 }
171
172 void ex0_irq(void) interrupt 0
173 {
174 1
C51 COMPILER V7.09 LEDTEST 04/30/2007 09:35:14 PAGE 4
175 1 busyport = 0;
176 1 if (typeport) //addr
177 1 {
178 2 if(LEDCOMPORT & 0x80) cmdbuf = LEDCOMPORT;
179 2 else addrbuf = LEDCOMPORT;
180 2 }
181 1 else { PBYTE[addrbuf] = LEDCOMPORT; addrbuf--;}
182 1 busyport = 1;
183 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 601 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 38 2
IDATA SIZE = ---- ----
BIT SIZE = 3 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -