EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 473

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
- 457 -
sfr P2M1 = 0x95;
sfr P2M0 = 0x96;
sfr P3M1 = 0xb1;
sfr P3M0 = 0xb2;
sfr P4M1 = 0xb3;
sfr P4M0 = 0xb4;
sfr P5M1 = 0xc9;
sfr P5M0 = 0xca;
sfr IAP_DATA = 0xC2;
sfr IAP_ADDRH = 0xC3;
sfr IAP_ADDRL = 0xC4;
sfr IAP_CMD = 0xC5;
sfr IAP_TRIG = 0xC6;
sfr IAP_CONTR = 0xC7;
sfr IAP_TPS = 0xF5;
#define IAP_OFFSET 0xF000H // STC8A8K60S4
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)
{
addr += IAP_OFFSET; //Using MOVC to read the EEPROM needs to add the
corresponding offset
return *(char code *)(addr); //Read data using MOVC
}
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)

Table of Contents

Related product manuals