Hi everyone! I have just studied at i2c so i write some codes to pic to pic communication use ccsc .my project is soo basic and it is about master pic communicate the another slave pic and the led Which is contact with slave pic blink,but led does not blink.i didn't solve this problem.I am a new in electronic,the forum,and english.I need some suggestion about i2c communication.thanks for helps.
My codes:
MASTER
SLAVE
Mod edit: code tags
My codes:
MASTER
C:
#include <I2_C_MASTER.h>
#fuses HS,NOWDT,PROTECT,NOLVP,BROWNOUT,PUT
#use delay(clock=20Mhz)
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3)
void main(){
while(1){
int data=1;
i2c_start();
delay_ms(50);
i2c_write(0b00001111);//slave adresi
delay_ms(50);
i2c_write(data);//veri
delay_ms(50);
i2c_stop();
}//while
}
C:
#include <I2C_SLAVE.h>
#fuses HS,NOWDT,PROTECT,NOLVP,BROWNOUT,PUT
#use delay(clock=20Mhz)
#use i2c(slave, sda=pin_c4, scl=pin_c3,address=0x15)
int data;
void main(){
set_tris_a(0x00);
while(TRUE)
{
if(i2c_poll()) {
data=i2c_read();
output_toggle(pin_a0);
delay_ms(50);
}
}
}
Last edited by a moderator: