📄 init_roution.lst
字号:
C51 COMPILER V7.06 INIT_ROUTION 09/11/2008 17:46:03 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE INIT_ROUTION
OBJECT MODULE PLACED IN Init_Roution.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Init_Roution.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include "c8051F330.h"
2 #include "define.h"
3 #include <intrins.h>
4 //#include "define_GLobal.h"
5
6 #ifndef Init_C
7 #define Init_C
8 #endif
9
10 //U8 xdata Test_Data[6];
11
12 //-----------------------------------------------------------------------------
13 // UNIONs, STRUCTUREs, and ENUMs
14 //-----------------------------------------------------------------------------
15 /*typedef union LONG
16 { // byte-addressable LONG
17 long l;
18 unsigned char b[4];
19 } LONG;
20
21 LONG command_LONG;
22
23 typedef union INT
24 { // byte-addressable INT
25 int i;
26 unsigned char b[2];
27 } INT;
28
29 INT temp_INT;
30
31 /*==================================================
32 Name : INT0_Init()
33 Function :
34 ====================================================*/
35 void INT0_Init (void)
36 {
37 1
38 1 }
39
40 /*==================================================
41 Name : INT1_Init()
42 Function :
43 ====================================================*/
44 void INT1_Init (void)
45 {
46 1
47 1 }
48
49 /*==================================================
50 Name : OSCILLATOR_EXTCLK_Init()
51 Function : This routine initializes the system clock to use the external Capacitor Oscillator
52 as its clock source and disables the internal oscillator.
53 ====================================================*/
54 void OSCILLATOR_EXTCLK_init(void)
55 {
C51 COMPILER V7.06 INIT_ROUTION 09/11/2008 17:46:03 PAGE 2
56 1 int i = 0;
57 1
58 1 //Rosc_Input = 0;
59 1 //Rosc_Output = 0;
60 1 P0MDIN &= 0x0f3;
61 1 // OSCICN = 0x00; //switch off internal oscillator
62 1 EA=0;
63 1 OSCXCN = 0x61; // Enalbe etxOscillator 110 crystal 32.768khz
64 1 for (i = 0; i < 3000; i++); // Wait 1ms for initialization
65 1 while ((OSCXCN & 0x80) == 0); // XTLVD
66 1 CLKSEL = 0x01; //switch to external oscillator
67 1 EA=1;
68 1 }
69
70 /*==================================================
71 Name : OSCILLATOR_High_Speed_Init()
72 Function : This function initializes the system clock to high speed
73 ====================================================*/
74 void OSCILLATOR_High_Speed_Init (void)
75 {
76 1 int i = 0;
77 1 //CLKSEL = 0x00; //switch to internal High oscillator
78 1 OSCICN =0x83;// 0x87; // Configure internal oscillator for 24.5M
79 1
80 1 for (i = 0; i < 3000; i++); // Wait 1ms for initialization
81 1 while ((OSCICN & 0x40) == 0);
82 1 }
83
84 /*==================================================
85 Name : OSCILLATOR_Low_Speed_Init()
86 Function :
87 ====================================================*/
88 void OSCILLATOR_Low_Speed_Init (void)
89 {
90 1 int i = 0;
91 1 // OSCLCN=0x83; // 1x000011 hi L_F
92 1 OSCLCN=0xb7; // 1x110111 low L_F 80k
93 1
94 1 for (i = 0; i < 3000; i++); // Wait 1ms for initialization
95 1 while ((OSCLCN & 0x40) == 0);
96 1 }
97
98 /*==================================================
99 Name : Timer2_Init_High_Speed()
100 Function :
101 ====================================================*/
102 void Timer2_Init_High_Speed (void)
103 {
104 1 ; // Start Timer2
105 1 }
106
107
108 /*==================================================
109 Name : Timer2_Init_Low_Speed()
110 Function :
111 ====================================================*/
112 void Timer2_Init_Low_Speed (void)
113 {
114 1 // Start Timer2
115 1 }
116
117 /*==================================================
C51 COMPILER V7.06 INIT_ROUTION 09/11/2008 17:46:03 PAGE 3
118 Name : Change_to_High_Speed_Mode()
119 Function :
120 ====================================================*/
121 void Change_to_High_Speed_Mode(void)
122 {
123 1 EA=0;
124 1 OSCILLATOR_High_Speed_Init();
125 1 CLKSEL=0x00;
126 1 Timer2_Init_High_Speed();
127 1 EA=1;
128 1 }
129
130 /*==================================================
131 Name : Change_to_High_Speed_Mode()
132 Function :
133 ====================================================*/
134 void Change_to_Low_Speed_Mode(void)
135 {
136 1 EA=0;
137 1 // OSCILLATOR_Low_Speed_Init();
138 1 CLKSEL=0x02;
139 1 Timer2_Init_Low_Speed();
140 1 EA=1;
141 1 }
142
143 /*==================================================
144 Name : PORT_Init()
145 Function : This function configures the crossbar and GPIO ports.
146 ====================================================*/
147
148 void PORT_Init (void)
149 {
150 1 P0MDIN = 0xf2; //11110010B,内部VREF输出,0是配置成模拟输入//P0MDIN = 0x38;P0.1,P0.2 and P0.6 are configure
-d as ADC0 input ports.p0.0被用作REF 00111000B,
151 1 P1MDIN = 0x0ff;
152 1
153 1 P0MDOUT= 0xcd; //11001101B,0是漏极开路输出,1是推挽 //P0MDOUT= 0xff;Force P0.1,P0.2 to be push-pull 100
-00110B
154 1 // P1MDOUT= 0xad; //all input ports 10101101
155 1 P1MDOUT= 0xfb; //p1.2漏极开路输出// 11111011
156 1
157 1 P0SKIP = 0xff;//00001101B,0是不被跳过,1要跳过//P0SKIP = 0xcf;(01100111B) Should be skipped by the Digita
-l Crossbar. p0.0被用作REF
158 1 P1SKIP = 0xff; //P1.1-P1.7 are configured as ADC0 input ports. (11111111B)Should be skipped by the
-Digital Crossbar.
159 1
160 1
161 1 XBR0 = 0x00;//XBR0 = 0x01; enable UART,SPI,内部VREF
162 1 XBR1 = 0x40; // Enable crossbar, enable weak pull-ups,
163 1 }
164
165
166
167
168
169 /*==================================================
170 Name : Timer1_Init()
171 Function :
172 ====================================================*/
173 void Timer1_Init()
174 {
175 1 // TCON = 0x40;
C51 COMPILER V7.06 INIT_ROUTION 09/11/2008 17:46:03 PAGE 4
176 1 TMOD = 0x10; // TMOD: timer 1, mode 1 16-bit
177 1 CKCON |= 0x01; // Timer0/Timer1 clocked based on SYSCLK/4;
178 1 //TH1 = 161;
179 1 //TH1=0xE8;
180 1 //TL1=0x12;
181 1 TH1=0xFF;
182 1 TL1=0xF0;
183 1 STOP_TIMER1; // start Timer1
184 1 //START_TIMER1;
185 1 ET1 = 1; // enable Timer 1 as interrupt source
186 1 }
187 /*==================================================
188 Name : init_adc()
189 Function :
190 ====================================================*/
191 void init_adc(void)
192 {
193 1 ;
194 1 }
195 /*=================================================
196 Name : Variable_Init()
197 Function :
198 ==================================================*/
199 void Variable_Init()
200 {
201 1 Temp=0;
202 1 Press=0;
203 1 Altitude=0;
204 1 C1=0;
205 1 C2=0;
206 1 C3=0;
207 1 C4=0;
208 1 C5=0;
209 1 C6=0;
210 1 C7=0;
211 1 AA=0;
212 1 BB=0;
213 1 CC=0;
214 1 DD=0;
215 1
216 1 D1=0;
217 1 D2=0;
218 1
219 1 DUT=0;
220 1 OFF=0;
221 1 SENS=0;
222 1 X=0;
223 1
224 1 }
225
226 /*==================================================
227 Name : UART0_Init()
228 Function : Configure the UART0 using Timer1, for <baudrate> and 8-N-1.
229 ====================================================*/
230 void UART0_Init (void)
231 {
232 1 ;
233 1 }
234
235 /*=================================================
236 Name : Get_Data_FromFlashMemory()
237 Function : Get 1.ID_CODE
C51 COMPILER V7.06 INIT_ROUTION 09/11/2008 17:46:03 PAGE 5
238 2.CalPoint1KWH
239 3.CalPoint1AD
240 4.CalPoint2KWH
241 5.CalPoint2AD
242 ==================================================*/
243 void Get_Data_FromFlashMemory(void)
244 {
245 1 ;
246 1 }
247 /*=================================================
248 Name : System_Init()
249 Function :
250 ==================================================*/
251 void System_Init(void)
252 {
253 1
254 1 // Temp_Reset=RSTSRC;
255 1
256 1 PCA0MD &= ~0x40; //WDT定时器禁止
257 1 PCON=0x00;
258 1 Variable_Init();
259 1 // OSCILLATOR_EXTCLK_init();
260 1 Change_to_High_Speed_Mode();
261 1 //OSCILLATOR_Low_Speed_Init();
262 1
263 1 INT0_Init();
264 1 INT1_Init ();
265 1
266 1 PORT_Init (); // Initialize ports for normal operation
267 1
268 1 init_adc(); // Initialize ADC0
269 1 Timer1_Init();
270 1 UART0_Init ();
271 1
272 1 // Select_Plug(Plug_2);
273 1 Get_Data_FromFlashMemory();
274 1 // Calculate_Unit();
275 1
276 1 }
277
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 336 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -