EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 477

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
- 461 -
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; //Disable IAP function
IAP_CMD = 0; //Clear command register
IAP_TRIG = 0; //Clear trigger register
IAP_ADDRH = 0x80; //Set the address to a non-IAP area
IAP_ADDRL = 0;
}
char IapRead(int addr)
{
char dat;
IAP_CONTR = 0x80; //Enable IAP
IAP_TPS = 12; //Set the erasing wait parameter of 12MHz
IAP_CMD = 1; //Set IAP read command
IAP_ADDRL = addr; //Set IAP low address
IAP_ADDRH = addr >> 8; //Set IAP high address
IAP_TRIG = 0x5a; //Write trigger command (0x5a)
IAP_TRIG = 0xa5; //Write trigger command (0xa5)
_nop_();
dat = IAP_DATA; //Read IAP data
IapIdle(); //Disable IAP function
return dat;
}
void IapProgram(int addr, char dat)
{
IAP_CONTR = 0x80; //Enable IAP
IAP_TPS = 12; //Set the erasing wait parameter of 12MHz
IAP_CMD = 2; //Set IAP writing command
IAP_ADDRL = addr; //Set IAP low address
IAP_ADDRH = addr >> 8; //Set IAP high address
IAP_DATA = dat; //Write IAP data
IAP_TRIG = 0x5a; //Write trigger command (0x5a)
IAP_TRIG = 0xa5; //Write trigger command (0xa5)
_nop_();
IapIdle(); //Disable IAP function
}
void IapErase(int addr)
{

Table of Contents

Related product manuals