Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

Anyone have an idea about how to connect Arduino Uno to PIC18F4620, the following circuit illustrates what I mean:

Schematic and Block Diagram

I want to use Arduino as a master and 2 PIC18F4620 microcontrollers as slaves, the first PIC on address 0x50 and the second one on 0x51.

I used the following code to program the Arduino as master:

‪#‎include‬ <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);

}

void loop()
{

Wire.beginTransmission(0x50);
Wire.write('I');
Wire.write('2');
Wire.write('C');
Wire.write('\n');
Wire.endTransmission(); 
Serial.println("Send to I2C Slave 0x50");
delay(1000);
}

The following code for the PIC using CCS compiler:

#include <slave.h>
‪#‎use‬ rs232(stream=string,baud=9600, xmit=PIN_C6, rcv=PIN_C7,parity = N, bits = 8) 
‪#‎define‬ P_SDA PIN_C4
#define P_SCL PIN_C3 

#use i2c(slave, sda=P_SDA, scl=P_SCL,address=0x50) 

void main() 
{ 
char data; 
char buffer_I2C[10]; 
int i=0; 
printf("SLAVE\r\n"); 
while(TRUE) 
{ 
if(i2c_poll()) 
{ 
data = i2c_read(); 
printf("%d \r\n" ,data);
if(data != -96) 
{ 
if(data == '\n') 
{ 
if(buffer_I2C[0] == 2) 
{ 
buffer_I2C[i]='\0'; 
printf("Message - %s\r\n",buffer_I2C); 
} 
} 
else 
{ 
buffer_I2C[i]=data; 
i++; 
} 
} 
else 
{ 
i=0; 
} 
} 
} 
}

The problem is the Arduino does not send anything to PIC. What is the problem?

share|improve this question
    
If the arduino doesn't send anything why have you listed the PIC code? –  Andy aka Feb 14 at 15:36
    
i think there is a problem in frequency? what do you think ???? –  Hafiz Irshaid Feb 14 at 16:16
    
i mentioned the PIC code because maybe the problem on it –  Hafiz Irshaid Feb 14 at 16:21
    
@Hafiz It is proper in English to capitalize "I" when referring to yourself. I've edited your question accordingly. –  JYelton Feb 14 at 18:35
    
Thanks a lot Mr. JYelton, but i will be happy if you answer my question. –  Hafiz Irshaid Feb 14 at 19:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.