📄 main.c
字号:
#include "2410lib.h"
#include "2410addr.h"
#include "timer.h"
#include "flashrom.h"
/********************************************/
// ARMSYS实验二:flash ROM 擦除写入测试
// 描述:对SST39VF160进行擦除和写入操作
/********************************************/
void Main(void)
{
int i;
char aa;
U16 temp;
SetClockDivider(1, 1);
SetSysFclk(DFT_FCLK_VAL);
Port_Init();
Uart_Select(0);
Uart_Init(0, UART_BAUD);
Delay(0);
Uart_Select(0); //Select UART0//
Uart_Printf("\n\n**********************************************************************");
Uart_Printf("\n* -flash ROM 读写测试程序- *");
Uart_Printf("\n* Version 1.10 *");
Uart_Printf("\n* UART Config--COM:115.2kbps,8Bit,NP,UART0 *");
Uart_Printf("\n*-----------------------Test flash? (Y/N)------------------------------*");
aa= Uart_Getch();
if((aa=='Y')||(aa=='y'))
{
//SST39VF160 扇区擦除
SST39VF160_SectorErase(0x1ff000);//SST39VF160的最后一个扇区的开始地址0x1ff000
Uart_Printf("\nSector erase successfully!");
//检查扇区是否为空,2K×16bit/sector
if(SST39VF160_CheckBlank(0x1ff000,2048))//是否为空
{
Uart_Printf("\nBlank check OK! Begin to Write the sector...");
for(i=0;i<2048;i++)
{
if(SST39VF160_WordProg(0x1ff000+i,0xaa55))//写入0xaa55
{
Delay(2);
}
else
Uart_Printf("adr=%d,Write Error",i);
}
Uart_Printf("\nWrite OK! Begin to Verify... ");
for(i=0;i<2048;i++)
{
temp = Readflash(0xff800+i);//读SST39VF160
if(temp!= 0xaa55)
{
Uart_Printf("\nadr=%4d,temp = %4x Verify Error!",i,temp);
//break;
}
}
Uart_Printf("\nVerify OK! Begin to erase the sector...");
SST39VF160_SectorErase(0xff800);//SST39VF160 扇区擦除
Uart_Printf("\nSector erase successfully!");
}
else
Uart_Printf("\nThe Sector is not empty! Abort the test!");
}
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -