|
|
View previous topic :: View next topic |
Author |
Message |
evelikov92
Joined: 10 Mar 2015 Posts: 23
|
i2c communication |
Posted: Mon Jun 08, 2015 11:20 pm |
|
|
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
|
|
Posted: Tue Jun 09, 2015 2:03 am |
|
|
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
|
|
Posted: Sat Jun 13, 2015 12:15 am |
|
|
When I asking question I want "Yes is possible" or "No". But your answer is better. Thanks a lot Ttelmah. |
|
|
|
|
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
|