I have been switching over from I2C to RS485 serial for a project I have had working in the Arduino 022 revision days. It appears that the 1.3 version of Arduino is giving me quite a head ache.
One thing to note is that the sender is using Software Serial and the receiver is using FastSPI_LED code to run LED lights. (Redirecting... if you want to see the project). I have run the FastSPI_LED for a long time with I2C communication with no issues. FWIW, the SPI interrupt is higher precedence than the I2C interrupt. The signal coming into the sender via SoftwareSerial (RS485) is read and then I2C is called to send the serial information to the LED driving arduino.
I am trying to send out 4 bytes of information one arduino to the other. If I send 2 bytes of information it works fine. If I do 3 bytes of information and its locks up.
I have the pullup code on and have also just tried digital write for pull ups.
pinMode(SDA,INPUT_PULLUP);
pinMode(SCL,INPUT_PULLUP);
Here is the sender code. All variables are a single unsigned byte:
void ContactAll()
{
Wire.beginTransmission(YOUR_ADDRESS);
Wire.write(Choice);
Wire.write(Cur_Colormult);
//Wire.write(Cur_direction);
//Wire.write(Cur_patternx);
Wire.endTransmission() ;
delay(5);
}
Here is the receiver code:
void receiveEvent(int howMany){
while(Wire.available()){
for(readit=0;readit<howMany;readit++){
data[readit]= Wire.read();
Serial.print("received ");
Serial.print(readit+1,DEC);
Serial.print(" value=");
Serial.print(data[readit],DEC);}}
}
I have attempted significant delays (3ms) after the Wire.read()s thinking slower might be better.
When I hook up the logic analyzer when sending 3 bytes, it shows it sending the signal one time and then the second time it shows the address of what is being sent and then both SCL and SDA go low and stay that way...
When I look at the logic when sending 2 bytes, everything looks normal and chugs right along...
Any ideas? Any help is much appreciated... Been working on this for 10+ hours and not seeming to get anywhere!