Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I2C

Status
Not open for further replies.

bsodmike

New Member
Hiya guys,

Does any one here have any decent code using the Hi-TECH pic compiler using the hardware MSSP module of the 16f877 to implement

a) I2C Master
b) I2C Slave

I've heard there there are issues with the hardware implemenation of I2C by Microchip :(

And what is with this business about setting SDA/SCL as inputs?

Cheers!

Mike
 
bsodmike said:
I've heard there there are issues with the hardware implemenation of I2C by Microchip :(

And what is with this business about setting SDA/SCL as inputs?

I have also heard that there are issues with I2C on pics. If that was the case, I'm sure that later pics would have any problems ironed out.

As for setting pins to input, the I2C pins have to be open collector outputs with a pull up. This is so multiple devices can pull the pin low and makes collision detection possible - if you are transmitting a 1 bit and see 0 on the pin then a collision has occurred. If you set the pins to output then they will be driven high/low instead of open circuit/low. You have to do the same (set to input) for the TX pin of RS232 even though that is a "proper" output.

Mike.
 
Yea thanks for that :)

The problem is, it is going to be PAINFUL developing code for the master if I don't have a working slave, i.e. I won't know which one isn't working. So any code that uses the hardware MSSP would be greatly appreciated :)

I'm working on the Master and Slave as we speak so I will post up code I've done and hope a kind sould will help me sort it out...I2C isn't complicated, but having a handful of registers to deal with, 4 - 5 interrupts to manage...it gets a bit out of hand...

Cheers,
Mike
 
Do you not have access to a I2C device such as a eeprom that you could use as a slave. Alternatively, Hitech have a sample of bit banged I2C that is master only. Either would give you one end.

Mike.
 
Hi-Tech do? Most of the masters I've seen are designed to work with specific sensors, not another PIC playing slave...

A link would be great, cheers!

Mike
 
If you hace HiTech C installed then it should be in
C:\Program Files\HI-TECH Software\PICC-Lite\9.50\samples\i2c

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top