?? main.lst
字號:
C51 COMPILER V7.06 MAIN 10/29/2008 11:22:40 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\main.c ROM(COMPACT) BROWSE DEBUG OBJECTEXTEND PRINT(.\main.lst) OBJE
-CT(main.obj)
stmt level source
1 /************************************************************************
2 ;copyright :shenzhen coolwaveasia
3 ;filename :main.c
4 ;mcu :w78e52b
5 ;crystal :33.177MHZ
6 ;cycle :0.36us
7 ;RF :7105
8 ;rf crystal :16MHZ
9 ;RF rate :250K(默認,可以通過按鍵修改)
10 ;startdate :2008.10.7
11 ;enddate :
12 ;writeby :dengyihong
13 ;revision :B
14 ;describe :7105 參數測試(可以測試通信)
15 ;notice :
16 ;complier :Keil C
17 ;***********************************************************************
18 ; --------------------
19 ; P1.0 |1 40| VCC
20 ; P1.1 |2 39| P0.0 ---- LCD_DATA0
21 ; RF_SCK ---- P1.2 |3 38| P0.1 ---- LCD_DATA1
22 ; RF_SDIO ---- P1.3 |4 37| P0.2 ---- LCD_DATA2
23 ; P1.4 |5 36| P0.3 ---- LCD_DATA3
24 ; RF_SCS ---- P1.5 |6 35| P0.4 ---- LCD_DATA4
25 ; P1.6 |7 34| P0.5 ---- LCD_DATA5
26 ; P1.7 |8 33| P0.6 ---- LCD_DATA6
27 ; RST/Vpd |9 32| P0.7 ---- LCD_DATA7
28 ; RXD/P3.0 |10 31| /EA/Vpp
29 ; TXD/P3.1 |11 30| ALE/PROG
30 ; RF_GPIO2 --- /INT0/P3.2 |12 29| /PSEN
31 ; RF_GPIO1 --- /INT1/P3.3 |13 28| P2.7 ---- KEY4
32 ; T0/P3.4 |14 27| P2.6 ---- KEY3
33 ; RX\TX --- T1/P3.5 |15 26| P2.5 ---- KEY2
34 ; /WR/P3.6 |16 25| P2.4 ---- KEY1
35 ; /RD/P3.7 |17 24| P2.3
36 ; XTAL2 |18 23| P2.2 ---- LCD_RW
37 ; XTAL1 |19 22| P2.1 ---- LCD_RS
38 ; VSS |20 21| P2.0 ---- LCD_EN
39 ; --------------------
40 ; W78E52B
41 ;***********************************************************************/
42
43 #include "..\header\main.h"
44 #include "..\header\maindef.h"
45
46
47 bit Wait_Ack = 0; // 等待RF應答
48 bit Clr_Screen = 0; // 刷新屏幕
49
50 U8 Timer0_Cnt = 0; // 定時器0計數器
51
52 U8 System_Mode = NORMAL_MODE; // rf 工作模式
53
54 enum Rf_Status Rf_Mode_Cnt;
C51 COMPILER V7.06 MAIN 10/29/2008 11:22:40 PAGE 2
55 U8 Add_Key_Cnt = 0;
56 U8 Dec_Key_Cnt = 0;
57
58 U8 Rf_Rate_Cnt = 5; // default 250k
59 U8 Rf_Channel_Cnt = 3; // default 第4個通道
60 U8 Rf_Rec_Channel = (3 << 3); // default frequency 2.412GHZ(2.400G + (3*8)*500K))
61
62 U8 Rf_Rec_Buf[RF_DATA_PACKET_SIZE] = {0};
63 U8 Rf_Send_Buf[RF_DATA_PACKET_SIZE] = {0};
64
65 U8 const code HexDispArray[16] = "0123456789ABCDEF";
66
67
68 // 主程序入口
69 void main(void)
70 {
71 1 EA = 0;
72 1 delay_2us(5000);
73 1 ini_mcu();
74 1 delay_2us(5000);
75 1
76 1 ini_lcd();
77 1 delay_2us(50000);
78 1
79 1 lcd_printf_string("COOLWAVE", ROW(0x00)|LEN(0x08)|COL(0x00));
80 1 lcd_printf_string(" A7105 ", ROW(0x01)|LEN(0x08)|COL(0x00));
81 1
82 1 ini_rf();
83 1 ini_rf();
84 1 ini_rf();
85 1
86 1 delay_2us(5000);
87 1
88 1 while(1)
89 1 {
90 2 if(System_Mode)
91 2 {
92 3
93 3 }
94 2 else
95 2 {
96 3 key_scan();
97 3 dispose_key_info();
98 3 if(IE1) // 是否接收到RF數據(查詢方式接收)
99 3 {
100 4 IE1 = 0;
101 4 rec_rf_data();
102 4 dispose_rf_data(); // 處理接收到的RF數據
103 4 }
104 3 dispose_timer0(); // 處理定時器0
105 3 }
106 2 }
107 1 }
108
109 /***********************************************************
110 name: ini_mcu
111 input: none
112 output: none
113 describe: 初始化MCU
114 notice:
115 creat date: 2008-7-24
116 creator: dengyihong
C51 COMPILER V7.06 MAIN 10/29/2008 11:22:40 PAGE 3
117 ************************************************************/
118 void ini_mcu(void)
119 {
120 1 PSW = 0x00;
121 1 PCON = 0x00;
122 1 IP = 0x00; // 設置中斷優先級
123 1 IE = 0x00; // EA - ET2 ES ET1 EX1 ET0 EX0 , disable all interrupt
124 1
125 1 ini_int1();
126 1 ini_timer0();
127 1 }
128
129 /**********************************************************
130 name: ini_int1
131 input: none
132 output: none
133 describe: 設置 int1中斷方式
134 notice:
135 creat date: 2008-7-24
136 creator: dengyihong
137 **********************************************************/
138 void ini_int1(void)
139 {
140 1 IT1 = 1; // 下降沿中斷
141 1 IE1 = 0;
142 1 EX1 = 0; //disable int1 中斷
143 1 }
144
145
146 /***********************************************************
147 name: ini_timer0
148 input: none
149 output: none
150 describe: 初始化定時器0
151 notice:
152 creat date: 2008-7-24
153 creator: dengyihong
154 ************************************************************/
155 void ini_timer0(void)
156 {
157 1 TF0 = 0;
158 1 TH0 = 0x94;
159 1 TL0 = 0x00; // 定時10ms
160 1
161 1 TMOD = 0x01; // timer0 工作在方式1
162 1 // ET0 = 0x01; // 允許timer0中斷
163 1 // TR0 = 1; // enable timer0
164 1 }
165
166
167 /**********************************************************
168 name: dispose_key_info
169 input: none
170 output: none
171 describe: 處理按鍵信息
172 notice:
173 creat date: 2008-7-24
174 creator: dengyihong
175 **********************************************************/
176 void dispose_key_info(void)
177 {
178 1 U8 i = 0;
C51 COMPILER V7.06 MAIN 10/29/2008 11:22:40 PAGE 4
179 1
180 1 if(Key_Msg) // 是否有按鍵消息
181 1 {
182 2 Key_Msg = 0;
183 2 switch(Key_Value)
184 2 {
185 3 case MODE_KEY:
186 3 if(Rf_Mode_Cnt == SEND_KEY)
187 3 {
188 4 Rf_Mode_Cnt = REC_STATUS;
189 4 }
190 3 else
191 3 {
192 4 Rf_Mode_Cnt++;
193 4 }
194 3
195 3 switch(Rf_Mode_Cnt)
196 3 {
197 4 case REC_STATUS:
198 4 lcd_printf_string("Rec ", ROW(0x00)|LEN(0x08)|COL(0x00));
199 4 lcd_printf_string(" Status", ROW(0x01)|LEN(0x08)|COL(0x00));
200 4 A7105_entry_rx();
201 4 break;
202 4
203 4 case SET_RF_RATE:
204 4 lcd_printf_string("Set Rate", ROW(0x00)|LEN(0x08)|COL(0x00));
205 4 display_rf_rate();
206 4 break;
207 4
208 4 case SET_RF_CHANNEL:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -