I2C Programming.

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
KeithSloan
Posts: 114
Joined: Fri Jul 27, 2007 10:50 am
Been thanked: 1 time
Contact:

I2C Programming.

Post by KeithSloan »

I understand that I can interact with I2C devices by any port if I use Bit banging, but I get the impression that some PIC processors have facilities to act as an I2C host.

1) Which PIC processors have the I2C host support.
2) How are the I2C devices wired to the PIC processor in this case.
3) I notice E-Blocks that support I2C devices tend to use Port C is this significant

Thanks Keith

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello Keith

1) The I2C host support is reffered to as MI2C. You can see a breakdown of the devices that have this functionality here.

http://www.microchip.com/ParamChartSear ... &pageId=74
There is also a similar page for the PIC18 series.

2) The I2C bus is two lines: SDA - Data and SCL - Clock. All you need to do is connect these lines to the lines on your remote I2C devices and then add a 10K pull up resistor to each line.

3) Most PICmicros use portC as the special function port. This includes I2C, UART and SPI. Therefore this is why the E-Blocks connect to portC.

KeithSloan
Posts: 114
Joined: Fri Jul 27, 2007 10:50 am
Been thanked: 1 time
Contact:

I2C Programming.

Post by KeithSloan »

Many Thanks Ben for the info.

Just to confirm my reading of the documentation.

If I was to build my own E-Block with an I2C slave device on it. I would be best advised to make pin 3 SCL and pin 4 SDA. Then plug into Port C.

Thanks Keith

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Post by Benj »

Hello

The PIC datasheet tells you which pins are which if you look at the pin diagram near the beginning of the datasheet then you will see the SCL and SDA pins. If you want to bit bang the output then you can use any pin you wish.

Post Reply