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 HELP

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







I2C HELP
PostPosted: Thu Feb 19, 2009 12:15 pm     Reply with quote

hello from UKRAINE.

master
Code:

i2c_start();
i2c_write(ADRES+1);
prom=i2c_read(0);
i2c_stop();


slave
Code:

#int_SSP
VOID SSP_isr()
{   
signed long long int prom;

state = i2c_isr_state();

if (state>=128)
{     
      prom=170;
      i2c_write(prom);

      }
   
}

Why at a parcel(sending) master of this code slave two times come into interruption. First time after exhibiting the address and second time after exhibiting stop. Thus if I put if (state > =128) that the master hangs. And if if (state == 128) that all is normal. Unless on stop there should be an interruption??. And still as to me to organize the program slave if the master transfers the following
Code:

i2c_start ();
i2c_write (ADRES+1);
prom=i2c_read (0);
prom=i2c_read (0);
prom=i2c_read (0);
i2c_stop ();

It is the text I translate(transport) by the interpreter therefore excuse for rough translation.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 19, 2009 6:40 pm     Reply with quote

Use the CCS example file code, Ex_Slave.c, for the Slave PIC.
It's in this directory:
Quote:
c:\Program Files\picc\Examples\Ex_Slave.c


Use the code in this post for the Master PIC:
http://www.ccsinfo.com/forum/viewtopic.php?t=32368&start=3

This will show how to write and read a byte between the master PIC
and the slave PIC with i2c.

Make sure that you have pull-up resistors on the SDA and SCL lines.
You can use 4.7K (4700 ohms) resistors.
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