View previous topic :: View next topic |
Author |
Message |
isikmurat06
Joined: 08 Jan 2011 Posts: 7
|
i2c problem |
Posted: Sat Jan 08, 2011 8:11 am |
|
|
hi,
I wanna communucate 3 pic with eacother.
One of them must be master and the others must be slave.
The LCD that is connected to slave pic doesn't show anything.
Please help....
I use this code for master pic;
Code: |
#use i2c(master,sda=pin_c4,scl=pin_c3,fast=400000)
.
.
.
i.2c_start();
i2c_write(0x01); // slave pic address
i2c_write(data);
i2c_stop();
.
.
. |
I use this code for slave pic;
Code: |
#use i2c(slave,sda=pin_c4,scl=pin_c3,fast=400000,address=0x01,FORCE_HW)
.
.
.
#INT_SSP
int I2C_kesme()
{
int data;
disable_interrupts(INT_SSP);
i2c_start();
i2c_write(0x01);
data=i2c_read();
delay_ms(11);
i2c_stop();
printf(putc_lcd,"%d",data);
return;
}
.
.
. |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Sat Jan 08, 2011 9:41 am |
|
|
'1' is not a legitimate I2C address. The first few addresses are _reserved_, and an address number will always be _even_. The low bit of an I2C address is the 'direction' flag. You are sending a command to read from reserved device 0.
Best Wishes |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Sat Jan 08, 2011 10:21 am |
|
|
Also, understand, that the _master_ controls all transactions. Only it can send a start or a stop.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sat Jan 08, 2011 12:32 pm |
|
|
Also be sure to add pullups on the I2C lines ! 4K7r I think.... |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Sat Jan 08, 2011 2:45 pm |
|
|
temtronic wrote: | Also be sure to add pullups on the I2C lines ! 4K7r I think.... |
1K for 400KHz, 4K7 for 100KHz _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
isikmurat06
Joined: 08 Jan 2011 Posts: 7
|
|
Posted: Sun Jan 09, 2011 8:42 am |
|
|
thanks you all for your answer. I will try and share the results. |
|
|
|