📄 inflash.lst
字号:
C51 COMPILER V7.05 INFLASH 08/27/2006 23:31:34 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE INFLASH
OBJECT MODULE PLACED IN InFLASH.OBJ
COMPILER INVOKED BY: D:\SilabIDE\IDEfiles\C51\BIN\C51.exe InFLASH.c DB OE
stmt level source
*** WARNING C500 IN LINE 1 OF INFLASH.C: MISSING DEVICE (SECURITY KEY NOT FOUND)
1 /****************************************************************************
2 **
3 ** 文件名: InFLASH.c
4 ** 功能: C8051Fxxx的片内FLASH读写驱动;
5 ** 创建时间:2005.08.05
6
7 ** 修改时间:2005.12.01
8 ** 修改说明:
9
10 ** 作者: 李立学
11 ** 版权申明:可以拷贝,可以修改,但必须保留修改时间和作者信息
12 **
13 ****************************************************************************/
14
15
16 #include "LZK.H"
*** ERROR C141 IN LINE 73 OF LZK.H: syntax error near '/', expected '='
*** ERROR C202 IN LINE 73 OF LZK.H: 'R0': undefined identifier
17
18
19 uint16 xdata *InFlashWrPtr;
20 uint16 code *InFlashRdPtr;
21
22 /****************************************************************************
23 ** 函数名称: InFlash_Init()
24 ** 功能描述: 内部FLASH初始化.
25 ** 入口参数: InFlashAddr:要初始化的FLASH块首地址;
26 ** 出口参数: bit:0/1:操作失败/成功.
27 ** 全局变量: 无
28 ** 调用模块: 无
29 ** 说明:
30 ****************************************************************************/
31 bit InFlash_Init( uint16 InFlashAddr )
32 {
33 1 if( ( InFlashAddr % 0x200 ) != 0 ) // Must a Block Start Address.
34 1 return 0; // Fail.
35 1 //FLSCL: FLASH Memory Control
36 1 // Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
37 1 // FOSE FRAE Res Res Res Res Res FLWE
38 1 //Bit7: FOSE: FLASH One-Shot Timer Enable This isth e timer that turnso ff the sense ampsaf ter a FLASH r
-ead.
39 1 // 0: FLASH One-Shot Timer disabled.
40 1 // 1: FLASH One-Shot Timer enabled (recommended setting.)
41 1 //Bit6: FRAE: FLASH Read AlwaysE nable
42 1 // 0: FLASH readso ccur asn ecessary (recommended setting.).
43 1 // 1: FLASH reads occur every system clock cycle.
44 1 //Bits5-1: RESERVED. Read = 00000b. Must Write 00000b.
45 1 //Bit0: FLWE: FLASH Read/Write Enable This bit must be set to allow FLASH writes from user software.
46 1 // 0: FLASH writesd isabled.
47 1 // 1: FLASH writesen abled.
48 1
49 1 //PSCTL: Program Store Read/Write Control
50 1 // Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
51 1 // - - - - - SFLE PSEE PSWE
C51 COMPILER V7.05 INFLASH 08/27/2006 23:31:34 PAGE 2
52 1 //Bits7-3: UNUSED. Read = 00000b, Write = don't care.
53 1 //Bit2: SFLE: Scratchpad FLASH Memory Access Enable When thisb it iss et, FLASH reads and writesfro m us
-er software are directed to the 128-byte Scratchpad
54 1 // FLASH sector. When SFLE is set to logic 1, FLASH accesses out of the address range 0x00-0x7F
- should not be attempted. Reads/Writes out of this range will yield undefined results.
55 1 // 0: FLASH access from user software directed to the 64k byte Program/Data FLASH sector.
56 1 // 1: FLASH access from user software directed to the 128 byte Scratchpad sector.
57 1 //Bit1: PSEE: Program Store Erase Enable. Setting thisb it allowsan entire page of the FLASH program memo
-ry to be erased provided thePSWE bit is also set.
58 1 // After setting this bit, a write to FLASH memory using the MOVX instruction will erase the en
-tire page that contains the location addressed by the MOVX instruction.
59 1 // The value of the data byte written doesn ot matter. Note: The FLASH page containing the Read
- Lock Byte and Write/Erase Lock Bytes cannot be erased by software.
60 1 // 0: FLASH program memory erasure disabled.
61 1 // 1: FLASH program memory erasure enabled.
62 1 //Bit0: PSWE: Program Store Write Enable. Setting thisb it allowswr iting a byte of data to the FLASH pr
-ogram memory using the MOVX write instruction. The location must be erased prior to writing data.
63 1 // 0: Write to FLASH program memory disabled. MOVX write operations target External RAM.
64 1 // 1: Write to FLASH program memory enabled. MOVX write operationst arget FLASH memory.
65 1
66 1 SFRPAGE = 0x00;
67 1
68 1 FLSCL = 0x81;
69 1 PSCTL = 0x03;
70 1
71 1 InFlashWrPtr = InFlashAddr;
72 1 *InFlashWrPtr = 0;
73 1
74 1 PSCTL = 0x01;
75 1 return 1;
76 1 }
77
78 /****************************************************************************
79 ** 函数名称: InFlashWriteEn()
80 ** 功能描述: 内部FLASH写使能.
81 ** 入口参数: InFwEN:1:允许写入;
82 ** 出口参数: 无.
83 ** 全局变量: 无
84 ** 调用模块: 无
85 ** 说明:
86 ****************************************************************************/
87 void InFlashWriteEn(bit InFwEN)
88 {
89 1 SFRPAGE = 0x00;
90 1
91 1 if( InFwEN == 1 )
92 1 FLSCL = FLSCL | 0x01;
93 1 else
94 1 FLSCL = FLSCL & 0xfe;
95 1 }
96
97 /****************************************************************************
98 ** 函数名称: InFlashEraseEn()
99 ** 功能描述: 内部FLASH块擦除使能.
100 ** 入口参数: InFeEN:1:允许块擦除;
101 ** 出口参数: 无.
102 ** 全局变量: 无.
103 ** 调用模块: 无.
104 ** 说明:
105 ****************************************************************************/
106 void InFlashEraseEn(bit InFeEN)
107 {
C51 COMPILER V7.05 INFLASH 08/27/2006 23:31:34 PAGE 3
108 1 SFRPAGE = 0x00;
109 1
110 1 if( InFeEN == 1 )
111 1 PSCTL = PSCTL | 0x02;
112 1 else
113 1 PSCTL = PSCTL & 0xfd;
114 1 }
C51 COMPILATION COMPLETE. 1 WARNING(S), 2 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -