View previous topic :: View next topic |
Author |
Message |
jehcc
Joined: 10 Jan 2019 Posts: 3 Location: Washington State
|
PIC24FJ64GB004 and I2C modules |
Posted: Thu Jan 10, 2019 7:22 pm |
|
|
I am trying to convert a C library from MPLAB X, XC16 compiler, to use the CCS compiler.
My current device is PIC24FJ64GB004 which has 2 fully functional I2C modules and dedicated pins for both.
I need to have both modules enabled and running at the same time, I do not see any way to do this in the CCS manual or examples.
Thank you for any help! |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Thu Jan 10, 2019 8:19 pm |
|
|
Check the section on the #use I2C preprocessor directive. You should be able to specify I2C1 and I2C2 with unique stream names for each.
something like:
#use i2c(I2C1, ... , STREAM = MYSTREAM1)
#use i2c(I2C2, ... , STREAM = MYSTREAM2) |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Fri Jan 11, 2019 1:25 am |
|
|
One caveat.
The statement: "dedicated pins for both", is not quite true.
In fact I2C1, can be located to two different sets of I/O pins depending
on a fuse setting. Where I2C1 will actually 'go', depends on whether
ALTI2C1 or NOALTI2C1 is selected in the fuses. |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Fri Jan 11, 2019 1:12 pm |
|
|
You've also gotta specify the stream parameter in your i2c functions (i2c_start, etc). If stream parameter is not specified, then it will apply to the last encountered #use i2c |
|
|
jehcc
Joined: 10 Jan 2019 Posts: 3 Location: Washington State
|
|
Posted: Fri Jan 11, 2019 2:22 pm |
|
|
Thanks for the feedback! I am looking into the #use syntax to see what I can do with it.
On this device I2C1 defaults to pin 1 & 44, with alternate set by the config bits of pins 19 & 20; I2C2 pins are 23 & 24, no choice. So little flexibility here.
And I need to run both at the same time.
Again, thanks |
|
|
|