EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 867

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
- 851 -
void CommInit(void)
{
UartRecvStep = 0;
TimeOut = 20;
UartReceived = FALSE;
}
// Send serial communication packets
void CommSend(BYTE size)
{
WORD sum;
BYTE i;
UartSend(0x46);
UartSend(0xb9);
UartSend(0x6a);
UartSend(0x00);
sum = size + 6 + 0x6a;
UartSend(size + 6);
for (i=0; i<size; i++)
{
sum += UartSend(TxBuffer[i]);
}
UartSend(HIBYTE(sum));
UartSend(LOBYTE(sum));
UartSend(0x16);
while (UartBusy);
CommInit();
}
//
STC15H Series of chips for ISP download
BOOL Download(BYTE *pdat, long size)
{
BYTE arg;
BYTE offset;
BYTE cnt;
WORD addr;
// Shake hands
CommInit();
while (1)
{
if (UartRecvStep == 0)
{
UartSend(0x7f);
DelayXms(10);
}
if (UartReceived)
{
arg = RxBuffer[4];
if (RxBuffer[0] == 0x50) break;
return FALSE;
}
}
// Set parameters (set the parameters such as the highest baud rate used by the slave chip and erase wait time)
TxBuffer[0] = 0x01;

Table of Contents

Related product manuals