EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 613

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
- 597 -
}
}
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;
P_SW2 = 0x80;
I2CCFG = 0xe0; //Enable I2C master mode
I2CMSST = 0x00;
EA = 1;
Start(); //Send start command
SendData(0xa0); //Send device address + write command
RecvACK();
SendData(0x00); //Send storage address high byte
RecvACK();
SendData(0x00); //Send storage address low byte
RecvACK();
SendData(0x12); //Write test data 1
RecvACK();
SendData(0x78); //Write test data 2
RecvACK();
Stop(); //Send stop command
Delay(); //Waiting for the device to write data
Start(); //Send start command
SendData(0xa0); //Send device address + write command
RecvACK();
SendData(0x00); //Send storage address high byte
RecvACK();
SendData(0x00); //Send storage address low byte
RecvACK();
Start(); //Send start command
SendData(0xa1); //Send device address + read command
RecvACK();
P0 = RecvData(); //Read data 1
SendACK();
P2 = RecvData(); //Read data 2
SendNAK();
Stop(); //Send stop command
P_SW2 = 0x00;
while (1);

Table of Contents

Related product manuals