void UART1_int (void) interrupt 4
{
if(RI)
{
RI = 0;
cmd = SBUF;
}
if(TI)
{
TI = 0;
B_TX1_Busy = 0;
}
}
C language code (EEPROM.c)
//Operating frequency for test is 11.0592MHz
// This program is the built-in EEPROM read and write program of STC series.
#include "config.h"
#include "EEPROM.h"
u32 PassWord; // Password required for erasing and writing
//========================================================================
// Function: void ISP_Disable(void)
// Description: Disable access ISP/IAP.
// Parameters:non.
// Return: non.
// Version: V1.0, 2012-10-22
//========================================================================
void DisableEEPROM(void)
{
ISP_CONTR = 0; //Disable ISP/IAP operation
IAP_TPS = 0;
ISP_CMD = 0; //Remove ISP/IAP commands
ISP_TRIG = 0; //Prevent false triggering of ISP/IAP commands
ISP_ADDRH = 0xff; //Clear address high byte
ISP_ADDRL = 0xff; //Clear address low byte, point to non-EEPROM area to prevent
misoperation
}
//========================================================================
// Function: void EEPROM_read_n(u16 EE_address,u8 *DataAddress,u16 number)
// Description: Read n bytes from the specified EEPROM first address and put them in the specified buffer.
// Parameters:EE_address: The first address of the EEPROM to read.
// DataAddress: The first address of the data buffer.
// number: The length of bytes to read.
// Return: non.
// Version: V1.0, 2012-10-22
//========================================================================
void EEPROM_read_n(u16 EE_address,u8 *DataAddress,u16 number)
{
if(PassWord == D_PASSWORD) // Only the correct password is allowed to operate the EEPROM
{
EA = 0; //Disable interrupts