EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 470

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
- 454 -
}
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)
{
IAP_CONTR = 0x80; //Enable IAP
IAP_TPS = 12; //Set the erasing wait parameter of 12MHz
IAP_CMD = 3; //Set IAP erasing 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_(); //
IapIdle(); //Disable IAP function
}
void main()
{
P0M0 = 0x00;
P0M1 = 0x00;
P1M0 = 0x00;
P1M1 = 0x00;
P2M0 = 0x00;
P2M1 = 0x00;
P3M0 = 0x00;
P3M1 = 0x00;
P4M0 = 0x00;
P4M1 = 0x00;
P5M0 = 0x00;
P5M1 = 0x00;
IapErase(0x0400);
P0 = IapRead(0x0400); //P0=0xff
IapProgram(0x0400, 0x12);
P1 = IapRead(0x0400); //P1=0x12
while (1);
}
Assembly code
;Operating frequency for test is 11.0592MHz
IAP_DATA DATA 0C2H
IAP_ADDRH DATA 0C3H

Table of Contents

Related product manuals