Checking for data on the I2C bus (without Wire.h)

[quote author=Nick Gammon link=topic=104800.msg785918#msg785918 date=1336390554]
Well it certainly should be possible. All the interrupt does is alert you to a status change, and that status change will be reflected in a register somewhere.[/quote]
That's my reasoning too, but as I am a) rather inexperienced with I2C and b) tried most of the registers that I could think of, I am now officially stumped :slight_smile:

I do need every last drop of performance

Can you put some figures to this? What speed are you planning to run I2C? How fast do you need to react? Are you needing to do anything else, other than checking for the incoming data?

Actually, the I2C speed is not an issue (I am using the Wire library on "MegaMan", i.e. the I2C master, to send data to Peggy). It's rather that I have nothing to spare, as the SPI communication between Peggy's AVR and four multiplexers that switches the LEDs on and off on the display eats most of the CPU time. The LEDs can only be on/off, and I need 16 tones of gray, so I use interlacing, and I need to do this fast. This means that I spend most of the power on managing the LEDs (pretty much like an old TV set). The current framebuffer containing the current values of all the LEDs (325bytes), needs to be transmitted to the display about 80 times/second minimum. In other words: I don't need the I2C communication to be incredibly fast, I just need it to be very light.

whenever I make Peggy run a built-in animation

Animations are typically drawn in something like 25 or 30 FPS. This isn't particularly fast.

Agreed, it's the interlacing that makes me run out of juice, as if I did "black&white" it would be fine, but with 16 iterations per frame to get grayscale, I ramps up quite a bit. But again, I2C speed in itself is not important, it's just to make the code very light so it fits in with the interrupt that updates the screen over SPI.

I might need that outside the Arduino universe

The universe as you call it isn't particularly an Arduino one. I have stuff running on bare Atmega328 chips. I may use the Arduino IDE to program them, because that is easy. I'm not sure what you mean by that.

A valid point, and like I said in the beginning, part of the reason why I would like to do this is to familiarize myself with exactly how this works. It's always easier to use the libraries of course, but when trying to understand how something really works, it can be both fun and educational to Do It Yourself(tm) :slight_smile:

Oh, and of course, here it's a matter of trying to slim down the overhead. Particularly when streaming live video over the I2C link. In such cases one does for example not care if a frame is lost - all that matters is speed, and with the SPI communication to the muxes, that works with very little left to spare.

The nice thing is that it all works perfectly, except that is, that I for the life of me cannot understand how to manually check if I should abort my animation and return to reading I2C in anticipation of new "orders" from MegaMan. Having read the datasheet to exhaustion I feel that I have tried all the sensible alternatives, yet I still can not get that simple check to trigger when new data has arrived...