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 CCS Technical Support

CCS i2c functions

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







CCS i2c functions
PostPosted: Mon Jun 23, 2003 10:58 am     Reply with quote

I am trying to get two PIC16F877s to talk to one another. One will be an i2c master, the other will be a slave with address 0xa0. (I'll deal with multi-master setups later...)<p>
I'm using 2.7 kohm pullup resistors on the SCL and SDA lines. The compiler I'm using is PCM 3.065. I'm using the built-in i2c pins, and the FORCE_HW and SLOW options.<p>
I have a few questions about the built-in CCS i2c functions:<p>
1) PIC-C only allows you to use 7-bit i2c addresses, right? The PIC itself supports some other strange modes, but they don't seem to be supported by CCS.<p>
2) A master doesn't ever need an address, does it?<p>
3) What portion of the i2c protocol is implemented by the i2c_start() and i2c_stop() functions? Judging from the examples included in the CCS manual, i2c_start() doesn't do anything except issue the START condition (i.e. SDA goes low while SCL is high.) So the next thing you have to do is use i2c_write() to send the address + R/nW byte.<p>
The slave never calls i2c_start() or i2c_stop(), correct?<p>
4) When called by the slave, do the i2c_read and i2c_poll functions automatically filter out data that is not intended for the current device? Or is this another "do-it-yourself" situation?<p>
5) How does a slave wait for the i2c start condition? For example, if I wanted the slave to begin sending data immediately after receiving START followed by its 7-bit address (and the W bit), how would I do this?<p>
Thanks.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515472
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

Re: CCS i2c functions
PostPosted: Mon Jun 23, 2003 6:21 pm     Reply with quote

<font face="Courier New" size=-1>:=I am trying to get two PIC16F877s to talk to one another. One will be an i2c master, the other will be a slave with address 0xa0. (I'll deal with multi-master setups later...)<p>
:=I'm using 2.7 kohm pullup resistors on the SCL and SDA lines. The compiler I'm using is PCM 3.065. I'm using the built-in i2c pins, and the FORCE_HW and SLOW options.<p>
:=I have a few questions about the built-in CCS i2c functions:<p>
:=1) PIC-C only allows you to use 7-bit i2c addresses, right? The PIC itself supports some other strange modes, but they don't seem to be supported by CCS.<p>

Slave devices with 10 bit addresses have to be addressed with two bytes. The first byte has the reserved combination
1111XXX. This allows devices with 7-bit addresses on the same bus to be addressed normally.
Master-slave communication between PICs is by 7-bit addressing though. Note that the slave address must be an even number because the master is sending the slave address (R/W = 0).

:=2) A master doesn't ever need an address, does it?<p>
Correct.

:=3) What portion of the i2c protocol is implemented by the i2c_start() and i2c_stop() functions? Judging from the examples included in the CCS manual, i2c_start() doesn't do anything except issue the START condition (i.e. SDA goes low while SCL is high.) So the next thing you have to do is use i2c_write() to send the address + R/nW byte.<p>
Correct.

:=The slave never calls i2c_start() or i2c_stop(), correct?<p>
Correct.

:=4) When called by the slave, do the i2c_read and i2c_poll functions automatically filter out data that is not intended for the current device? Or is this another "do-it-yourself" situation?<p>

The slave doesn't call anything, instead responds to requests from the master.

:=5) How does a slave wait for the i2c start condition? For example, if I wanted the slave to begin sending data immediately after receiving START followed by its 7-bit address (and the W bit), how would I do this?<p>

In the SSP interrupt routine on the slave when an address match occurs.
Place 'i2c slave' in the search of this forum, there are lots of posts on this subject.
Also ex_slave.c in the 'examples' directory.

:=Thanks.

Regards
Kenny</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515498
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