sfr P3M1 = 0xb1;
char cnt7f;
void UartIsr() interrupt 4 // UART Interrupt Service Routine
{
if (TI)
{
TI = 0;
}
if (RI)
{
RI = 0;
if ((SBUF == 0x7f) && (RB8 == 1)) // Handshake command 7F sent by ISP download software
//The even parity bit of 7F is 1
{
if (++cnt7f == 8) // When 8 consecutive 7Fs are detected
IAP_CONTR = 0x60; // reset to system area
}
else
{
cnt7f = 0;
}
}
}
void main()
{
P3M0 = 0x00;
P3M1 = 0x00;
SCON = 0xd0; // Set the UART to 9 data bits
TMOD = 0x00;
AUXR = 0x40;
TH1 = BR2400 >> 8; // Set the UART baud rate to 2400
TL1 = BR2400;
TR1 = 1;
ES = 1;
EA = 1;
cnt7f = 0;
while (1)
{
... //User codes
}
}
Use P3.0/RxD to receive and detect user download commands sent by ISP download
software
If the user code needs to use the serial port for communication, the above 3 methods may not be applicable. At
this time, you can use the interface provided by the STC ISP download software to customize a set of dedicated user
download commands (you can specify the baud rate, Check bit and stop bit). If this function is enabled, the ISP
download software will use the user-specified baud rate, check bit and stop bit to send the user download command
before ISP download, and then send the handshake command. The user only needs to monitor the serial port command
sequence in his own code. When the correct user download command is detected, the software is reset to the system