EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 625

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
- 609 -
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(0xa2); //Send device address + write command
RecvACK();
SendData(0x02); //Send storage address
RecvACK();
SendData(0x00); //Set second value
RecvACK();
SendData(0x00); //Set minute value
RecvACK();
SendData(0x12); //Set hour value
RecvACK();
Stop(); //Send stop command
while (1)
{
Start(); //Send start command
SendData(0xa2); //Send device address + write command
RecvACK();
SendData(0x02); //Send storage address
RecvACK();
Start(); //Send start command
SendData(0xa3); //Send device address + read command
RecvACK();
P0 = RecvData(); //Read second value
SendACK();
P2 = RecvData(); //Read minute value
SendACK();
P3 = RecvData(); //Read hour value
SendNAK();
Stop(); //Send stop command
Delay();
}
}
Assembly code
;Operating frequency for test is 11.0592MHz
P_SW2 DATA 0BAH
I2CCFG XDATA 0FE80H
I2CMSCR XDATA 0FE81H

Table of Contents

Related product manuals