i2C Slave Module Support

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
thetekguy
Posts: 3
Joined: Tue Jun 03, 2008 9:53 pm
Location: Toronto Canada

i2C Slave Module Support

Post by thetekguy » Tue Jun 03, 2008 10:10 pm

I'm complete newbie working on a program for a PIC18f24J10 that takes data off of an i2c bus and displays it on an LCD screen (cheap two wire LCD backpack module)

I'm looking at the data for the hardware i2c module and software i2c module and cannot find a command for i2c slave mode. Am I missing something?

If slave mode support does not exist, does someone have something they have coded already to give me a head start of building a module for it?

:D


thetekguy
Posts: 3
Joined: Tue Jun 03, 2008 9:53 pm
Location: Toronto Canada

Thanks

Post by thetekguy » Wed Jun 04, 2008 12:57 am

Good ideas :D - I was hoping to insulate the i2c master(s) from having to send control signals and do timing as well as display text by i2c- i have multiple i2c masters who will be sending status information to a shared common lcd display that are of different micro types- i would have to write an i2c expander driver for each of these micros unless the slave display peripheral handles these functions.

Looks like I may have to write a module....

It looks like a good start may be these picbasic pro routines unless anyone has seen something better:

http://www.astrosurf.com/soubie/pic_as_an_i2c_slave.htm , and:

http://www.astrosurf.com/soubie/downloads.htm

:lol:

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Wed Jun 04, 2008 2:07 pm

Is Multi-Master I2C a viable concept straight up?

thetekguy
Posts: 3
Joined: Tue Jun 03, 2008 9:53 pm
Location: Toronto Canada

Post by thetekguy » Thu Jun 05, 2008 1:52 am

I hope so- this article explains it:

http://www.esacademy.com/faq/i2c/general/i2carbit.htm

"When a master changes the state of a line to HIGH, it MUST always check that the line really has gone to HIGH. If it stays low then this is an indication that the bus is occupied and some other device is pulling the line low.

Therefore the general rule of thumb is: If a master can't get a certain line to go high, it lost arbitration and needs to back off and wait until a stop condition is seen before making another attempt to start transmitting."

I will have to modify i2c bus master to check the current state of a line hi/lo before transmitting, and implement a random timer to attempt transmission again. This should effectively make it a multi-master i2c bus.

Post Reply