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

📄 main.c

📁 包含s3c2440几乎所有测试程序代码
💻 C
字号:
#include "2440lib.h"
#include "2440addr.h"
#include "flashrom.h"


void xmain(void)
{
	int  i;
	U16  temp;
	U32  flashid;
	
	ChangeClockDivider(3,1); //1:3:6
	ChangeMPllValue(127,2,1); //405MHZ
	
	Port_Init();
	Isr_Init();
	
	Uart_Init(0, 115200);
	Uart_Select(0);
	Uart_Printf("the main is running\n");
	
	//读取 Am29LV800D 的ID
	flashid=Get_Am29LV800D_ID();
	Uart_Printf("\nAm29LV800D'ID is %X",flashid);
		    
	//Am29LV800D 扇区擦除
    Am29LV800D_SectorErase(Section_Addr);//SST39VF160的最后一个扇区的开始地址0xf0000
	Uart_Printf("\nSector erase is done!");
    Delay(1000);	
    
    //检查扇区是否为空,2K×16bit/sector
    i = Am29LV800D_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的最后一个扇区 扇区地址0x0xf0000
	for(i=0;i<2048*2;i+=2)
	  {
	   if(Am29LV800D_WordProg(Section_Addr + i,0xaa55))//写入0xaa55到指定扇区
		{  
		  Delay(2);
	      Uart_Printf("\nWrite OK! Begin to Verify... ");
	    }
	   else
		  Uart_Printf("adr=%d,Write Error",i);
	   }
	   
	  //读flash的最后一个扇区 扇区地址0x0xf0000 
	for(i=0;i<2048;i+=2)
      {
        temp = Am29LV800D_WordRead(Section_Addr + i);//读Am29LV800D指定扇区
        if(temp!= 0xaa55)
          Uart_Printf("\nadr=%4d,temp = %4x Verify Error!",i,temp);	      
	  }
		   
	Uart_Printf("\nVerify OK! Begin to erase the sector...");
		   
    Am29LV800D_SectorErase(Section_Addr);//Am29LV800D 扇区擦除
    Uart_Printf("\nSector erase successfully!");
}	
	 
	  
  
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -