CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

i2c communication problem with pic18f2520

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nehallove



Joined: 16 Jan 2008
Posts: 61

View user's profile Send private message

i2c communication problem with pic18f2520
PostPosted: Wed Jan 16, 2008 8:32 pm     Reply with quote

hi guys,

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 Smile
_________________
nehal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 12:55 am     Reply with quote

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

View user's profile Send private message

re: i2c communication problem with pic18f2520
PostPosted: Thu Jan 17, 2008 12:49 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group