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 slave killing packets from the master

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



Joined: 04 Oct 2004
Posts: 12
Location: Glasgow, Scotland

View user's profile Send private message

i2c slave killing packets from the master
PostPosted: Mon Oct 04, 2004 11:13 am     Reply with quote

My i2c master sends out address/data packets quite happily when there's no slave on the line. When the slave is an I/O expander (Phillips pcf8754), everything goes ok.

When I use a pic-based slave, as soon as the slave comes out of reset, the packets stop - seems to resolve around inclusion of the #use i.e.
#use i2c(SLAVE, SDA=PIN_C4, SCL=PIN_C3, address=0x41, SLOW, FORCE_HW)

I'm running both ends on pics with hardware mssp's, I've got the usual output_float calls on C3 & C4, and I've checked that I haven't misconnected C3/4 at the slave end, or plugged them into the wrong port.

Anybody know what the use i2c line actually adds to my code?

Thanks,

Ken Confused
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Oct 04, 2004 4:26 pm     Reply with quote

The Master is the one that generates the SCL pulses but if the Slave wants to it can hold the SCL line low which will cause the Master to pause until the SCL line is released by the slave. This is to ensure that the Master doesn't attempt to clock data out to the slave (or from it) before the Slave is ready to send (or receive) the data. You #use statement simply tells the PIC that it will be in Slave mode, which pins to use, the address of the Slave, that you want to talk in slow mode and to force the use of the hardware that built into the PIC. Make sure that the pins that you have selected are, in fact, the hardware pins for I2C communication. I found that not having the FORCE_HW in my use statement made it run, in one application, whereas if I included it the PIC would not function.

Ronald
Guest








PostPosted: Mon Oct 04, 2004 4:32 pm     Reply with quote

Also, the slave address specified needs to be an even number.
Ken Macfarlane



Joined: 04 Oct 2004
Posts: 12
Location: Glasgow, Scotland

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 4:43 am     Reply with quote

Thanks - my slave address was "A". Rather unfortunately for me Embarassed , it's an odd byte. As soon as I changed it to "B", everything just went - circular buffer and all!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Oct 05, 2004 8:49 am     Reply with quote

I have never seen that even address thing before. What spec sheet did that come from.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Oct 05, 2004 10:58 am     Reply with quote

You can check out the entire I2C specification at http://www.semiconductors.philips.com/acrobat/literature/9398/39340011.pdf. The addresses need to be even because the LSB is used as a R/W bit.

Ronald
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Oct 05, 2004 10:35 pm     Reply with quote

When the last bit is a 1 (odd) the device is addressed in read mode which caused the device to hold the clock line low until you set it back high for the master to clock out the data. Thus the reason for only even addresses.
Ken Macfarlane



Joined: 04 Oct 2004
Posts: 12
Location: Glasgow, Scotland

View user's profile Send private message

PostPosted: Thu Oct 07, 2004 6:48 am     Reply with quote

CCS' ex_slave.c shows i2c_poll being used to determine whether the incoming slave address is accompanied with a read or a write i.e. i2c_poll returns 0 when the slave is to be read, the inverse of the read/write# bit. Am I understanding this correctly? Is it the inverse of r/w#, i.e. bit 2 in SSPSTAT<2>?

I'm finding that I only occasionally get anything other than the slave address in the incoming packet at the slave end, and although the slave sees both true & false returns by i2c_poll, it always replies with all zero packets. I'm considering porting the hitech C code in an736 to CCS C, as it handles all the error conditions - anybody had any success with this?
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