?? flash.asm
字號:
//==========================================================================================================
//說明:凌陽包含32k可用FLASH,被分為128個頁,每個頁的存儲容量為256個字,第一頁的存儲地址為0x8000-0x80ff,
// 最后一頁的地址為0xff00-0xffff。其中0xfc00-0xffff的地址為系統(tǒng)保留,用戶最好不要占用。值得注意的是,
// 如果程序占用的空間很大,那么用戶能夠使用的空間就相對少;反之,用戶可以有更多的支配空間。
//==========================================================================================================
.include hardware.inc
.define C_FLASH_SIZE 0x8000
.define C_FLASH_BLOCK_SIZE 0x100
.define C_FLASH_MATCH 0xAAAA
.define C_FLASH_PAGE_ERASE 0x5511 //erase 1 page
.define C_FLASH_MASS_ERASE 0x5522 //only can execution on STOP=1
.define C_FLASH_1WORD_PGM 0x5533 //write 1 word
.define C_FLASH_SEQUENT_PGM 0x5544 //write sequential word
.define C_FLASH_MAIN_BLOCK 0x5555 //
.define C_FLASH_INFORM_BLOCK 0x5566 //
.define P_Flash_Ctrl 0x7555
//*********************************************************//
//函數(shù):F_FlashWrite1Word()
//語法:void F_FlashWrite1Word(unsigned int ,unsigned int);
//描述:寫一個字到FLASH中
//參數(shù): 1、被寫數(shù)據(jù)的存儲地址
// 2、被寫數(shù)據(jù)
//返回:無
//*********************************************************//
.CODE
.public _F_FlashWrite1Word
_F_FlashWrite1Word: .proc
push bp to [sp]
bp=sp+1
r1=C_FLASH_MATCH //AAAA
[P_Flash_Ctrl]=r1
r1=C_FLASH_1WORD_PGM //5533
[P_Flash_Ctrl]=r1
r1=[bp+3] //flash address
r2=[bp+4] //data
[r1]=r2
//delay 40us //dont need,hardware auto block cpu
pop bp from [sp]
retf
.endp
//*********************************************************//
//函數(shù):F_FlashWrite()
//語法:void F_FlashWrite(unsigned int ,unsigned int * ,unsigned int);
//描述:順序?qū)懚鄠€字
//參數(shù):1、被寫數(shù)據(jù)的起始地址
// 2、被寫數(shù)組首地址
// 3、寫數(shù)據(jù)的數(shù)量
//返回:無
//*********************************************************//
.public _F_FlashWrite
_F_FlashWrite: .proc
push bp to [sp]
bp=sp+1
r1=[bp+3] //flash base address
r2=[bp+4] //data
r3=[bp+5] //nBytes
r4=C_FLASH_MATCH //AAAA
[P_Flash_Ctrl]=r4
L_FlashWriteLoop:
r4=C_FLASH_SEQUENT_PGM //5544
[P_Flash_Ctrl]=r4
r4=[r2++]
[r1++]=r4
//delay 40us //hardware auto block cpu
r3-=1
jnz L_FlashWriteLoop
[P_Flash_Ctrl]=r3 //end write
pop bp from [sp]
retf
.endp
//*********************************************************//
//函數(shù):F_FlashErase()
//語法:void F_FlashErase(unsigned int );
//描述:擦除256字節(jié)
//參數(shù):擦除頁的起始地址
//返回:無
//*********************************************************//
.public _F_FlashErase
_F_FlashErase: .proc
push bp to [sp]
bp=sp+1
r1=C_FLASH_MATCH //AAAA
[P_Flash_Ctrl]=r1
r1=C_FLASH_PAGE_ERASE //5511
[P_Flash_Ctrl]=r1
r1=[bp+3] //erase page
[r1]=r1
//delay 20ms //dont need,hardware auto block cpu
pop bp from [sp]
retf
.endp
//*********************************************************//
//函數(shù):F_FlashRead()
//語法:unsigned int F_FlashRead(unsigned int);
//描述:從flash中讀出數(shù)據(jù)
//參數(shù):所讀數(shù)據(jù)的存儲地址
//返回:所讀數(shù)據(jù)
//*********************************************************//
.public _F_FlashRead
_F_FlashRead: .proc
push bp to [sp]
bp=sp+1
r2=[bp+3]
r1=[r2]
pop bp from [sp]
retf
.endp
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -