I've searched but can't find any reference to this.
Has anyone built code to use a a pic in i2c slave mode that they can share?
Thanks
Peter
Hardware I2C in slave mode
Moderators: David Barker, Jerry Messina
Hi Matherp,
I've often looked at setting this up myself so am interested as well.
I've set up i2c before but with the PIC as master.
On the hardware side the i2c lines wouuld have pins for clock to clock (SCL), data to data (SDA) connected, with a pullup resistor on each line, 4.7K is generally recommended.
On the slave definition side, you are right, I also don't see any code for that in the library. The functions of the slave have to be replicated in code (preferably in a library).
PICs that have a MSSP module (Master Synchronous Serial Module) can be set up for slave operation in the respective registers. Making a library for slave operation would be to simplify the operation of the respecitive control and status register bits with human-readable names and setting routings for each major function (receive, transmit, ack, line stats, etc). Basically, starting as a complement to the master i2c library that is in the SF code now. Microchip's description should be in the datasheet of the chip you are using.
I also found a very good description of how a slave works in the Maxim timer chip I used the (formerly Dallas) DS1374:
http://datasheets.maxim-ic.com/en/ds/DS1374-DS1374U.pdf
So the slave must wait for a command from the master. The slave must be able to match the clock speed and provide the signals and data as a slave.
73's,
de Tom
I've often looked at setting this up myself so am interested as well.
I've set up i2c before but with the PIC as master.
On the hardware side the i2c lines wouuld have pins for clock to clock (SCL), data to data (SDA) connected, with a pullup resistor on each line, 4.7K is generally recommended.
On the slave definition side, you are right, I also don't see any code for that in the library. The functions of the slave have to be replicated in code (preferably in a library).
PICs that have a MSSP module (Master Synchronous Serial Module) can be set up for slave operation in the respective registers. Making a library for slave operation would be to simplify the operation of the respecitive control and status register bits with human-readable names and setting routings for each major function (receive, transmit, ack, line stats, etc). Basically, starting as a complement to the master i2c library that is in the SF code now. Microchip's description should be in the datasheet of the chip you are using.
I also found a very good description of how a slave works in the Maxim timer chip I used the (formerly Dallas) DS1374:
http://datasheets.maxim-ic.com/en/ds/DS1374-DS1374U.pdf
So the slave must wait for a command from the master. The slave must be able to match the clock speed and provide the signals and data as a slave.
73's,
de Tom
On the forum there is an option named "Search" !!!!
use it and put "SLAVE I2C" and you'll find a lot of discussions about slave I2C
check http://www.sfcompiler.co.uk/forum/viewt ... =7122#7122
use it and put "SLAVE I2C" and you'll find a lot of discussions about slave I2C
check http://www.sfcompiler.co.uk/forum/viewt ... =7122#7122