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

SLAVE I2C Not working

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



Joined: 11 Mar 2004
Posts: 7

View user's profile Send private message

SLAVE I2C Not working
PostPosted: Tue Mar 16, 2004 10:33 am     Reply with quote

Hey all, this is my code for the slave device:

#fuses MCLR,HS,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,NODEBUG
#use delay(clock=20000000, RESTART_WDT)


#use i2c(SLAVE, SDA=PIN_B1, SCL=PIN_B4,address=0xB0)

#byte Port_a = 5

#int_ssp
void ssp_interrupt() {
Port_a = 0xFF;
}

void main() {
set_tris_a(0);
enable_interrupts(GLOBAL);
enable_interrupts(INT_SSP);
while (TRUE) {
restart_wdt();
}
}



My master device works because I can get info to and from an eeprom.
I have just added these lines in the masters code :
i2c_start();
i2c_write(0xB0);
i2c_stop();


Could anyone tell me WHY my led on PORT_A on the slave device is not turning on ???

Thx
agrj



Joined: 26 Sep 2003
Posts: 48

View user's profile Send private message

PostPosted: Tue Mar 16, 2004 12:22 pm     Reply with quote

Hi,

2 things:

1 - CCS said in their manual that you have to use the directive force_hw when using I2C in slave mode

2 - These pins that you are using are the correct SDA and SCL? (what processor are you using?)

I hope it helps

Dinho
pyroboy123



Joined: 11 Mar 2004
Posts: 7

View user's profile Send private message

more info
PostPosted: Tue Mar 16, 2004 12:34 pm     Reply with quote

nope all you said I have done already.

I'm using a 16F87 and I have tried doing the FORCE_HW and that doesnt change anything either.

Now I'm using the ICD2 to look at my registers ....

I put a breakpoint on one of the first lines.

When I look at SSPCON it is 0

This means that the #use i2c doesnt work ?
agrj



Joined: 26 Sep 2003
Posts: 48

View user's profile Send private message

PostPosted: Wed Mar 17, 2004 6:51 am     Reply with quote

what are the value of the others registers:

SSPADD and SSPSTAT?

thanks
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