
#include<I2C.h>
#include<generic.h>
#include<serial.h>
void serial_interrupt() interrupt 4
{
	if(TI)
		{
		TI = 0;
		}	
	if(RI)
		{
		RI = 0;
		}
}

void main()
{
char BYTE_GET = 0x00,DATA_ = 0x11;
initialize_serial();
SBUF = 0x11;
usec_wait(200);
SBUF = 0x12;
usec_wait(200);
while(1)
{
 /********WRITE TO ADDRESS********/
 i2c_transmit_start();
SBUF = 0x13;
usec_wait(200);

 i2c_transmit_byte(0xA0);
SBUF = 0x14;
usec_wait(200);

 i2c_transmit_byte(0x11);
SBUF = 0x15;
usec_wait(200);

 i2c_transmit_byte(0x11);
SBUF = 0x16;
usec_wait(200);

 i2c_transmit_byte(DATA_);
SBUF = 0x17;
usec_wait(200);

 i2c_transmit_stop();
SBUF = 0x18;
usec_wait(200);

msec_wait(200);//wait after write

 /********READ FROM ADDRESS*******/
 i2c_transmit_start();
SBUF = 0x19;
usec_wait(200);

 i2c_transmit_byte(0xA0);
SBUF = 0x20;
usec_wait(200);

 i2c_transmit_byte(0x11);
SBUF = 0x21;
usec_wait(200);

 i2c_transmit_byte(0x11);
SBUF = 0x22;
usec_wait(200);

 i2c_transmit_start();
SBUF = 0x23;
usec_wait(200);

 i2c_transmit_byte(0xA1);
SBUF = 0x24;
usec_wait(200);

 i2c_transmit_stop();
SBUF = 0x25;
usec_wait(200);

 BYTE_GET = i2c_receive_byte(I2C_NAK);
 sec_wait(1);

 SBUF = BYTE_GET;
 msec_wait(1);

 SBUF = DATA_;
 msec_wait(1);

 DATA_ ++;
}
}
