Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
return data_bit; /* If send_bit = 0 i2c is valid */
}
unsigned char I2C_read(void)
{
bit rd_bit;
unsigned char i, dat;
dat = 0x00;
for(i=0;i<8;i++) /* For loop read data 1 byte */
{
I2C_delay();
SCL = 1; /* Set SCL */
I2C_delay();
rd_bit = SDA; /* Keep for check acknowledge */
dat = dat<<1;
dat = dat | rd_bit; /* Keep bit data in dat */
SCL = 0; /* Clear SCL */
}
return dat;
}
void I2C_ack()
{
SDA = 0; /* Clear SDA */
I2C_delay();
I2C_clock(); /* Call for send data to i2c bus */
SDA = 1; /* Set SDA */
}
void I2C_noack()
{
SDA = 1; /* Set SDA */
I2C_delay();
I2C_clock(); /* Call for send data to i2c bus */
SCL = 1; /* Set SCL */
}
Added after 1 minutes:
main
#include <AT89X51.H>
#include <24xx512.h>
unsigned int del,i,x,temp;
char getCharacter (void)
{
char chr; // variable to hold the new character
while (RI != 1) {;}
chr = SBUF;
RI = 0;
return(chr);
}
void send (char a)
{
SBUF = a;
while (TI != 1);
TI=0;
}
void main (void){
char chr;
int i=0,j=0,count=0,inc=47;//inc=47
int index=0;
P1=0X00;
P2=0X00;
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.