EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 492

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
- 476 -
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
}
else if(cmd == 'R') //PC requests to return 64 bytes of EEPROM data
{
if(ReadRecord(0x0000) == 0) //read data of sector 0
{
PrintString1("read sector 0
的数据如下:
\r\n");
for(i=0; i<64; i++)
TX1_write2buff(tmp[i]); // Return data to UART
TX1_write2buff(0x0d); // carriage return and line feed
TX1_write2buff(0x0a);
}
else PrintString1("read sector 0
的数据错误
!\r\n");
if(ReadRecord(0x0200) == 0) // Read data of sector 1
{
PrintString1("
读出扇区
1
的数据如下:
\r\n");
for(i=0; i<64; i++)
TX1_write2buff(tmp[i]); // Return data to UART
TX1_write2buff(0x0d); // carriage return and line feed
TX1_write2buff(0x0a);
}
else PrintString1("
读出扇区
1
的数据错误
!\r\n");
if(ReadRecord(0x0400) == 0) // Read data of sector 2
{
PrintString1("
读出扇区
2
的数据如下:
\r\n");
for(i=0; i<64; i++)
TX1_write2buff(tmp[i]); // Return data to UART
TX1_write2buff(0x0d); // carriage return and line feed
TX1_write2buff(0x0a);
}
else PrintString1("
读出扇区
2
的数据错误
!\r\n");
}
else PrintString1("
命令错误
!\r\n");
cmd = 0;
}
}
}
/**********************************************/
/*************** send a byte *******************************/
void TX1_write2buff(u8 dat) //write send buffer
{
B_TX1_Busy = 1; //Set sending busy flag
SBUF = dat; //send a byte
while(B_TX1_Busy); //wait for sending complish
}
//========================================================================
// Function: void PrintString1(u8 *puts)
// Description: UART1 send string function.
// Parameters:puts: String pointer.
// Return: none.

Table of Contents

Related product manuals