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

Software I2C

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







Software I2C
PostPosted: Tue Jul 15, 2003 1:02 pm     Reply with quote

Hi,

I know the PIC only has one hardware I2C port. If I use software I2C, can I have more than one I2C ports on a single micro? Thanks!
Thomas
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516011
jds-pic
Guest







Re: Software I2C
PostPosted: Tue Jul 15, 2003 1:25 pm     Reply with quote

yes, you can use multiple i2c, one could be hardware and the rest software-synthesized. however, you have to explicitly code your functions using the #use i2c directives. there is no runtime selection of which i2c port to use.

so you MUST code as follows:

#use i2c(config 1)
my_function_1() {
i2c_start();
...
}

#use i2c(config 2)
my_function_2() {
i2c_start();
...
}

you MUST NOT code as follows:

if (someval=TRUE) {
#use i2c(config 1)
i2c_start();
...
}
else {
#use i2c(config 2)
i2c_start();
...
}
}

good luck,
jim aka jds-pic


:=Hi,
:=
:=I know the PIC only has one hardware I2C port. If I use software I2C, can I have more than one I2C ports on a single micro? Thanks!
:=Thomas
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516012
thomas
Guest







Re: Software I2C
PostPosted: Tue Jul 15, 2003 1:49 pm     Reply with quote

Thank you very much for your help!
Best wishes and regards,
Thomas
:=
:=yes, you can use multiple i2c, one could be hardware and the rest software-synthesized. however, you have to explicitly code your functions using the #use i2c directives. there is no runtime selection of which i2c port to use.
:=
:=so you MUST code as follows:
:=
:=#use i2c(config 1)
:=my_function_1() {
:=i2c_start();
:=...
:=}
:=
:=#use i2c(config 2)
:=my_function_2() {
:=i2c_start();
:=...
:=}
:=
:=you MUST NOT code as follows:
:=
:=if (someval=TRUE) {
:= #use i2c(config 1)
:= i2c_start();
:= ...
:= }
:=else {
:= #use i2c(config 2)
:= i2c_start();
:= ...
:= }
:=}
:=
:=good luck,
:=jim aka jds-pic
:=
:=
:=:=Hi,
:=:=
:=:=I know the PIC only has one hardware I2C port. If I use software I2C, can I have more than one I2C ports on a single micro? Thanks!
:=:=Thomas
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516013
Mark



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

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

Re: Software I2C
PostPosted: Tue Jul 15, 2003 4:40 pm     Reply with quote

FYI:
In case you didn't know this, multiple i2c devices can be on the same bus.

Regards
Mark

:=Hi,
:=
:=I know the PIC only has one hardware I2C port. If I use software I2C, can I have more than one I2C ports on a single micro? Thanks!
:=Thomas
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516016
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