CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

i2c problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
isikmurat06



Joined: 08 Jan 2011
Posts: 7

View user's profile Send private message

i2c problem
PostPosted: Sat Jan 08, 2011 8:11 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 08, 2011 9:41 am     Reply with quote

'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: 19549

View user's profile Send private message

PostPosted: Sat Jan 08, 2011 10:21 am     Reply with quote

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: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 08, 2011 12:32 pm     Reply with quote

Also be sure to add pullups on the I2C lines ! 4K7r I think....
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sat Jan 08, 2011 2:45 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 08, 2011 3:03 pm     Reply with quote

The 1K value for 400 KHz is for 3.3v operation:
http://www.maxim-ic.com/app-notes/index.mvp/id/476
For a 5v system, it would be 1.6K to 1.7K minimum.
isikmurat06



Joined: 08 Jan 2011
Posts: 7

View user's profile Send private message

PostPosted: Sun Jan 09, 2011 8:42 am     Reply with quote

thanks you all for your answer. I will try and share the results.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group