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

How can I use I2C between 184620 & 18452

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



Joined: 15 Jan 2009
Posts: 8

View user's profile Send private message MSN Messenger

How can I use I2C between 184620 & 18452
PostPosted: Tue Feb 17, 2009 12:26 am     Reply with quote

Who can basically test the procedure for me ?
184620 as master , 18452 as slave.
A Give materials to B through I2c, is printed out by UART of B.

Master of 4620 code :
Code:

void i2c_send_data()
{
 i2c_start();       // Start condition
 i2c_write(0xa0);   // Device address
 i2c_write('A');   // Low byte of command
 i2c_stop();        // Stop condition
}

void main()
{

for(;;)
  {
    i2c_send_data();
  }   
}

slave of 452 code :
Code:
#int_SSP
void  SSP_isr(void)
{
   BYTE incoming, state;
   state = i2c_isr_state();
   if(state < 0x80)   {
      incoming = i2c_read();
      if(state == 1)                     
         address = incoming;
         puts(incoming);
      if(state == 2)                     
         buffer[address] = incoming;
   }
       if(state == 0x80){
      i2c_write(buffer[address]);
   }
}
void main()
{
while (TRUE)
   {
      printf(" data from master ");
  }
}

How can I do ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 18, 2009 2:21 am     Reply with quote

Quote:
if(state == 2)
buffer[address] = incoming;

You can expand the if() statement above, so that it also sets a global flag
to TRUE. The code in main() can check this flag. If it is TRUE,
then you can send data from the buffer[] array to the PC with printf.
Also set the flag to FALSE. The flag should be initialized to FALSE
at the start of main() in the slave code.
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