Hi all,
I am doing the
interprocesser communication using the I2C communication.Atr my master side the
The RCM3000 processer while slave is the 16F873A.THe problem is that my
communication is fine from the one side. When I am taking the data from the
slave it given me the desired data.But I am sending some the data it is not
received by the slave.
I am using the same
library function given by the DC.I am asking the error code it give me the error
code 0. THis mean that the communication is occured. But the data is not actual
received by slave caz I am toggling a pin. But it not happing. While I am asking
some data from slave. IT gives me the desired data.
THe library code is as
follows.
Please go through it code suggest me any
error
This is Master transmit From
Rabbit(Master) to PIC(Slave).
int send_command(unsigned char slave,unsigned
char buf)
{
auto unsigned char cnt;
auto short int err;
if (err=i2c_startw_tx())
{
i2c_stop_tx();
return -10+err; // Return too long stretching
}
if(err=i2c_wr_wait(slave))
{
i2c_stop_tx();
return -20+err; // Return no ack on slave (retried)
}
if(err=i2c_write_char(buf)
{
i2c_stop_tx();
return -30+err;
}
i2c_stop_tx();
return 0;
}
{
auto unsigned char cnt;
auto short int err;
if (err=i2c_startw_tx())
{
i2c_stop_tx();
return -10+err; // Return too long stretching
}
if(err=i2c_wr_wait(slave))
{
i2c_stop_tx();
return -20+err; // Return no ack on slave (retried)
}
if(err=i2c_write_char(buf)
{
i2c_stop_tx();
return -30+err;
}
i2c_stop_tx();
return 0;
}
This is Master
Receive
int get_data(unsigned char slave,unsigned
char *buf)
{
auto unsigned char cnt;
auto short int err;
{
auto unsigned char cnt;
auto short int err;
if
(err=i2c_startw_tx())
{
i2c_stop_tx();
return -10+err; // Return too long stretching
}
if(err=i2c_wr_wait(slave))
{
i2c_stop_tx();
return -20+err; // Return no ack on slave
}
if (err=i2c_startw_tx())
{
i2c_stop_tx();
return -30+err; // Return too long stretch on read
}
if (err=i2c_wr_wait(slave+1))
{
i2c_stop_tx();
return -40+err; // Send read to slave - no ack (retried) return -5
}
err=i2c_read_char(buf);
if (err)
{
i2c_stop_tx();
return -50+err;
}
{
i2c_stop_tx();
return -10+err; // Return too long stretching
}
if(err=i2c_wr_wait(slave))
{
i2c_stop_tx();
return -20+err; // Return no ack on slave
}
if (err=i2c_startw_tx())
{
i2c_stop_tx();
return -30+err; // Return too long stretch on read
}
if (err=i2c_wr_wait(slave+1))
{
i2c_stop_tx();
return -40+err; // Send read to slave - no ack (retried) return -5
}
err=i2c_read_char(buf);
if (err)
{
i2c_stop_tx();
return -50+err;
}
i2c_send_nak();
i2c_stop_tx();
return 0;
}
i2c_stop_tx();
return 0;
}
Warm Regards,
Dhananjay
Embedded System Engineer
TPT india Pvt. Ltd.
3.2,Herekar park, near Kamla Nehru park,
Bhandarkar road, Pune:-411004
India.
PhNo:-+91-020-25660665
MobileNo:-+91-9890396394
Email :- D...@touchplate.com
Website. www.touchplate.com
Embedded System Engineer
TPT india Pvt. Ltd.
3.2,Herekar park, near Kamla Nehru park,
Bhandarkar road, Pune:-411004
India.
PhNo:-+91-020-25660665
MobileNo:-+91-9890396394
Email :- D...@touchplate.com
Website. www.touchplate.com