i am tryin to communicate with the ad5933 chip with i2c communication protocol ... the communication code is also given below. the thing i m missing is that if i do single step then i get to read the rite value but if run the code free then it won't run properly.
code:
int8 AD5933readbyte(unsigned char address)
{
int1 ack_rcv; // Receives acknowledge bit from transaction. CCS defined type.
int8 byte_rcv; // Receives the byte transmitted by the AD5933.
/* Initialize the address to be read back from by setting a pointer. */
i2c_start(); // Starts I2C transaction.
ack_rcv = i2c_write(AD5933_I2C_WRITE); // Address the AD5933 for write.
ack_rcv = i2c_write(ADDRESSPOINTERCMD); // Write the address pointer cmd.
ack_rcv = i2c_write(address); // Write the address to request reading from.
i2c_stop(); // Stops I2C transaction.
/* Read back the byte pointed to by the above address initialization. */
i2c_start(); // Start I2C transaction.
ack_rcv = i2c_write(AD5933_I2C_READ); // Address the AD5933 for read.
/*** TEST CODE ***/
byte_rcv = i2c_read(I2C_NACK); // Receive byte and send NACK to slave.
i2c_stop(); // Stops I2C transaction.
return byte_rcv; // Return the received byte from AD5933.
}
in above code i suppose to write all three
AD5933_I2C_WRITE
ADDRESSPOINTERCMD
0x03
but before 0x03 i got slave to talk to the bus and put data in between.
so i don't know wht is goin on ... code seems rite to me as far as i2c communication is concern ... i looked on scope and logic analyzer and i got same value. so some how in between 2nd and 3rd write sequence there is some other data placed on. but i do single stepping then i doesn't have.
so if anybody has solution of this problem please let me know.
thank u.
nehal _________________ nehal
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Thu Jan 17, 2008 12:55 am
Quote:
in above code i suppose to write all three
AD5933_I2C_WRITE
ADDRESSPOINTERCMD
0x03
The AD5933 data sheet has a Register Map that shows the addresses
of all the registers. It's on page 21 of the data sheet. The addresses go
from 0x80 to 0x97. I don't see an address of 0x03 in the list.
nehallove
Joined: 16 Jan 2008 Posts: 61
re: i2c communication problem with pic18f2520
Posted: Thu Jan 17, 2008 12:49 pm
sorry i was just testing the other address thing if i can write at all or not ... i was using address 0x8f for writing the register ... sorry my mistake ... but i got frustrated to make it work. _________________ nehal
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum