📄 at45db041d.s
字号:
xcall _SPI_Write_Byte
.dbline 502
; SPI_Write_Byte((unsigned char)(PA<<1));
mov R16,R10
lsl R16
rol R17
xcall _SPI_Write_Byte
.dbline 503
; SPI_Write_Byte(0xFF); //8 don't care bits
ldi R16,255
xcall _SPI_Write_Byte
.dbline 505
;
; Disable_DFLASH();
xcall _Disable_DFLASH
.dbline -2
L138:
.dbline 0 ; func end
xjmp pop_xgset300C
.dbsym r PA 10 i
.dbsym r BufferX 20 c
.dbend
.dbfunc e Main_Memory_Page_Program_Through_Buffer _Main_Memory_Page_Program_Through_Buffer fV
; i -> R10
; DataLen -> y+10
; wData -> y+8
; BA -> R10
; PA -> R12,R13
; BufferX -> R20
.even
_Main_Memory_Page_Program_Through_Buffer::
xcall push_xgset303C
movw R12,R18
mov R20,R16
ldd R10,y+6
.dbline -1
.dbline 519
; }
; /************************************************************
; *将数据写到内存中(自动先写到BUFFER1 OR BURRER2中再将数据写到内存中)
; *BufferX :选择自动先写入的缓冲器(Buffer1或Buffer2)
; *PA :内存中的页地址0~2047
; *BA :从页中的这个地址开始写数据,会自动转到下一页(0~263)
; *当写到最后一页的最后一个地址时,会自动转到第一页开始写
; *wData :要写入的数据
; *DataLen :要写入的数据长度
; ************************************************************/
; void Main_Memory_Page_Program_Through_Buffer(unsigned char BufferX,
; unsigned int PA,unsigned char BA,
; unsigned char *wData,unsigned int DataLen)
; {
.dbline 521
; unsigned char i;
; DF_Check_Busy_State();
xcall _DF_Check_Busy_State
.dbline 522
; Enable_DFLASH();
xcall _Enable_DFLASH
.dbline 524
;
; if(BufferX == Buffer1) SPI_Write_Byte(Main_Memory_Page_Program_Through_Buffer1);//0x82
cpi R20,1
brne L142
X31:
.dbline 524
ldi R16,130
xcall _SPI_Write_Byte
xjmp L143
L142:
.dbline 525
; else SPI_Write_Byte(Main_Memory_Page_Program_Through_Buffer2);//0x85
ldi R16,133
xcall _SPI_Write_Byte
L143:
.dbline 528
;
; //4 bits(don't care bits) + 11 bits(page address)+9(address in the page)
; SPI_Write_Byte((unsigned char)(PA>>7));
ldi R18,7
ldi R19,0
movw R16,R12
xcall lsr16
xcall _SPI_Write_Byte
.dbline 529
; SPI_Write_Byte((unsigned char)((PA<<1)|(BA>>8)));
mov R2,R10
clr R3
mov R2,R3
clr R3
sbrc R2,7
com R3
mov R16,R12
lsl R16
rol R17
or R16,R2
or R17,R3
xcall _SPI_Write_Byte
.dbline 530
; SPI_Write_Byte((unsigned char)BA);
mov R16,R10
xcall _SPI_Write_Byte
.dbline 532
;
; for(i=0;i<DataLen;i++) SPI_Write_Byte(wData[i]);
clr R10
xjmp L147
L144:
.dbline 532
mov R30,R10
clr R31
ldd R0,y+8
ldd R1,y+9
add R30,R0
adc R31,R1
ldd R16,z+0
xcall _SPI_Write_Byte
L145:
.dbline 532
inc R10
L147:
.dbline 532
mov R2,R10
clr R3
ldd R0,y+10
ldd R1,y+11
cp R2,R0
cpc R3,R1
brlo L144
X32:
.dbline 534
;
; Disable_DFLASH();
xcall _Disable_DFLASH
.dbline -2
L141:
.dbline 0 ; func end
xjmp pop_xgset303C
.dbsym r i 10 c
.dbsym l DataLen 10 i
.dbsym l wData 8 pc
.dbsym r BA 10 c
.dbsym r PA 12 i
.dbsym r BufferX 20 c
.dbend
.dbfunc e DF_Main_Memory_Page_Read _DF_Main_Memory_Page_Read fV
; i -> R20
; DataLen -> y+8
; rData -> y+6
; BA -> R10
; PA -> R12,R13
.even
_DF_Main_Memory_Page_Read::
xcall push_xgset303C
mov R10,R18
movw R12,R16
.dbline -1
.dbline 547
; }
; /************************************************************
; *从内存中读取数据到数组rData中(直接读取数据不经过BUFFER1 OR BURRER2)
; *PA :内存中的页地址0~2047
; *BA :从页中的这个地址开始读数据,会自动转到下一页(0~263)
; *当读到最后一页的最后一个地址时,会自动转到第一页开始读取
; *rData :存放读到的数据
; *DataLen :要读取的数据长度
; *与DF_Continuous_Array_Read一样的功能但与Buffer有关,但不改变Buffer中的数据
; ************************************************************/
; void DF_Main_Memory_Page_Read(unsigned int PA,unsigned char BA,
; unsigned char *rData,unsigned int DataLen)
; {
.dbline 549
; unsigned char i;
; DF_Check_Busy_State();
xcall _DF_Check_Busy_State
.dbline 551
;
; Enable_DFLASH();
xcall _Enable_DFLASH
.dbline 553
;
; SPI_Write_Byte(Main_Memory_Page_Read_Command);//0xD2
ldi R16,210
xcall _SPI_Write_Byte
.dbline 556
;
; //4 bits(don't care bits) + 11 bits(page address)+9(address in the page)
; SPI_Write_Byte((unsigned char)(PA>>7));
ldi R18,7
ldi R19,0
movw R16,R12
xcall lsr16
xcall _SPI_Write_Byte
.dbline 557
; SPI_Write_Byte((unsigned char)((PA<<1)|(BA>>8)));
mov R2,R10
clr R3
mov R2,R3
clr R3
sbrc R2,7
com R3
mov R16,R12
lsl R16
rol R17
or R16,R2
or R17,R3
xcall _SPI_Write_Byte
.dbline 558
; SPI_Write_Byte((unsigned char)BA);
mov R16,R10
xcall _SPI_Write_Byte
.dbline 560
; //4 don’t care bytes
; for(i=0;i<4;i++) SPI_Write_Byte(0xFF);
clr R20
xjmp L152
L149:
.dbline 560
ldi R16,255
xcall _SPI_Write_Byte
L150:
.dbline 560
inc R20
L152:
.dbline 560
cpi R20,4
brlo L149
X33:
.dbline 562
;
; for(i=0;i<DataLen;i++) rData[i] = SPI_Read_Byte(0xFF);//读取数据
clr R20
xjmp L156
L153:
.dbline 562
ldi R16,255
xcall _SPI_Read_Byte
mov R30,R20
clr R31
ldd R0,y+6
ldd R1,y+7
add R30,R0
adc R31,R1
std z+0,R16
L154:
.dbline 562
inc R20
L156:
.dbline 562
mov R2,R20
clr R3
ldd R0,y+8
ldd R1,y+9
cp R2,R0
cpc R3,R1
brlo L153
X34:
.dbline 564
;
; Disable_DFLASH();
xcall _Disable_DFLASH
.dbline -2
L148:
.dbline 0 ; func end
xjmp pop_xgset303C
.dbsym r i 20 c
.dbsym l DataLen 8 i
.dbsym l rData 6 pc
.dbsym r BA 10 c
.dbsym r PA 12 i
.dbend
.dbfunc e DF_Continuous_Array_Read _DF_Continuous_Array_Read fV
; i -> R20
; DataLen -> y+8
; rData -> y+6
; BA -> R10
; PA -> R12,R13
.even
_DF_Continuous_Array_Read::
xcall push_xgset303C
mov R10,R18
movw R12,R16
.dbline -1
.dbline 577
; }
; /************************************************************
; *从内存中读取数据到数组rData中(直接读取数据不经过BUFFER1 OR BURRER2)
; *PA :内存中的页地址0~2047
; *BA :从页中的这个地址开始读数据,会自动转到下一页(0~263)
; *当读到最后一页的最后一个地址时,会自动转到第一页开始读取
; *rData :存放读到的数据
; *DataLen :要读取的数据长度
; *与DF_Main_Memory_Page_Read一样的功能但与Buffer无关
; ************************************************************/
; void DF_Continuous_Array_Read(unsigned int PA,unsigned char BA,
; unsigned char *rData,unsigned int DataLen)
; {
.dbline 579
; unsigned char i;
; DF_Check_Busy_State();
xcall _DF_Check_Busy_State
.dbline 581
;
; Enable_DFLASH();
xcall _Enable_DFLASH
.dbline 583
;
; SPI_Write_Byte(Continuous_Array_Read_Command);//0xE8
ldi R16,232
xcall _SPI_Write_Byte
.dbline 586
;
; //4 bits(don't care bits) + 11 bits(page address)+9(address in the page)
; SPI_Write_Byte((unsigned char)(PA>>7));
ldi R18,7
ldi R19,0
movw R16,R12
xcall lsr16
xcall _SPI_Write_Byte
.dbline 587
; SPI_Write_Byte((unsigned char)((PA<<1)|(BA>>8)));
mov R2,R10
clr R3
mov R2,R3
clr R3
sbrc R2,7
com R3
mov R16,R12
lsl R16
rol R17
or R16,R2
or R17,R3
xcall _SPI_Write_Byte
.dbline 588
; SPI_Write_Byte((unsigned char)BA);
mov R16,R10
xcall _SPI_Write_Byte
.dbline 590
; //4 don’t care bytes
; for(i=0;i<4;i++) SPI_Write_Byte(0xFF);
clr R20
xjmp L161
L158:
.dbline 590
ldi R16,255
xcall _SPI_Write_Byte
L159:
.dbline 590
inc R20
L161:
.dbline 590
cpi R20,4
brlo L158
X35:
.dbline 592
;
; for(i=0;i<DataLen;i++) rData[i] = SPI_Read_Byte(0xFF);//读取数据
clr R20
xjmp L165
L162:
.dbline 592
ldi R16,255
xcall _SPI_Read_Byte
mov R30,R20
clr R31
ldd R0,y+6
ldd R1,y+7
add R30,R0
adc R31,R1
std z+0,R16
L163:
.dbline 592
inc R20
L165:
.dbline 592
mov R2,R20
clr R3
ldd R0,y+8
ldd R1,y+9
cp R2,R0
cpc R3,R1
brlo L162
X36:
.dbline 594
;
; Disable_DFLASH();
xcall _Disable_DFLASH
.dbline -2
L157:
.dbline 0 ; func end
xjmp pop_xgset303C
.dbsym r i 20 c
.dbsym l DataLen 8 i
.dbsym l rData 6 pc
.dbsym r BA 10 c
.dbsym r PA 12 i
.dbend
.area lit(rom, con, rel)
L167:
.byte 199,148
.byte 128,154
.area text(rom, con, rel)
.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
.dbfunc e DF_Chip_Erase _DF_Chip_Erase fV
; Chip_Erase_Command -> y+0
; i -> R20
.even
_DF_Chip_Erase::
st -y,R20
sbiw R28,4
.dbline -1
.dbline 601
; }
; /************************************************************
; *擦除FLASH全部内容
; *not affect sectors that are protected or locked down
; ************************************************************/
; void DF_Chip_Erase(void)
; {
.dbline 602
; unsigned char Chip_Erase_Command[4]={0xC7,0x94,0x80,0x9A};//整片擦除操作码
ldi R24,<L167
ldi R25,>L167
movw R30,R28
ldi R16,4
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
xcall asgncblk
.dbline 605
; unsigned char i;
;
; DF_Check_Busy_State();
xcall _DF_Check_Busy_State
.dbline 606
; Enable_DFLASH();
xcall _Enable_DFLASH
.dbline 608
;
; for(i=0;i<4;i++)
clr R20
xjmp L171
L168:
.dbline 609
; {
.dbline 610
; SPI_Write_Byte(Chip_Erase_Command[i]);
movw R24,R28
mov R30,R20
clr R31
add R30,R24
adc R31,R25
ldd R16,z+0
xcall _SPI_Write_Byte
.dbline 611
; }
L169:
.dbline 608
inc R20
L171:
.dbline 608
cpi R20,4
brlo L168
X37:
.dbline 613
;
; Disable_DFLASH();
xcall _Disable_DFLASH
.dbline -2
L166:
.dbline 0 ; func end
adiw R28,4
ld R20,y+
ret
.dbsym l Chip_Erase_Command 0 A[4:4]c
.dbsym r i 20 c
.dbend
.dbfunc e DataFlash_Init _DataFlash_Init fV
.even
_DataFlash_Init::
.dbline -1
.dbline 619
; }
; /************************************************************
; *DataFlash初始化(其实是初始化驱动FLASH用到的SPI)
; ************************************************************/
; void DataFlash_Init(void)
; {
.dbline 620
; SPI_Init();
xcall _SPI_Init
.dbline -2
L172:
.dbline 0 ; func end
ret
.dbend
.dbfunc e DF_Reset _DF_Reset fV
.even
_DF_Reset::
.dbline -1
.dbline 626
; }
; /************************************************************
; *FLASH复位
; ************************************************************/
; void DF_Reset(void)
; {
.dbline 627
; SPI_PORT&=~(1<<RESET); //使能复位
cbi 0x18,3
.dbline 628
; DF_Delay(100);
ldi R16,100
ldi R17,0
xcall _DF_Delay
.dbline 629
; SPI_PORT|=(1<<RESET); //禁止复位
sbi 0x18,3
.dbline 630
; DF_Delay(100);
ldi R16,100
ldi R17,0
xcall _DF_Delay
.dbline -2
L173:
.dbline 0 ; func end
ret
.dbend
.area lit(rom, con, rel)
L175:
.byte 1,2
.byte 3,4
.byte 5,6
.byte 7,8
.byte 9,10
L176:
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.area text(rom, con, rel)
.dbfile E:\item\car\AT45DB041D\AT45DB041D.c
.dbfunc e Test_Flash_Buffer_to_Buffer _Test_Flash_Buffer_to_Buffer fV
; TestReadBuffer -> y+14
; TestWriteBuffer -> y+4
; i -> R20
.even
_Test_Flash_Buffer_to_Buffer::
st -y,R20
sbiw R28,24
.dbline -1
.dbline 637
; }
; /************************************************************
; *Test DataFlash
; ************************************************************/
; //Test_Flash_Buffer_to_Buffer
; void Test_Flash_Buffer_to_Buffer(void)
; {
.dbline 639
; unsigned char i;
; unsigned char TestWriteBuffer[10]={1,2,3,4,5,6,7,8,9,10};
ldi R24,<L175
ldi R25,>L175
movw R30,R28
adiw R30,4
ldi R16,10
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
xcall asgncblk
.dbline 640
; unsigned char TestReadBuffer[10] ={0,0,0,0,0,0,0,0,0,0};
ldi R24,<L176
ldi R25,>L176
movw R30,R28
adiw R30,14
ldi R16,10
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
xcall asgncblk
.dbline 643
;
; //写数据到Buffer中
; DF_Write_to_Buffer(Buffer1,0,TestWriteBuffer,10);
ldi R24,10
ldi R25,0
std y+3,R25
std y+2,R24
movw R24,R28
adiw R24,4
std y+1,R25
std y+0,R24
clr R18
clr R19
ldi R16,1
xcall _DF_Write_to_Buffer
.dbline 645
; //从Buffer中读取数据
; DF_Read_from_Buffer(Buffer1,0,TestReadBuffer,10);
ldi R24,10
ldi R25,0
std y+3,R25
std y+2,R24
movw R24,R28
adiw R24,14
std y+1,R25
std y+0,R24
clr R18
clr R19
ldi R16,1
xcall _DF_Read_from_Buffer
.dbline 647
;
; for(i=0;i<10;i++)//把要写入的和读出的数据写入EEPROM用于比较
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -