View previous topic :: View next topic |
Author |
Message |
rougie
Joined: 14 Jun 2006 Posts: 31
|
Quick question on I2C? |
Posted: Fri Jun 16, 2006 2:21 pm |
|
|
Hello,
I am a <newbie> to the CCS and the PIC world. I just got the CCS kit for the PIC16f877A micro controller a few days ago and I am doing chapter 17 (using an I2C temperature sensor).
Q#1:
If this sample claims to be using I2C, then why is it not using the appropriate pin outs of the chip? Pinouts for I2C on the PIC of package (44Pin PLCC) are pins 25 and 26 or RC4 and RC5 respectively.
But the sample in out exercise booklet is using pins B0 and B1 which are simple digital IO pins.
confused!
Any help or clarification for this is very appreciated!
Thanks
Regards
Roberto! |
|
|
cmdrdan
Joined: 08 Apr 2005 Posts: 25 Location: Washington
|
|
Posted: Fri Jun 16, 2006 2:42 pm |
|
|
Rougie --
I don't have the CCS board, nor do I know what all is on it. The pins slated for I2C on the PIC may be in use for other purposes, but for the purpose of your exercises, it doesn't matter.
If you use the hardware-defined pins for I2C, the compiler will generate code to use the internal I2C hardware. If you use other pins, the compiler generates code to "bit-bang" those pins to effect I2C. In this manner, you can use I2C on devices that don't have on-chip I2C capability, such as the 12F675.
Hope this helps! Make sure that you have pullup resistors on the lines for SCL and SDA, and have fun! Welcome to the world of PICs!
Dan |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Jun 16, 2006 2:56 pm |
|
|
Software I2C signals can be used on almost any pin as long as the PIC is used as the Master. A PIC configured as a Slave is much more complicated in software mode. It sounds like the PIC will be the Master so there's no worry there. Simply have the proper pins assigned in the #use i2c statement and you should be fine.
Ronald |
|
|
rougie
Joined: 14 Jun 2006 Posts: 31
|
Thankyou! |
Posted: Fri Jun 16, 2006 3:08 pm |
|
|
A million thanks guys, you have cleared it All up!
Kind regards
Roberto! |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Jun 16, 2006 3:09 pm |
|
|
cmdrdan:
The help manual says...
Quote: | Software functions are generated unless the FORCE_HW is specified. |
To me this means it is unrelated to which pins are picked.
So I think you need to say force_hw or you will get the bit-bang.
BUT i didn't look at the code listing to make sure. |
|
|
|