EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 491

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
- 475 -
for(i=0; i<64; i++)
SaveTmp[i] = T_StringD[i]; //Read the default value
}
else PrintString1("
上电读取
3
个扇区数据均正确
!\r\n"); //UART1 send a string prompt
if((status & 0x01) == 0) // If sector 0 is wrong, write default value
{
if(SaveRecord(0x0000) == 0)
PrintString1("write a sector0
正确
!\r\n"); // Writing record 0 sector is correct
else
PrintString1("write a sector0
错误
!\r\n"); // Writing record 0 sector is wrong
}
if((status & 0x02) == 0) // If sector 1 is wrong, write default value
{
if(SaveRecord(0x0200) == 0)
PrintString1("write a sector1
正确
!\r\n"); // Writing record 1 sector is correct
else
PrintString1("write a sector1
错误
!\r\n"); // Writing record 1 sector is wrong
}
if((status & 0x04) == 0) // If sector 2 is wrong, write default value
{
if(SaveRecord(0x0400) == 0)
PrintString1("write a sector2
正确
!\r\n"); // Writing record 2 sector is correct
else
PrintString1("write a sector2
错误
!\r\n"); // Writing record 2 sector is wrong
}
while(1)
{
if(cmd != 0) // There is UART commands
{
if((cmd >= 'a') && (cmd <= 'z'))
cmd -= 0x20; // lowercase to uppercase
if(cmd == 'E') //PC requests to erase a sector
{
PassWord = D_PASSWORD; //given password
EEPROM_SectorErase(0x0000); //Erase a sector
PassWord = D_PASSWORD; //given password
EEPROM_SectorErase(0x0200); //Erase a sector
PassWord = D_PASSWORD; //given password
EEPROM_SectorErase(0x0400); //Erase a sector
PrintString1("
扇区擦除完成
!\r\n");
}
else if(cmd == 'W') //PC request to write 64 bytes data to EEPROM
{
for(i=0; i<64; i++)
SaveTmp[i] = T_StringW[i]; //write value
if(SaveRecord(0x0000) == 0)
PrintString1("write a sector0
正确
!\r\n"); // Writing record 0 sector is correct
else
PrintString1("write a sector0
错误
!\r\n"); // Writing record 0 sector is wrong
if(SaveRecord(0x0200) == 0)
PrintString1("write a sector1
正确
!\r\n"); // Writing record 1 sector is correct
else
PrintString1("write a sector1
错误
!\r\n"); // Writing record 1 sector is wrong

Table of Contents

Related product manuals