问题
Hi I have a big problem with addressing multiple attiny85-chips with I2C:
For what I know the attiny uses 7-bit addresses for communication. I am using the TinyWireS lib, which works perfectly fine for me, untill I am reaching address: '64' which is '1000000' in binary. The highest usable address should be '1111111'.
This is what happens:
Slave:
Attiny85: switches led on or off when msg is received over I2C.
Slaveaddress: 64
#include <TinyWireS.h>
#include <usiTwiSlave.h>
#define output (4)
#define I2C_SLAVE_ADDR (64) //works if I2C_SLAVE_ADDR < 64
void setup() {
TinyWireS.begin(I2C_SLAVE_ADDR);
pinMode(output, OUTPUT);
}
volatile bool state = LOW;
void loop() {
byte msg = -1;
if(TinyWireS.available())
msg = TinyWireS.receive();
if(msg == 1)
state = HIGH;
else if(msg == 0)
state = LOW;
else if(msg == 2)
state = !state;
digitalWrite(output, state);
}
Master:
Arduino pro mini:
sendMsg(0, true); //works! led on chip: 64 switches on
sendMsg(64, true); //fails! led on chip: 64 is off.
#include <Wire.h>
#define DEVICE (64) //0 works!
void setup() {
Wire.begin();
}
void loop() {
sendMsg(1, DEVICE);
delay(2000);
sendMsg(0, DEVICE);
delay(2000);
}
void sendMsg(int msg, int device) {
Wire.beginTransmission(device);
Wire.write(msg);
Wire.endTransmission();
}
Have you any idea how to solve this problem?
TinyWireS version I am using: https://github.com/rambo/TinyWire/tree/master/TinyWireS
来源:https://stackoverflow.com/questions/31448327/i2c-addresses-63-are-not-usable-with-attiny85