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 support@ccsinfo.com

i2c communication between 2 pic877 problem

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







i2c communication between 2 pic877 problem
PostPosted: Fri Aug 24, 2007 12:44 pm     Reply with quote

uav wrote:
hi i've a problem with i2c communication with following code
Code:
 master
while (1)
   {
   while(~porta0){}
   while(porta0){}
   i2c_start(); // Start condition
   i2c_write(0x54); // Device address
   i2c_write(8); // Write Command
   i2c_stop();
   delay_us(50);
   i2c_start(); // Start condition
   i2c_write(0x54 + 1); // read
   [b]for (i = 0; i <7>=0x80)
    {
   
    [b]portd++;
     i2c_write(0xf1);[/b]
     
    }
    else if (state >0)
    {
       portb = i2c_read();
    }
}


i test these codes with protues by checking port values. At this debbuging step slave pic freezes. master demands only 8bytes from slave. but i found that slave tries to send 9 bytes to master (portd indicates 9) and i think program stuck up there. how can i solve this problem thanks for your helps.


sorry for wrong post at different topic
uav
Guest







PostPosted: Fri Aug 24, 2007 12:45 pm     Reply with quote

oops i forget slave codes
Code:
void ssp_interupt ()
{   state=i2c_isr_state();
    if (state>=0x80)
    {
   
    portd++;
     i2c_write(0xf1);
     
    }
    else if (state >0)
    {
       portb = i2c_read();
    }
}
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