IICS_IICIF = 1; //++
temp = (page_n & 0x07) << 1;
IICC_TX = 1; // Set transmit mode;
//-------start of transmit first byte to IIC bus-----
IICC_MST = 1; // Start transfer - Master bit = 1;
// IIC1D = sl_addr | temp; // send "Write" + high address;
if(iic_chnl==eprm)
{
IICD = 0xa0;
}
else
IICD = 0x70; //MAX695_A_地址 0x70= 0111000+0或//24c64Adresss:0xa0=BIT1010,0000
while (!(IICS_IICIF));
IICS_IICIF = 1;
while (IICS_RXAK); // wait for ACK from slave;
//-----Slave ACK occured------------
if(iic_chnl==eprm)
{
IICD = page_n; // send high address byte;
while (!(IICS_IICIF));
IICS_IICIF = 1;
while (IICS_RXAK); // wait for ACK from slave;
}
//-----Slave ACK occured------------
IICD = iic_ad; // send address byte;
while (!(IICS_IICIF)); // wait till data transfered;
IICS_IICIF = 1;
while (IICS_RXAK); // wait for ACK from slave;
//-----Slave ACK occured------------
IICD = iic_data; // write data byte into led driver;
while (!(IICS_IICIF)); // wait till data transfered;
while (IICS_RXAK); // wait for ACK from slave;
IICC_MST = 0; // STOP bit;
WaitNms(20);