Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 16th March 2006, 11:54 PM   (permalink)
Default I2C

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
__________________
"Ambition is the last refuge of failure..." --Oscar Wilde
"Success is not final, failure is not fatal: it is the courage to continue that counts." -- Winston Churchill
bsodmike is offline  
Old 17th March 2006, 04:48 AM   (permalink)
Default Re: I2C

Quote:
Originally Posted by bsodmike

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.
Pommie is online now  
Old 17th March 2006, 08:51 AM   (permalink)
Default

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
__________________
"Ambition is the last refuge of failure..." --Oscar Wilde
"Success is not final, failure is not fatal: it is the courage to continue that counts." -- Winston Churchill
bsodmike is offline  
Old 17th March 2006, 10:00 AM   (permalink)
Default

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.
Pommie is online now  
Old 17th March 2006, 06:30 PM   (permalink)
Default

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
__________________
"Ambition is the last refuge of failure..." --Oscar Wilde
"Success is not final, failure is not fatal: it is the courage to continue that counts." -- Winston Churchill
bsodmike is offline  
Old 18th March 2006, 02:43 AM   (permalink)
Default

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

Mike.
Pommie is online now  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:43 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker