⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 S3C2410学习的基础资料 大部分实验源码及工程
💻 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 + -