?? main.c
字號:
#include "2410lib.h"
#include "2410addr.h"
#include "flashrom.h"
void Main(void)
{
int i;
U16 temp;
U32 flashid;
ChangeClockDivider(1,1);
ChangeMPllValue(0xa1,0x3,0x1);
Port_Init();
Uart_Select(0);
Uart_Init(0,115200);
//讀取SST39VF160的ID
flashid=Get_SST39VF160_ID();
Uart_Printf("\nSST39VF1601'ID is %X",flashid);
//SST39VF160 扇區擦除
SST39VF160_SectorErase(Section_Addr);//SST39VF160的最后一個扇區的開始地址0x1ff000
Uart_Printf("\nSector erase successfully!");
Delay(1000);
//檢查扇區是否為空,2K×16bit/sector
i = SST39VF160_CheckBlank(Section_Addr,2048);//檢查扇區是否擦除正確(0xFFFF)
if(i = 1)
Uart_Printf("\nBlank check OK! Begin to Write the sector...");
else
{
Uart_Printf("\nThe Sector is not empty! Abort the test!");
while(1);
}
//寫flash的最后一個扇區 扇區地址0x081ff000
for(i=0;i<2048*2;i+=2)
{
if(SST39VF160_WordProg(Section_Addr + i,0xaa55))//寫入0xaa55到指定扇區
{
Delay(2);
Uart_Printf("\nWrite OK! Begin to Verify... ");
}
else
Uart_Printf("adr=%d,Write Error",i);
}
//讀flash的最后一個扇區 扇區地址0x081ff000
for(i=0;i<2048;i+=2)
{
temp = SST39VF160_WordRead(Section_Addr + i);//讀SST39VF160指定扇區
if(temp!= 0xaa55)
Uart_Printf("\nadr=%4d,temp = %4x Verify Error!",i,temp);
}
Uart_Printf("\nVerify OK! Begin to erase the sector...");
SST39VF160_SectorErase(Section_Addr);//SST39VF160 扇區擦除
Uart_Printf("\nSector erase successfully!");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -