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

📄 sst25vfxxx.txt

📁 SST25系列编程方法
💻 TXT
📖 第 1 页 / 共 2 页
字号:
{
	CE_Low();			/* enable device */
	Send_Byte(0x06);		/* send WREN command */
	CE_High();			/* disable device */
}

/************************************************************************/
/* PROCEDURE: WRDI							*/
/*									*/
/* This procedure disables the Write Enable Latch.			*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void WRDI()
{
	CE_Low();			/* enable device */
	Send_Byte(0x04);		/* send WRDI command */
	CE_High();			/* disable device */
}


/************************************************************************/
/* PROCEDURE: Read_ID							*/
/*									*/
/* This procedure Reads the manufacturer's ID and device ID.  It will 	*/
/* use 90h or ABh as the command to read the ID (90h in this sample).   */
/* It is up to the user to give the last byte ID_addr to determine      */
/* whether the device outputs manufacturer's ID first, or device ID 	*/
/* first.  Please see the product datasheet for details.  Returns ID in */
/* variable byte.							*/
/*									*/
/* Input:								*/
/*		ID_addr							*/
/*									*/
/* Returns:								*/
/*		byte:	ID1						*/
/*									*/
/************************************************************************/
unsigned char Read_ID(ID_addr)
{
	unsigned char byte;
	CE_Low();			/* enable device */
	Send_Byte(0x90);		/* send read ID command (90h or ABh) */
    	Send_Byte(0x00);		/* send address */
	Send_Byte(0x00);		/* send address */
	Send_Byte(ID_addr);		/* send address - either 00H or 01H */
	byte = Get_Byte();		/* receive byte */
	CE_High();			/* disable device */
	return byte;
}


/************************************************************************/
/* PROCEDURE:	Read							*/
/*									*/		
/* This procedure reads one address of the device.  It will return the 	*/
/* byte read in variable byte.						*/
/*									*/
/*									*/
/*									*/
/* Input:								*/
/*		Dst:	Destination Address 000000H - 07FFFFH		*/
/*      								*/
/*									*/
/* Returns:								*/
/*		byte							*/
/*									*/
/************************************************************************/
unsigned char Read(unsigned long Dst) 

	unsigned char byte = 0;	

	CE_Low();			/* enable device */
	Send_Byte(0x03); 		/* read command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16));	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	byte = Get_Byte();
	CE_High();			/* disable device */
	return byte;			/* return one byte read */
}

/************************************************************************/
/* PROCEDURE:	Read_Cont						*/
/*									*/		
/* This procedure reads multiple addresses of the device and stores	*/
/* data into 128 byte buffer. Maximum byte that can be read is 128 bytes*/
/*									*/
/* Input:								*/
/*		Dst:		Destination Address 000000H - 07FFFFH	*/
/*      	no_bytes	Number of bytes to read	(max = 128)	*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/*									*/
/************************************************************************/
void Read_Cont(unsigned long Dst, unsigned long no_bytes)
{
	unsigned long i = 0;
	CE_Low();				/* enable device */
	Send_Byte(0x03); 			/* read command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16)); 	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	for (i = 0; i < no_bytes; i++)		/* read until no_bytes is reached */
	{
		upper_128[i] = Get_Byte();	/* receive byte and store at address 80H - FFH */
	}
	CE_High();				/* disable device */

}



/************************************************************************/
/* PROCEDURE:	Byte_Program						*/
/*									*/
/* This procedure programs one address of the device.			*/
/* Assumption:  Address being programmed is already erased and is NOT	*/
/*		block protected.					*/
/*									*/
/*									*/
/*									*/
/* Input:								*/
/*		Dst:		Destination Address 000000H - 07FFFFH	*/
/*		byte:		byte to be programmed			*/
/*      								*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/*									*/
/************************************************************************/
void Byte_Program(unsigned long Dst, unsigned char byte)
{
	CE_Low();				/* enable device */
	Send_Byte(0x02); 			/* send Byte Program command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16));	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	Send_Byte(byte);			/* send byte to be programmed */
	CE_High();				/* disable device */
}

/************************************************************************/
/* PROCEDURE:	Auto_Add_IncA						*/
/*									*/
/* This procedure programs consecutive addresses of the device.  This  	*/
/* is used to to start the AAI process.  It should be followed by 	*/
/* Auto_Add_IncB.							*/
/* Assumption:  Address being programmed is already erased and is NOT	*/
/*		block protected.					*/
/*									*/
/*									*/
/* Note: Only RDSR command can be executed once in AAI mode.	 	*/
/* 	 Use WRDI to exit AAI mode unless AAI is programming the last	*/
/*	 address or last address of unprotected block, which 		*/
/*	 automatically exits AAI mode.					*/
/*									*/
/* Input:								*/
/*		Dst:		Destination Address 000000H - 07FFFFH	*/
/*		byte:		byte to be programmed			*/
/*      								*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/*									*/
/************************************************************************/
void Auto_Add_IncA(unsigned long Dst, unsigned char byte)
{

	
	CE_Low();				/* enable device */
	Send_Byte(0xAF);			/* send AAI command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16)); 	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	Send_Byte(byte);			/* send byte to be programmed */
	CE_High();				/* disable device */
}

/************************************************************************/
/* PROCEDURE:	Auto_Add_IncB						*/
/*									*/
/* This procedure programs consecutive addresses of the device.  This  	*/
/* is used after Auto_Address_IncA.					*/
/* Assumption:  Address being programmed is already erased and is NOT	*/
/*		block protected.					*/
/*									*/
/* Note: Only RDSR command can be executed once in AAI mode.	 	*/
/* 	 Use WRDI to exit AAI mode unless AAI is programming the last	*/
/*	 address or last address of unprotected block, which 		*/
/*	 automatically exits AAI mode.					*/
/*									*/
/* Input:								*/
/*									*/
/*		byte:		byte to be programmed			*/
/*      								*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/*									*/
/************************************************************************/
void Auto_Add_IncB(unsigned char byte)
{
	CE_Low();				/* enable device */
	Send_Byte(0xAF);			/* send AAI command */
	Send_Byte(byte);			/* send byte to be programmed */
	CE_High();				/* disable device */
}


/************************************************************************/
/* PROCEDURE: Chip_Erase						*/
/*									*/
/* This procedure erases the entire Chip.				*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void Chip_Erase()
{
	CE_Low();				/* enable device */
	Send_Byte(0x60);			/* send Chip Erase command */
	CE_High();				/* disable device */
}

/************************************************************************/
/* PROCEDURE: Sector_Erase						*/
/*									*/
/* This procedure Sector Erases the Chip.				*/
/*									*/
/* Input:								*/
/*		Dst:		Destination Address 000000H - 07FFFFH	*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void Sector_Erase(unsigned long Dst)
{


	CE_Low();				/* enable device */
	Send_Byte(0x20);			/* send Sector Erase command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16)); 	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	CE_High();				/* disable device */
}

/************************************************************************/
/* PROCEDURE: Block_Erase						*/
/*									*/
/* This procedure Block Erases the Chip.				*/
/*									*/
/* Input:								*/
/*		Dst:		Destination Address 000000H - 07FFFFH	*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void Block_Erase(unsigned long Dst)
{
	CE_Low();				/* enable device */
	Send_Byte(0x52);			/* send Block Erase command */
	Send_Byte(((Dst & 0xFFFFFF) >> 16)); 	/* send 3 address bytes */
	Send_Byte(((Dst & 0xFFFF) >> 8));
	Send_Byte(Dst & 0xFF);
	CE_High();				/* disable device */
}

/************************************************************************/
/* PROCEDURE: Wait_Busy							*/
/*									*/
/* This procedure waits until device is no longer busy (can be used by	*/
/* Byte-Program, Sector-Erase, Block-Erase, Chip-Erase).		*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void Wait_Busy()
{
	while (Read_Status_Register() == 0x03)	/* waste time until not busy */
		Read_Status_Register();
}

/************************************************************************/
/* PROCEDURE: Wait_Busy_AAI						*/
/*									*/
/* This procedure waits until device is no longer busy for AAI mode.	*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void Wait_Busy_AAI()
{
	while (Read_Status_Register() == 0x43)	/* waste time until not busy */
		Read_Status_Register();
}

/************************************************************************/
/* PROCEDURE: WREN_Check						*/
/*									*/
/* This procedure checks to see if WEL bit set before program/erase.	*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void WREN_Check()
{
	unsigned char byte;
	byte = Read_Status_Register();	/* read the status register */
	if (byte != 0x02)		/* verify that WEL bit is set */
	{
		while(1)
					/* option: insert a display to view error on LED? */
	}
}

/************************************************************************/
/* PROCEDURE: WREN_AAI_Check						*/
/*									*/
/* This procedure checks for AAI and WEL bit once in AAI mode.		*/
/*									*/
/* Input:								*/
/*		None							*/
/*									*/
/* Returns:								*/
/*		Nothing							*/
/************************************************************************/
void WREN_AAI_Check()
{
	unsigned char byte;
	byte = Read_Status_Register();	/* read the status register */
	if (byte != 0x42)		/* verify that AAI and WEL bit is set */
	{
		while(1)		
					/* option: insert a display to view error on LED? */
	}
}


int main()
{


return 0;
}








⌨️ 快捷键说明

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