STC8A8K64D4 Series Manual
void UartInit()
{
SCON = 0x5a;
T2L = BRT;
T2H = BRT >> 8;
AUXR = 0x15;
}
void UartSend(char dat)
{
while (!TI);
TI = 0;
SBUF = dat;
}
void IapIdle()
{
IAP_CONTR = 0;
IAP_CMD = 0;
IAP_TRIG = 0;
IAP_ADDRH = 0x80;
IAP_ADDRL = 0;
}
char IapRead(int addr)
{
char dat;
IAP_CONTR = 0x80;
IAP_TPS = 12;
IAP_CMD = 1;
IAP_ADDRL = addr;
IAP_ADDRH = addr >> 8;
IAP_TRIG = 0x5a;
IAP_TRIG = 0xa5;
_nop_();
dat = IAP_DATA;
IapIdle();
return dat;
}
void IapProgram(int addr, char dat)
{
IAP_CONTR = 0x80;
IAP_TPS = 12;
IAP_CMD = 2;
IAP_ADDRL = addr;
IAP_ADDRH = addr >> 8;
IAP_DATA = dat;
IAP_TRIG = 0x5a;
IAP_TRIG = 0xa5;
_nop_();
IapIdle();
}
void IapErase(int addr)
{
//Disable IAP function
//Clear command register
//Clear trigger register
//Set the address to a non-IAP area
//Enable IAP
//Set the erasing wait parameter of 12MHz
//Set IAP read command
//Set IAP low address
//Set IAP high address
//Write trigger command (0x5a)
//Write trigger command (0xa5)
//Read IAP data
//Disable IAP function
//Enable IAP
//Set the erasing wait parameter of 12MHz
//Set IAP writing command
//Set IAP low address
//Set IAP high address
//Write IAP data
//Write trigger command (0x5a)
//Write trigger command (0xa5)
//Disable IAP function
- 461 -
Need help?
Do you have a question about the micro STC8A8K64D4 Series and is the answer not in the manual?