View previous topic :: View next topic |
Author |
Message |
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
SLAVE I2C Not working |
Posted: Tue Mar 16, 2004 10:33 am |
|
|
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
|
|
Posted: Tue Mar 16, 2004 12:22 pm |
|
|
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
|
more info |
Posted: Tue Mar 16, 2004 12:34 pm |
|
|
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
|
|
Posted: Wed Mar 17, 2004 6:51 am |
|
|
what are the value of the others registers:
SSPADD and SSPSTAT?
thanks |
|
|
|