📄 flash.lst
字号:
C51 COMPILER V7.02b FLASH 06/20/2006 18:46:35 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE FLASH
OBJECT MODULE PLACED IN flash.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE flash.c DEBUG OBJECTEXTEND
stmt level source
1 /*---------------------------------------------------*/
2 /* Flash 操作程序
3
4 Description: 本程序最主要是读写/扇区搽除/片搽除,以及主要的调用程序
5 源程序时使用AMD 公司s29gl032m,现在修改为sst公司sst36vf03203
6 这样,需要增加扇区搽除,以及修改存储流程
7 */
8 /*--------------------------------------------------*/
9 /*-------------------------------------------------*/
10 #include "defineh.h"
11 #include "flash.h"
12 #include "sbitdef.h" //test
13 /*-------------------------------------------------*/
14 extern uchar Dec_Cem(uchar dec_data);
15 extern void delay();
16 extern void Clr_Rx();
17 extern void init_timer2();
18 extern void clr_timer2();
19
20
21 extern uchar idata Tx_buffer[16]; //test
22 extern void txstart();
23 extern void delays60ms();
24
25 /*------------------------------------------------*/
26 void Chip_Erase_Op()
27 {
28 1 uchar xdata *mm;
29 1 AUXR=0x03;
30 1 P1=0;
31 1
32 1 mm=0xaaa;
33 1 *mm=0xaa;
34 1 mm=0x555;
35 1 *mm=0x55;
36 1 mm=0xaaa;
37 1 *mm=0x80;
38 1
39 1 mm=0xaaa;
40 1 *mm=0xaa;
41 1 mm=0x555;
42 1 *mm=0x55;
43 1 mm=0xaaa;
44 1 *mm=0x10;
45 1
46 1 delay();
47 1 delay();
48 1 AUXR=0x00;
49 1 }
50 /*---------------------------------------------*/
51 void Sector_Erase_Op(ulong write_address)
52 {
53 1 ulong data temp;
54 1 uchar data i;
55 1 uchar xdata *mm;
C51 COMPILER V7.02b FLASH 06/20/2006 18:46:35 PAGE 2
56 1
57 1 temp=write_address;
58 1 AUXR=0x03;
59 1 i=(uchar)(temp>>16);
60 1 P1=i;
61 1
62 1 mm=0xaaa;
63 1 *mm=0xaa;
64 1 mm=0x555;
65 1 *mm=0x55;
66 1 mm=0xaaa;
67 1 *mm=0x80;
68 1
69 1 mm=0xaaa;
70 1 *mm=0xaa;
71 1 mm=0x555;
72 1 *mm=0x55;
73 1 mm=(uint)(temp);
74 1 *mm=Flash_Write; //if 36vf3202,=0x50
75 1
76 1 delay(); //>18ms
77 1
78 1 AUXR=0x00;
79 1 }
80 /*-------------------------------------------------*/
81 /* Rwad Message Group
82
83 DESCRIPTION:
84 读取信息的编号,需要带页地址来
85 每一次读出8字节
86
87 */
88 /*-----------------------------------------------------*/
89 void Page_Read_Op()
90 {
91 1 uchar data i;
92 1 uint data j;
93 1 uchar xdata *mm;
94 1
95 1 i=(uchar)(read_block>>16);
96 1 P1=i;
97 1 j=(uint)(read_block);
98 1 AUXR=0x03;
99 1
100 1 for(i=0;i<18;i++)
101 1 {
102 2 mm=j+i;
103 2 message_group[i]=*mm;
104 2 }
105 1 AUXR=0;
106 1 }
107 /*---------------------------------------------*/
108 /*
109 根据偏移位置和目前编号,保存在地址write_block
110 注意寄存器 write_block,infonumber
111
112 */
113 /*--------------------------------------------*/
114 void save_infomessage()
115 {
116 1 ulong data y;
117 1 uint data k;
C51 COMPILER V7.02b FLASH 06/20/2006 18:46:35 PAGE 3
118 1 uchar data i,j;
119 1 uchar xdata *mm;
120 1
121 1 y=write_block;
122 1 AUXR=0x03;
123 1 i=(uchar)(y>>16);
124 1 P1=i; //a15---a22 had out from p1
125 1 y=write_block;
126 1 k=(uint)(y);
127 1
128 1 EA=0;
129 1 for(j=0;j<(infonumber+1);j++)
130 1 {
131 2 mm=0xaaa;
132 2 *mm=0xaa; //program step 1
133 2 mm=0x555;
134 2 *mm=0x55; //program step 2
135 2 mm=0xaaa;
136 2 *mm=0xa0; //program step 3 ,not 0x80????test
137 2
138 2
139 2 mm=k+j;
140 2 if(j==0)
141 2 {
142 3 *mm=message_group[offset_smallest];
143 3 }
144 2 else
145 2 {
146 3 AUXR=0X00;
147 3 i=*(info_buffer+4+j);
148 3 AUXR=0X03;
149 3 *mm=i;
150 3 }
151 2 }
152 1 delay();
153 1 AUXR=0X00;
154 1 EA=1;
155 1 }
156 /*-------------------------------------*/
157 /* 把使用区域的除最旧区域以外信息复制到count_copy指定的区域
158 首先确定被复制的区域地址,由read_block决定
159 */
160 /*----------------------------------*/
161 void Copy_Message()
162 {
163 1 uchar data i,j,m,k;
164 1 uchar xdata *mm;
165 1
166 1
167 1 EA=0;
168 1 AUXR=0X03;
169 1 if((offset_smallest!=0)&&(offset_smallest!=15)) //最小的信息在中间
170 1 {
171 2 for(k=0;k<offset_smallest;k++)
172 2 {
173 3 mm=read_block+k*0x100+1;
174 3 m=*mm;
175 3 for(j=0;j<(m+1);j++)
176 3 {
177 4 mm=read_block+k*0x100+j;
178 4 i=*mm;
179 4 //writing to the new zone a byte
C51 COMPILER V7.02b FLASH 06/20/2006 18:46:35 PAGE 4
180 4 mm=0x0aaa;
181 4 *mm=0xaa; //step 1
182 4 mm=0x0555;
183 4 *mm=0x55; //step 2
184 4 mm=0x0aaa;
185 4 *mm=0xa0; //step 3
186 4 mm=0x10000+count_copy*0x1000+k*0x100+j;
187 4 *mm=i;
188 4 }
189 3 }
190 2
191 2 for(k=(offset_smallest+1);k<16;k++)
192 2 {
193 3 mm=read_block+k*0x100+1;
194 3 m=*mm;
195 3 for(j=0;j<(m+1);j++)
196 3 {
197 4 mm=read_block+k*0x100+j;
198 4 i=*mm;
199 4 //writing to the new zone a byte
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -