EasyManua.ls Logo

STC micro STC8A8K64D4 Series - Page 635

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
- 619 -
if (I2CSLST & 0x40)
{
I2CSLST &= ~0x40; //Handle the START event
}
else if (I2CSLST & 0x20)
{
I2CSLST &= ~0x20; //Handle the RECV event
if (isda)
{
isda = 0; //Handle the RECV event (RECV DEVICE ADDR)
}
else if (isma)
{
isma = 0; //Handle the RECV event (RECV MEMORY ADDR)
addr = I2CRXD;
I2CTXD = buffer[addr];
}
else
{
buffer[addr++] = I2CRXD; //Handle the RECV event (RECV DATA)
}
}
else if (I2CSLST & 0x10)
{
I2CSLST &= ~0x10; //Handle the SEND event
if (I2CSLST & 0x02)
{
I2CTXD = 0xff; //Stop receiving data when receiving NAK
}
else
{
I2CTXD = buffer[++addr]; //Continue reading data when receiving ACK
}
}
else if (I2CSLST & 0x08)
{
I2CSLST &= ~0x08; //Handle the STOP event
isda = 1;
isma = 1;
}
}
}
Assembly code
;Operating frequency for test is 11.0592MHz
P_SW2 DATA 0BAH
I2CCFG XDATA 0FE80H
I2CMSCR XDATA 0FE81H
I2CMSST XDATA 0FE82H
I2CSLCR XDATA 0FE83H
I2CSLST XDATA 0FE84H
I2CSLADR XDATA 0FE85H
I2CTXD XDATA 0FE86H
I2CRXD XDATA 0FE87H

Table of Contents

Related product manuals