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

📄 main.c

📁 本程序是并口FLASH 39sf040读写程序,并给出调用函数.
💻 C
字号:
#include    <reg52.h>
#include    <..\Include\FLASH.h>
unsigned char xdata Writebydata[8192];

void Wait(unsigned int j)
{
	unsigned char i;
	while(j--)
		for(i=0;i<100;i++);
}

void main()
{  
    unsigned char xdata Readbydata[8192];
	unsigned int chipseletaddr;
	unsigned char i ;
	unsigned int  j;
	unsigned char FlashNum, FlashSize;
	FlashNum=4;
	chipseletaddr=0x8000;
	if(Flash_Init(chipseletaddr,&FlashSize, &FlashNum)==0)
	{
//		Flash_EraseEntirChip(0x9000);       //片擦除
		for(i=0;i<FlashNum;i++)
		{
			Flash_EraseOneSector(i, 0x8000);                   //第0片的第0页
			chipseletaddr = (i+1)<<12;
		}
		Wait(100);
		Flash_ReadData (&Readbydata, 0,0, 8192, 0x9000);
		for(j=0;j<8192;j++)
			if( Readbydata[j] != 0xff )
			{
				while(1);
			}
		for(j=0;j<8192;j++)
			Writebydata[j] = j;
		Flash_ProgramData (&Writebydata, 0,0, 8192, 0x9000);
		Wait(10);
		Flash_ReadData (&Readbydata, 0,0, 8192, 0x9000);
		for(j=0;j<8192;j++)
			if( Writebydata[j] != Readbydata[j] )
			{
				while(1);
			}
	 }  
	while(1);
}

⌨️ 快捷键说明

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