📄 main.lst
字号:
190 1
191 1 /// ---------------------------------------------------------------------
192 1 /// Initialization of the SYSCON0 Register:
193 1 /// ---------------------------------------------------------------------
194 1
195 1 //// this register must be set in the start-up file
196 1 //// SYSCON0 = 0x0000
197 1
198 1 /// ---------------------------------------------------------------------
199 1 /// Initialization of the SYSCON1 Register:
200 1 /// ---------------------------------------------------------------------
201 1 /// clock prescaler for system is fpll / 1
202 1
203 1 //// this register must be set in the start-up file
204 1 //// SYSCON1 = 0x0000
205 1
206 1 /// ---------------------------------------------------------------------
207 1 /// Initialization of the SYSCON3 Register:
208 1 /// ---------------------------------------------------------------------
209 1
210 1 //// this register must be set in the start-up file
211 1 //// SYSCON3 = 0x0000
212 1
213 1 /// ---------------------------------------------------------------------
214 1 /// Initialization of EBC
215 1 /// ---------------------------------------------------------------------
216 1
217 1 //// this register must be set in the start-up file
218 1 //// EBCMOD1 = 0x007F
219 1
220 1 /// EBC is disabled
221 1 //// -----------------------------------------------------------------------
222 1 //// End of Important Settings for the Start-Up File
223 1 //// -----------------------------------------------------------------------
224 1
225 1
226 1 // -----------------------------------------------------------------------
227 1 // Initialization of the Peripherals:
228 1 // -----------------------------------------------------------------------
229 1
230 1 // initializes the Parallel Ports
231 1 IO_vInit();
232 1
233 1 // initializes the High-Speed Synchronous Serial Interface 0 (SSC0)
234 1 SSC0_vInit();
235 1
236 1 // USER CODE BEGIN (Init,3)
237 1
238 1 // USER CODE END
239 1
240 1 // globally enable interrupts
241 1 PSW_IEN = 1;
C166 COMPILER V6.04, MAIN 09/08/2007 15:46:24 PAGE 5
242 1
243 1 } // End of function MAIN_vInit
244
245
246 //****************************************************************************
247 // @Function void MAIN_vUnlockProtecReg(void)
248 //
249 //----------------------------------------------------------------------------
250 // @Description This function makes it possible to write one protected
251 // register. After calling of this function and write on the
252 // protected register is the security level set to low
253 // protected mode.
254 //
255 //----------------------------------------------------------------------------
256 // @Returnvalue None
257 //
258 //----------------------------------------------------------------------------
259 // @Parameters None
260 //
261 //----------------------------------------------------------------------------
262 // @Date 2007-5-25
263 //
264 //****************************************************************************
265
266 // USER CODE BEGIN (UnlockProtecReg,1)
267
268 // USER CODE END
269
270 void MAIN_vUnlockProtecReg(void)
271 {
272 1 uword ubPASSWORD;
273 1
274 1 if((SCUSLS & 0x1800) == 0x0800) // if low protected mode
275 1 {
276 2
277 2 ubPASSWORD = SCUSLS & 0x00FF;
278 2 ubPASSWORD = ~ubPASSWORD;
279 2 SCUSLC = 0x8E00 | ubPASSWORD; // command 4
280 2
281 2 } // end if low protected mode
282 1
283 1 if((SCUSLS & 0x1800) == 0x1800) // if write protected mode
284 1 {
285 2 SCUSLC = 0xAAAA; // command 0
286 2 SCUSLC = 0x5554; // command 1
287 2
288 2 ubPASSWORD = SCUSLS & 0x00FF;
289 2 ubPASSWORD = ~ubPASSWORD;
290 2
291 2 SCUSLC = 0x9600 | ubPASSWORD; // command 2
292 2 SCUSLC = 0x0800; // command 3; new PASSWOR is 0x00
293 2
294 2 ubPASSWORD = SCUSLS & 0x00FF;
295 2 ubPASSWORD = ~ubPASSWORD;
296 2 SCUSLC = 0x8E00 | ubPASSWORD; // command 4
297 2
298 2 } // end if write protected mode
299 1
300 1 } // End of function MAIN_vUnlockProtecReg
301
302
303 //****************************************************************************
C166 COMPILER V6.04, MAIN 09/08/2007 15:46:24 PAGE 6
304 // @Function void main(void)
305 //
306 //----------------------------------------------------------------------------
307 // @Description This is the main function.
308 //
309 //----------------------------------------------------------------------------
310 // @Returnvalue None
311 //
312 //----------------------------------------------------------------------------
313 // @Parameters None
314 //
315 //----------------------------------------------------------------------------
316 // @Date 2007-5-25
317 //
318 //****************************************************************************
319
320 // USER CODE BEGIN (Main,1)
321
322 // USER CODE END
323
324 void main(void)
325 {
326 1 // USER CODE BEGIN (Main,2)
327 1
328 1 // USER CODE END
329 1
330 1 MAIN_vInit();
331 1
332 1 // USER CODE BEGIN (Main,4)
333 1
334 1 Write_Enable(); //写使能X5043
335 1 Read_Status(); //读X5043状态寄存器;这步是必需的
336 1 _nop_();
337 1 _nop_();
338 1 _nop_();
339 1 Write_Data(0x02,0xAA); //向X5043的地址0x02,写入数据
340 1 while(Read_Status()&0x0001); //指示X5043正在烧写数据
341 1 P1L = Read_Data(0x02); //从X5043的地址0x02读取数据,并通过P1L显示读取的数据
342 1
343 1 /*
344 1 Write_Enable(); //写使能X5043
345 1 Read_Status(); //读X5043状态寄存器;这步是必需的
346 1 _nop_();
347 1 _nop_();
348 1 _nop_();
349 1 Write_Data_Page(0x02,5,&Test[0]); //向X5043的地址0x02,写入数据
350 1 while(Read_Status()&0x0001); //指示X5043正在烧写数据
351 1 P1L = Read_Data_Page(0x02,5); //从X5043的地址0x02读取数据,并通过P1L显示读取的数据
352 1 */
353 1 while(1);
354 1
355 1 // USER CODE END
356 1
357 1 } // End of function main
358
359
360
361 // USER CODE BEGIN (MAIN_General,10)
362
363 // USER CODE END
364
C166 COMPILER V6.04, MAIN 09/08/2007 15:46:24 PAGE 7
MODULE INFORMATION: INITIALIZED UNINITIALIZED
CODE SIZE = 206 --------
NEAR-CONST SIZE = -------- --------
FAR-CONST SIZE = -------- --------
HUGE-CONST SIZE = -------- --------
XHUGE-CONST SIZE = -------- --------
NEAR-DATA SIZE = 6 --------
FAR-DATA SIZE = -------- --------
XHUGE-DATA SIZE = -------- --------
IDATA-DATA SIZE = -------- --------
SDATA-DATA SIZE = -------- --------
BDATA-DATA SIZE = -------- --------
HUGE-DATA SIZE = -------- --------
BIT SIZE = -------- --------
INIT'L SIZE = 10 --------
END OF MODULE INFORMATION.
C166 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -