![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| If you hace HiTech C installed then it should be in C:\Program Files\HI-TECH Software\PICC-Lite\9.50\samples\i2c Mike. | |
| |