EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 487

Default Icon
901 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
STC8A8K64D4 Series Manual
- 471 -
*DataAddress = ISP_DATA; //Data be read
EE_address++;
DataAddress++;
}while(--number);
DisableEEPROM();
EA = 1; //re-enable interrupt
}
/******************** Sector Erase Function *****************/
//========================================================================
// Function: void EEPROM_SectorErase(u16 EE_address)
// Description: Erase the EEPROM sector at the specified address.
// Parameters:EE_address: The address of the sector EEPROM to be erased.
// Return: non.
// Version: V1.0, 2013-5-10
//========================================================================
void EEPROM_SectorErase(u16 EE_address)
{
EA = 0; //Disable interrupts
//Only sector erase, no byte erase, 512 bytes per sector.
//Any byte address in a sector is sector address.
ISP_ADDRH = EE_address / 256; //Send the high byte of the sector address (the address needs to be re-sent
when the address needs to be changed)
ISP_ADDRL = EE_address % 256; //Send the low byte of the sector address
ISP_CONTR = ISP_EN; //Allow ISP/IAP operation
IAP_TPS = (u8)(MAIN_Fosc / 1000000L); //Working frequency setting
ISP_ERASE(); //Send sector erase command. When the command does not need to be
changed, it is not necessary to send the command again
ISP_TRIG();
_nop_();
_nop_();
_nop_();
DisableEEPROM();
EA = 1; //re-enable interrupt
}
//========================================================================
// Function: void EEPROM_write_n(u16 EE_address,u8 *DataAddress,u16 number)
// Description: Write the buffered n bytes into the EEPROM of the specified first address.
// Parameters:EE_address: Write the first address of the EEPROM.
// DataAddress: The first address of the buffer where the source data is written.
// number: The length of bytes written.
// Return: non.
// Version: V1.0, 2012-10-22
//========================================================================
void EEPROM_write_n(u16 EE_address,u8 *DataAddress,u16 number)
{
EA = 0; //Disable interrupts
ISP_CONTR = ISP_EN; //Allow ISP/IAP operation
IAP_TPS = (u8)(MAIN_Fosc / 1000000L); //Working frequency setting
ISP_WRITE(); //Send byte write command. When the command does not need to be
changed, no need to send the command again
do
{
ISP_ADDRH = EE_address / 256; //Send the high byte of the address (the address needs to be re-sent when
the address needs to be changed)

Table of Contents

Related product manuals