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

i2c communication

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



Joined: 10 Mar 2015
Posts: 23

View user's profile Send private message

i2c communication
PostPosted: Mon Jun 08, 2015 11:20 pm     Reply with quote

I have PIC18F6722 and sensor device. In pic18f6722 SDA_PIN is in RC4 and SCL_PIN is in RC3. My question is can I connect DATA PIN on sensor device in other PIN (for example RB5) in pic18f6722 or is required connect on RC4.

Code:

#use i2c(Master,Fast,sda=PIN_B5,scl=PIN_C3)


Sorry for my bad English.
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Tue Jun 09, 2015 2:03 am     Reply with quote

For a master device, you can use _any_ normal I/O pins.

You have a choice between 'software' I2C (where everything is done by code), and 'hardware' I2C, (where the internal chip hardware is used).

For a slave device, hardware I2C must be used. For a master device select any pin you want, and the code will generate software I2C.

However:
1) Depending on your chip speed, the communication may well be slower.
2) Depending on the pins you choose, these may be problems with signalling voltages. If you choose as the 'data' pin, a pin that uses Schmitt input buffers, may give problems with the signals not getting high enough, quickly enough. Depends on the capacitance of your bus, and the speed you use.
3) Code for the hardware interface will be smaller.

Look at the 'I2C Overview' in the manual:

"CCS offers support for the hardware-based I2C™ and a software-based master I2C™ device."

Note 'software based master device'.

In your case, RB5, is a normal TTL input, so provided you choose a suitable pull-up resistor for your bus length/speed, the combination you show should work.
evelikov92



Joined: 10 Mar 2015
Posts: 23

View user's profile Send private message

PostPosted: Sat Jun 13, 2015 12:15 am     Reply with quote

When I asking question I want "Yes is possible" or "No". But your answer is better. Thanks a lot Ttelmah.
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