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 slave not work

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







I2C slave not work
PostPosted: Fri Jan 19, 2007 12:33 pm     Reply with quote

i am trying to communicate 2 pic using the I2C bus,

master generate sda and sdl signals, but the slave not responds,

this is the code for the master
....
..
#use I2C(master,sda=PIN_B0, scl=PIN_B1))
.....
.....
while (TRUE){
i2c_start();
if ( i2c_write(0xa1)==0){
resultadoADC[0] = i2c_read();
resultadoADC[1] = i2c_read();
}
i2c_stop();
delay_ms(100);
}
....
....


this is the code for the slave

...
...

#use I2C(slave,address=0xa0,sda=PIN_B0, scl=PIN_B1))

int8 resultadoADC[2];
int16 lectura;


#INT_SSP
void ssp_interupt ()
{
BYTE state;

state = i2c_isr_state();

if(state == 0x80) //Master is requesting data
{
output_toggle(pin_B5); //flag
resultadoADC[0]=make8(lectura,0);
resultadoADC[1]=make8(lectura,1);
i2c_write(resultadoADC[0]);
i2c_write(resultadoADC[1]);

}
}
void main (void){

enable_interrupts(GLOBAL);
enable_interrupts(INT_SSP);


i2c_SlaveAddr(0xa0);

setup_adc( ADC_CLOCK_INTERNAL );
setup_adc( AN0);
set_adc_channel(0);
output_low(pin_B5);
while (TRUE){
lectura = read_adc();
output_toggle(pin_B4); // flag

}

}

can you helpme please
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 19, 2007 1:16 pm     Reply with quote

Which PIC
Guest








PostPosted: Fri Jan 19, 2007 1:26 pm     Reply with quote

sorry,....

i am using two pics 18F4550
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