EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 619

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
- 603 -
void Delay()
{
int i;
for (i=0; i<3000; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();
}
}
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;
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();

Table of Contents

Related product manuals