📄 blockerase.asm
字号:
#include <def21262.h>
.global FLASH_BLOCK_Erase_Command;
.extern block_erase_cmds;
.extern read_status_cmd;
.extern PP_DMA_READ;
.extern READ_STATUS;
//delay funcntions
.extern CLE_delay_func;
.extern ALE_delay_func;
.extern BYTE_PPDMA;
.extern AFTER_RD_WR_delay_func;
.extern Delay_Before_Return_func;
//##########################################################################
.section/pm seg_dmda;
.var Erase_Row_Addr[1] = 0;//This contains the block address to be erased
.section/pm seg_pmco;
//Block Erase Command
FLASH_BLOCK_Erase_Command:
//Generate block address from r13, r14 and r15
r11 = 0;//Initialize to "0"
r14 = LSHIFT r14 by 8;//left shift by 8
r15 = LSHIFT r15 by 16;//left shift by 16
r11 = r13 or r14;
r11 = r11 or r15;//r11 has the generated block address
bit clr FLAGS FLG0; //enable chip - FLASH CS# asserted here
bit set FLAGS FLG1; //Drive CLE "HI" for the command phase
//Give command "0x60"
i0 = block_erase_cmds;
r7 = i0; //this is written to IIPP
r8 = 1; //external memory byte transfer count
m0 = 1; //modifier to select next byte of command
CALL BYTE_PPDMA;
idle;//wait for PP Interrupt
CALL CLE_delay_func;//call CLE delay
//De-assert CLE
bit clr FLAGS FLG1;
//Drive ALE "HI" - address phase
bit set FLAGS FLG2;
/* For block erase, only ROW address is needed since the entire block is erased
with this command. Page address and element address is not used only block address
needs to be written.
*/
i1 = Erase_Row_Addr;
dm(i1,0) = r11;
r7 = i1; //this is written to IIPP
r8 = 3; //external memory byte transfer count
CALL BYTE_PPDMA;
idle;//wait for PP Interrupt
//Drive ALE "LO"
CALL ALE_delay_func;//call ALE delay
bit clr FLAGS FLG2;
bit set FLAGS FLG1; //Drive CLE "HI" for the command phase
//Give command "0xD0"
modify(i0,m0);//This is 0xD0 command
r7 = i0;
r8 = 1;//external memory byte transfer count
m0 = 1;//modifier to select next byte of command
CALL BYTE_PPDMA;
CALL CLE_delay_func;//call CLE delay
//De-assert CLE
bit clr FLAGS FLG1;
idle; //wait for DAI Interrupt - R/B# done
//Chip Erase status can be checked here
CALL READ_STATUS;
bit set FLAGS FLG0;//Disable chip - FLASH CS# de-asserted
CALL Delay_Before_Return_func;
RTS;
FLASH_BLOCK_Erase_Command.end:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -