View previous topic :: View next topic |
Author |
Message |
SkamneR Guest
|
Comunicating 2 Pic via I2C |
Posted: Mon Nov 29, 2004 10:16 am |
|
|
I´m trying to get started with the I2C protocol in order to comunicate two Pic microcontrollers, one as Master and the other as Slave. I have been checking this forum, and I´ve noticed that almost everybody uses a very low level programming (near to the ASM, as they program diferent bits on registers) at the moment of programing the Slave Microcontroller. My question is:
Does anybody have a piece of code which shows how to configure the slave microcontroller? (I mean, without going down into the register level?) |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 10:25 am |
|
|
Take a look at "ex_slave.c" example. It shows a PIC being emulated as an eeprom. What you want to do it very similar. An eeprom you write the address and then read back the data. What you are probably going to do is send a command (like the eeprom's address) and read back some data. |
|
|
Ken Macfarlane
Joined: 04 Oct 2004 Posts: 12 Location: Glasgow, Scotland
|
|
Posted: Tue Nov 30, 2004 3:13 am |
|
|
I tried to use ex_slave a while ago, and never could get the slave pic to see the msg although the interrupt did trigger for the incoming address byte, so I gave up and used a parallel interface to the chips, and had to use a bigger pic with more i/o lines.
All of the other examples that I could find were about getting a pic to talk to an i2c eeprom or a pcf8574 i/o expander i.e. there don't seem to be any master/slave pic to pic examples. Please let us know if you get one to work! |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Nov 30, 2004 7:08 am |
|
|
Yep, works just fine. Did you put pullups on the I2C lines? |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Tue Nov 30, 2004 8:59 am |
|
|
Also remember not to change the address. It needs to be even.
I forgot who mentioned this. But the example works. |
|
|
|