DelayXms(10);
addr = 0;
TxBuffer[0] = 0x22;
TxBuffer[3] = 0x5a;
TxBuffer[4] = 0xa5;
offset = 5;
while (addr < size)
{
TxBuffer[1] = HIBYTE(addr);
TxBuffer[2] = LOBYTE(addr);
cnt = 0;
while (addr < size)
{
TxBuffer[cnt+offset] = pdat[addr];
addr++;
cnt++;
if (cnt >= 128) break;
}
CommSend(cnt + offset);
while (1)
{
if (TimeOut == 0) return FALSE;
if (UartReceived)
{
if ((RxBuffer[0] == 0x02) && (RxBuffer[1] == 'T')) break;
return FALSE;
}
}
TxBuffer[0] = 0x02;
}
//// Write hardware options
//// If you do not need to modify the hardware options, this step can be skipped directly.At this time, all the hardware options
//// remain unchanged, the frequency of the MCU is the last adjusted frequency
//// If you write the hardware option, the MCU's internal IRC frequency will be fixed to 24MHz,
//// and other options will be restored to the factory settings.
////Suggestion: Set the hardware options of the slave chip when you use STC-ISP download software the first time.
//// Do not write hardware options when downloading programs from the master chip to the slave chip.
//DelayXms(10);
//for (cnt=0; cnt<128; cnt++)
//{
// TxBuffer[cnt] = 0xff;
//}
//TxBuffer[0] = 0x04;
//TxBuffer[1] = 0x00;
//TxBuffer[2] = 0x00;
//TxBuffer[3] = 0x5a;
//TxBuffer[4] = 0xa5;
//TxBuffer[33] = arg;
//TxBuffer[34] = 0x00;
//TxBuffer[35] = 0x01;
//TxBuffer[41] = 0xbf;
//TxBuffer[42] = 0xbd; //P5.4 is I/O port
////TxBuffer[42] = 0xad; //P5.4 is reset pin
//TxBuffer[43] = 0xf7;
//TxBuffer[44] = 0xff;
//CommSend(45);