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

PIC24FJ64GB004 and I2C modules

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



Joined: 10 Jan 2019
Posts: 3
Location: Washington State

View user's profile Send private message

PIC24FJ64GB004 and I2C modules
PostPosted: Thu Jan 10, 2019 7:22 pm     Reply with quote

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

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

PostPosted: Thu Jan 10, 2019 8:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 11, 2019 1:25 am     Reply with quote

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

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

PostPosted: Fri Jan 11, 2019 1:12 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 11, 2019 2:22 pm     Reply with quote

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
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