📄 main.lst
字号:
C51 COMPILER V8.08 MAIN 03/06/2008 13:46:56 PAGE 1
C51 COMPILER V8.08, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\obj\main.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SRC\main.C BROWSE DEBUG OBJECTEXTEND PRINT(.\lst\main.lst) OBJECT(.\obj\mai
-n.obj)
line level source
1 #include "comm.h"
2 #include "ir.h"
3 #include "ic165.h"
4 #include "message.h"
5 #include "Key_process.h"
6 #include "debug.h"
7 /*
8 *SYSTEM CLOCK IS 4MHz
9 */
10
11 //extern uint pre_code;
12 //unsigned
13 uchar user_key = 0xff;
14 int linear_timer = 0;
15 uchar Get_key_timer = 0;
16
17 #ifdef DEBUG_PRINTF1
bit test_flag = 0;
#endif
22
23 uchar codeIR;
24 bit ir_enable = 0; /*IR receive valid?*/
25 bit power_flag = 0; /*POWER valid?*/
26
27 void timer1_interrupt_service() interrupt 3
28 /*system timer increase 10mS*/
29 {
30 1 #ifdef DEBUG_PRINTF1
static uchar delay_time_cnt = 0;
#endif
35 1
36 1 TR1 = 0;
37 1 TH1 = TIMER0_RELOAD_HIGH;//0xB1;
38 1 TL1 = TIMER0_RELOAD_LOW;//0xED; /*add 0xd to adjust timer*/
39 1 TR1 = 1;
40 1
41 1 if(linear_timer > 0)
42 1 {
43 2 linear_timer = linear_timer - 1;
44 2 }
45 1 if(Get_key_timer >0) /*扫描按键的时间*/
46 1 {
47 2 Get_key_timer --;
48 2 }
49 1 #ifdef DEBUG_PRINTF1
delay_time_cnt ++;
if( delay_time_cnt == 100)
{
test_flag = 1;
delay_time_cnt = 0;
C51 COMPILER V8.08 MAIN 03/06/2008 13:46:56 PAGE 2
}
#endif
57 1
58 1 /* linear_timer ++;*/
59 1 }
60
61 void system_timer_init()
62 /*I use timer1 to generate system time*/
63 {
64 1 TH1 =TIMER0_RELOAD_HIGH ;//0xBE;
65 1 TL1 = TIMER0_RELOAD_LOW;//0xE0;
66 1 TR1 = 1;
67 1 ET1 = 1;
68 1 }
69 #if 1
70 void delay(unsigned int j) /*0.173ms*/
71 {
72 1 unsigned char i ;
73 1 for(;j>0;j--)
74 1 {
75 2 i = 10;
76 2 while(--i); /*10uS*/
77 2 }
78 1 }
79 #endif
80
81
82 void set_system_baud_rate(uchar mode) /*7.3728 MHz /2*/
83 {
84 1 uchar reg_brgr0 = 0,reg_brgr1 = 0;
85 1
86 1 switch(mode)
87 1 {
88 2 case 0:
89 2 reg_brgr0 = 0x50;
90 2 // baud_rate = 38400;
91 2 break;
92 2 case 1:
93 2 reg_brgr0 = 0xB0;
94 2 reg_brgr1 = 0x00;
95 2 // baud_rate = 19200;
96 2 break;
97 2 case 2:
98 2 reg_brgr0 = 0x70;
99 2 reg_brgr1 = 0x01;
100 2 // baud_rate = 9600;
101 2 break;
102 2 case 3:
103 2 reg_brgr0 = 0x10;
104 2 // baud_rate = 115200;
105 2 break;
106 2 case 4:
107 2 reg_brgr0 = 0xF0;
108 2 reg_brgr1 = 0x02;
109 2 // baud_rate = 4800;
110 2
111 2 break;
112 2 }
113 1
114 1 PCON = 0x40;
115 1 SCON = 0x50;
116 1 BRGCON = 0;
C51 COMPILER V8.08 MAIN 03/06/2008 13:46:56 PAGE 3
117 1 BRGR0 = reg_brgr0;
118 1 BRGR1 = reg_brgr1;
119 1 BRGCON = 3;
120 1 }
121
122
123
124 /*
125 QUASI_BIDIRECTIONAL: 00
126 PUSH_PULL: 01
127 INPUT_ONLY: 10
128 OPEN_DRAIN: 11
129 */
130
131 void io_config()
132 {
133 1 P0M1 = 0x00;/* 0.0 推挽*/
134 1 P0M2 = 0x23;
135 1 //P0 = 0x7c /**/;
136 1 P1M1 = 0x06;//0x04 jian
137 1 P1M2 = 0x17;
138 1 /*p1.1 LED 为准双向设置
139 1 p1.2 发送为输出1 0
140 1 p1.3 IR 接受,准双向 00.
141 1 p1.4 rst_n 输入
142 1
143 1 */
144 1 // P1 = 0xB0;
145 1 }
146 #if 0
unsigned char LSbTMsb(unsigned char Ldata)
{
unsigned char Mdata,i;
for (i =0 ;i<8;i++)
{
if(Ldata & 0x01)
{
Mdata |= 0x01;
}
else
{
Mdata &= ~0x01;
}
Ldata >>= 1;
if(i < 7)
Mdata <<= 1;
}
return Mdata;
}
#endif
170 void main()
171 {
172 1
173 1 #ifdef DEBUG_PRINTF
// extern unsigned char ivcode,sys_code;
#endif
178 1
C51 COMPILER V8.08 MAIN 03/06/2008 13:46:56 PAGE 4
179 1 DIVM = 1; /*将时钟分为一半的频率*/
180 1 io_config();
181 1 set_system_baud_rate(3); /*115200*/
182 1 /*start system timer*/
183 1 TMOD = 0x11;
184 1 TH0 = 0x00;
185 1 TL0 = 0x00;
186 1 ET0 = 1;
187 1 EX0 = 1;
188 1 TR0 = 0;
189 1 IT0 = 1; /*中断1 下降廷触发*/
190 1 EA = 1;
191 1 system_timer_init();
192 1 //STANDBY_LED = LED_POWER_ON;
193 1 // proc_ir_sel_disp(14);
194 1
195 1 P1M1 = 0x06;
196 1 STANDBY_LED = LED_STANDBY; /**/
197 1 RST_N = 0; /*复位脚先拉低*/
198 1 OUTPUT_IR = 1;
199 1 STANDBY_CTRL = CTRL_POWER_OFF;
200 1 #if 0
RST_N = 0; /*复位脚先拉低*/
STANDBY_CTRL = CTRL_POWER_ON;
//proc_ir_sel_disp(6); //delete zxl 07-10-09 去除灯闪烁
Rest_Mast_TvBox();
STANDBY_LED = LED_STANDBY;
power_flag = 1; /*POWER ON*/
#endif
208 1 // STANDBY_CTRL = CTRL_POWER_ON;
209 1 // power_flag = 0;
210 1 // proc_power_key();
211 1 while(1)
212 1 {
213 2 #if 1
214 2 if(Get_key_timer == 0) /*10ms扫描一次*/
215 2 {
216 3 GetPanelKeyThread();
217 3 Get_key_timer = 1;
218 3 }
219 2 #endif
220 2
221 2 if(ir_enable)
222 2 {
223 3 #ifdef DEBUG_PRINTF
tvbox_printf("button code:",codeIR,1);
// tvbox_printf("sys code:",sys_code,1);
// tvbox_printf("ivn code:",ivcode,1);
#endif
228 3
229 3 ir_enable = 0;
230 3 //codeIR = LSbTMsb(codeIR); /*jian add in 07-07-31*/
231 3 user_key = codeIR;
232 3 }
233 2 if(user_key != 0xff/*_NO_KEY*/)
234 2 {
235 3 // tvbox_printf("user key:",user_key,1);
236 3 key_service(user_key);
237 3 user_key = 0xff;/*_NO_KEY*/;
238 3 }
239 2 // PutChar(0x55);
240 2 #ifdef DEBUG_PRINTF1
C51 COMPILER V8.08 MAIN 03/06/2008 13:46:56 PAGE 5
if (test_flag == 1) /*1 s 一次*/
{
PutChar(0x55);
test_flag = 0;
}
#endif
248 2
249 2 delay(10);
250 2 }
251 1
252 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 238 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 5 ----
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -