Go Down

Topic: Issue with TinyWireM only recieving one byte (Read 1 time) previous topic - next topic

bHogan

Quote
Its more important for the "slaves" to be able to push events to the master as they happen

FWI, the way I did that was for the slave to trigger a pin change interrupt on the master when it had something. (There might be some help in the code for this crazy idea I had.)

Quote
Fingers crossed someone might have a solution.

There are a lot of sharp guys here on I2C.
Good luck, John
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

rs232


FWI, the way I did that was for the slave to trigger a pin change interrupt on the master when it had something. (There might be some help in the code for this crazy idea I had.)


Indeed. Thats basically what I planned to do, but in reverse. If the master wanted to contact the slaves, it would fire off a interrupt, then the slaves would ask what the master wanted. The slaves would be frequently sending data to the master, but it would be rare (and manually triggered) for the master needed to contact the slaves.

Thanks - will take a look at that code.

eric_f

Hey guys

I am working on a project that sounds similar to what you're facing.  I have multiple Attinys (mixture of 85s and 2313s) all talking with a mixture of Atmegas (328p, 1280, etc).
One thing I found with the Attinys, if you are wanting both master and slave capabilities is you have to do one at a time, switching between them.  You start them all as slaves, then if they need to send data, shutdown the slave, go to master, send whatever, then go back to slave.

Something like this:
Code: [Select]

void setup() {
    TinyWireS.begin(attinyAddress);
}

void loop() {
    if (TinyWireS.available) {
        byte command = TinyWireS.read();
        switch (command) {
            case WHATEVER: {
                // reset the I2C pins
                pinMode(0, INPUT);
                pinMode(2, INPUT);
                TinyWireM.begin();
                TinyWireM.beginTransmission(AtmegaAddress);
                TinyWireM.write(stuff);
                TinyWireM.endTransmisison();
                // reset the I2C pins
                pinMode(0, INPUT);
                pinMode(2, INPUT);
                TinyWireS.begin(attinyAddress);
            }
        }
    }
}


This is just a snippit of code that I have been using successfully.

Hope that helps somebody.

Go Up