loading

I2C addresses > 63 are not usable with atTiny85?

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'.

Here is the attiny85 datesheet.

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?

I suspect the address is wrapping round to 0000000

iceng17 days ago

Boy its annoying when a double answer is posted and deleting one kills them both... Anyway I spent 2hrs going through the ML code for your datasheet

.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. page 144 of 207

15.4.5. SOUT - Serial OUT to i/o space using direct addressing

The SOUT instruction stores the data byte that is shifted into the physical layer shift register to the I/O space. The instruction uses direct addressing, the address consisting of the 6 address bits of the instruction.

Table 15-6. The Serial OUT to i/o space (SOUT) Instruction

Operation___|__Opcode__|__Remarks

I/O[a] ← data__|__1aa1 aaaa__|__Bits marked ‘a’ form the direct, 6-bit address

.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..

There is only 000,000 - 111,111... When you code 1,000,000 your compiler assumes 0 address and when you try 1,111,111 it sends the compiler into the monkey shit tree.

Yes, your familiar with the tiny and found a limitation that could be overcome with bank switching.. But Really you will do better to move up to a bigger unit in the long run..