|
|
View previous topic :: View next topic |
Author |
Message |
thomas Guest
|
Software I2C |
Posted: Tue Jul 15, 2003 1:02 pm |
|
|
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 |
Posted: Tue Jul 15, 2003 1:25 pm |
|
|
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 |
Posted: Tue Jul 15, 2003 1:49 pm |
|
|
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
|
Re: Software I2C |
Posted: Tue Jul 15, 2003 4:40 pm |
|
|
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 |
|
|
|
|
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
|