add LED display
This commit is contained in:
207
Listings/Interrupt_1.lst
Executable file → Normal file
207
Listings/Interrupt_1.lst
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
C51 COMPILER V9.54 INTERRUPT_1 05/13/2018 16:58:21 PAGE 1
|
||||
C51 COMPILER V9.54 INTERRUPT_1 05/13/2018 18:13:58 PAGE 1
|
||||
|
||||
|
||||
C51 COMPILER V9.54, COMPILATION OF MODULE INTERRUPT_1
|
||||
@ -14,87 +14,154 @@ line level source
|
||||
4 #include <reg51.h>
|
||||
5
|
||||
6 // <20>ŧi<C5A7><69><EFBFBD>ɨ禡
|
||||
7 void delay10ms(void);
|
||||
7 void delay_1500ms(void);
|
||||
8
|
||||
9 unsigned int timer0_counter = 150;
|
||||
10
|
||||
11 void main(void){
|
||||
12 1
|
||||
13 1 //<2F>}<7D><> Timer0 <20>M Timer1
|
||||
14 1 TMOD = 0x11;
|
||||
15 1
|
||||
16 1 //interrupt control
|
||||
17 1 TL0 = (65536 - 9216) % 256;
|
||||
18 1 TH0 = (65536 - 9216) / 256;
|
||||
19 1 TF0 = 0;
|
||||
20 1 TR0 = 1; //<2F>}<7D>ҭp<D2AD>ɾ<EFBFBD> timer0
|
||||
21 1 ET0 = 1; //<2F>}<7D><> TF0 <20><><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>Ҳն}<7D><>
|
||||
22 1 EA = 1; //<2F>}<7D>Ҥ<EFBFBD><D2A4>_<EFBFBD>Ҳ<EFBFBD><D2B2>`<60>}<7D><>
|
||||
23 1
|
||||
24 1 delay10ms();
|
||||
25 1
|
||||
26 1 while(1){
|
||||
27 2 // do LED move up to down per 1.5 sec
|
||||
28 2 // using Timer 1 Mode 1 to generate 10ms delay
|
||||
29 2 }
|
||||
30 1 }
|
||||
31
|
||||
32
|
||||
33 void delay10ms(void){
|
||||
34 1 //<2F>]<5D>w<EFBFBD><77><EFBFBD>l<EFBFBD><6C>
|
||||
35 1 TF1 = 0;
|
||||
36 1 TR1 = 0;
|
||||
37 1 TL1 = (65536-9216) % 256;
|
||||
38 1 TH1 = (65536-9216) / 256;
|
||||
39 1
|
||||
40 1 //<2F>}<7D>ҭp<D2AD>ɾ<EFBFBD> timer1
|
||||
41 1 TR1 = 1;
|
||||
42 1
|
||||
43 1 //<2F><> TF1 <20>S<EFBFBD><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
44 1 while(TF1 == 0);
|
||||
45 1
|
||||
46 1 //<2F><><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>ɾ<EFBFBD>
|
||||
47 1 TR1 = 0;
|
||||
48 1
|
||||
49 1 //<2F>N TF1 <20>k<EFBFBD>s
|
||||
50 1 TF1 = 0;
|
||||
51 1 }
|
||||
52
|
||||
53
|
||||
54 // timer0 <20>b<EFBFBD>p<EFBFBD>ɨ쪺<C9A8>ɭ<EFBFBD>(TF0 = 1)<29>|<7C>I<EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ƨ禡
|
||||
C51 COMPILER V9.54 INTERRUPT_1 05/13/2018 16:58:21 PAGE 2
|
||||
11 bit lightoff = 1;
|
||||
12 bit lighton = 0;
|
||||
13 sbit P1_0 = P1^0;
|
||||
14 sbit P1_1 = P1^1;
|
||||
15 sbit P1_2 = P1^2;
|
||||
16 sbit P1_3 = P1^3;
|
||||
17 sbit P1_4 = P1^4;
|
||||
18 sbit P1_5 = P1^5;
|
||||
19 sbit P1_6 = P1^6;
|
||||
20 sbit P1_7 = P1^7;
|
||||
21
|
||||
22 void main(void){
|
||||
23 1
|
||||
24 1 //<2F>}<7D><> Timer0 <20>M Timer1
|
||||
25 1 TMOD = 0x11;
|
||||
26 1
|
||||
27 1 //interrupt control
|
||||
28 1 TL0 = (65536 - 9216) % 256;
|
||||
29 1 TH0 = (65536 - 9216) / 256;
|
||||
30 1 TF0 = 0;
|
||||
31 1 TR0 = 1; //<2F>}<7D>ҭp<D2AD>ɾ<EFBFBD> timer0
|
||||
32 1 ET0 = 1; //<2F>}<7D><> TF0 <20><><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>Ҳն}<7D><>
|
||||
33 1 EA = 1; //<2F>}<7D>Ҥ<EFBFBD><D2A4>_<EFBFBD>Ҳ<EFBFBD><D2B2>`<60>}<7D><>
|
||||
34 1
|
||||
35 1 while(1){
|
||||
36 2 // do LED move up to down per 1.5 sec
|
||||
37 2 // using Timer 1 Mode 1 to generate 10ms delay
|
||||
38 2 P1 = 0xFF;
|
||||
39 2 while (1) {
|
||||
40 3 delay_1500ms();
|
||||
41 3
|
||||
42 3 P1_0 = lighton;
|
||||
43 3 delay_1500ms();
|
||||
44 3
|
||||
45 3 P1_1 = lighton;
|
||||
46 3 delay_1500ms();
|
||||
47 3
|
||||
48 3 P1_2 = lighton;
|
||||
49 3 delay_1500ms();
|
||||
50 3
|
||||
51 3 P1_3 = lighton;
|
||||
52 3 delay_1500ms();
|
||||
53 3
|
||||
54 3 P1_4 = lighton;
|
||||
C51 COMPILER V9.54 INTERRUPT_1 05/13/2018 18:13:58 PAGE 2
|
||||
|
||||
55 void my_timer0(void) interrupt 1 {
|
||||
56 1
|
||||
57 1 //<2F>]<5D>w<EFBFBD><77><EFBFBD>l<EFBFBD><6C>
|
||||
58 1 TL0 = (65536 - 9216) % 256;
|
||||
59 1 TH0 = (65536 - 9216) / 256;
|
||||
60 1 TF0 = 0;
|
||||
61 1
|
||||
62 1 // timer0_counter <20>@<40><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
63 1 timer0_counter--;
|
||||
64 1
|
||||
65 1
|
||||
66 1 //<2F><> timer0_counter <20><> 0 <20>ɡA<C9A1><41><EFBFBD>@<40>C<EFBFBD>q<EFBFBD><71><EFBFBD>ܾ<EFBFBD>
|
||||
67 1 if (timer0_counter == 0){
|
||||
68 2 // <20><><EFBFBD>@<40>C<EFBFBD>q<EFBFBD><71><EFBFBD>ܾ<EFBFBD>
|
||||
69 2
|
||||
70 2
|
||||
71 2 //<2F>N timer0_counter <20><><EFBFBD>ȳ]<5D>^ 150
|
||||
72 2 timer0_counter = 150;
|
||||
73 2
|
||||
74 2 }
|
||||
75 1 }
|
||||
55 3 delay_1500ms();
|
||||
56 3
|
||||
57 3 P1_5 = lighton;
|
||||
58 3 delay_1500ms();
|
||||
59 3
|
||||
60 3 P1_6 = lighton;
|
||||
61 3 delay_1500ms();
|
||||
62 3
|
||||
63 3 P1_7 = lighton;
|
||||
64 3 delay_1500ms();
|
||||
65 3
|
||||
66 3 P1_7 = lightoff;
|
||||
67 3 delay_1500ms();
|
||||
68 3
|
||||
69 3 P1_6 = lightoff;
|
||||
70 3 delay_1500ms();
|
||||
71 3
|
||||
72 3 P1_5 = lightoff;
|
||||
73 3 delay_1500ms();
|
||||
74 3
|
||||
75 3 P1_4 = lightoff;
|
||||
76 3 delay_1500ms();
|
||||
77 3
|
||||
78 3 P1_3 = lightoff;
|
||||
79 3 delay_1500ms();
|
||||
80 3
|
||||
81 3 P1_2 = lightoff;
|
||||
82 3 delay_1500ms();
|
||||
83 3
|
||||
84 3 P1_1 = lightoff;
|
||||
85 3 delay_1500ms();
|
||||
86 3
|
||||
87 3 P1_0 = lightoff;
|
||||
88 3 }
|
||||
89 2 }
|
||||
90 1 }
|
||||
91
|
||||
92
|
||||
93 void delay_1500ms(void){
|
||||
94 1
|
||||
95 1 int time = 0;
|
||||
96 1 while(time < 150) {
|
||||
97 2 //<2F>]<5D>w<EFBFBD><77><EFBFBD>l<EFBFBD><6C>
|
||||
98 2 TF1 = 0;
|
||||
99 2 TR1 = 0;
|
||||
100 2 TL1 = (65536-9216) % 256;
|
||||
101 2 TH1 = (65536-9216) / 256;
|
||||
102 2
|
||||
103 2 //<2F>}<7D>ҭp<D2AD>ɾ<EFBFBD> timer1
|
||||
104 2 TR1 = 1;
|
||||
105 2
|
||||
106 2 //<2F><> TF1 <20>S<EFBFBD><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
107 2 while(TF1 == 0);
|
||||
108 2
|
||||
109 2 //<2F><><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>ɾ<EFBFBD>
|
||||
110 2 TR1 = 0;
|
||||
111 2
|
||||
112 2 //<2F>N TF1 <20>k<EFBFBD>s
|
||||
113 2 TF1 = 0;
|
||||
114 2 time++;
|
||||
115 2 }
|
||||
116 1 }
|
||||
C51 COMPILER V9.54 INTERRUPT_1 05/13/2018 18:13:58 PAGE 3
|
||||
|
||||
117
|
||||
118
|
||||
119 // timer0 <20>b<EFBFBD>p<EFBFBD>ɨ쪺<C9A8>ɭ<EFBFBD>(TF0 = 1)<29>|<7C>I<EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD>ƨ禡
|
||||
120 void my_timer0(void) interrupt 1 {
|
||||
121 1
|
||||
122 1 //<2F>]<5D>w<EFBFBD><77><EFBFBD>l<EFBFBD><6C>
|
||||
123 1 TL0 = (65536 - 9216) % 256;
|
||||
124 1 TH0 = (65536 - 9216) / 256;
|
||||
125 1 TF0 = 0;
|
||||
126 1
|
||||
127 1 // timer0_counter <20>@<40><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
128 1 timer0_counter--;
|
||||
129 1
|
||||
130 1
|
||||
131 1 //<2F><> timer0_counter <20><> 0 <20>ɡA<C9A1><41><EFBFBD>@<40>C<EFBFBD>q<EFBFBD><71><EFBFBD>ܾ<EFBFBD>
|
||||
132 1 if (timer0_counter == 0){
|
||||
133 2 // <20><><EFBFBD>@<40>C<EFBFBD>q<EFBFBD><71><EFBFBD>ܾ<EFBFBD>
|
||||
134 2
|
||||
135 2
|
||||
136 2 //<2F>N timer0_counter <20><><EFBFBD>ȳ]<5D>^ 150
|
||||
137 2 timer0_counter = 150;
|
||||
138 2
|
||||
139 2 }
|
||||
140 1 }
|
||||
|
||||
|
||||
MODULE INFORMATION: STATIC OVERLAYABLE
|
||||
CODE SIZE = 74 ----
|
||||
CODE SIZE = 200 ----
|
||||
CONSTANT SIZE = ---- ----
|
||||
XDATA SIZE = ---- ----
|
||||
PDATA SIZE = ---- ----
|
||||
DATA SIZE = 2 ----
|
||||
IDATA SIZE = ---- ----
|
||||
BIT SIZE = ---- ----
|
||||
BIT SIZE = 2 ----
|
||||
END OF MODULE INFORMATION.
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user