Hardware I2C in slave mode

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
matherp
Registered User
Registered User
Posts: 31
Joined: Tue May 31, 2011 2:59 pm
Location: Cambridge

Hardware I2C in slave mode

Post by matherp » Tue Apr 03, 2012 8:55 am

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

User avatar
RadioT
Registered User
Registered User
Posts: 157
Joined: Tue Nov 27, 2007 12:50 pm
Location: Winnipeg, Canada

Post by RadioT » Fri Apr 06, 2012 3:43 pm

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

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Sat Apr 07, 2012 10:35 am

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 :shock:


check http://www.sfcompiler.co.uk/forum/viewt ... =7122#7122

matherp
Registered User
Registered User
Posts: 31
Joined: Tue May 31, 2011 2:59 pm
Location: Cambridge

Post by matherp » Mon Apr 16, 2012 9:39 am

Octal

Thanks for the link

I did use search - honest:-) but didn't check that thread as I assumed the title related to a software i2c implemetation (SI2C) duh....

Did you ever do the upgrade for the newer devices? I'm using 14K22 in this project

Thanks
Peter

Post Reply