wire lib and interrupt troubles...


I use one arduino as i2c master, and another one as i2c slave. the i2c slave also drive a 8x8 led matrix. To drive the matrix I use an interrupt
function which gets called about 10000 times/s. the matrix image is displayed fine if no i2c data is received.

NOW here comes the funny part - IF the i2c slave receive data (guess thats also interrupt driven) this needs time as well and disrupt my matrix driver. the result are brighter random horizontal lines, sometimes 1 per second, then 3s no visible error, then 2 lines per second...). the matrix driver use 128 cycles to display a full image (8 lines * 16 brightness values).

so the theoretical solution is, don't call the matrix driver interrupt while getting data (darker lines would be less visible) OR get the i2c data if my matrix driver just finished updating a full image (poll i2c lib each 128 cycles).

but i failed to find a practical solution ;( I tried to change the led matrix interrupt timer, tried to use flags (in my i2c callback) etc.

the code is visible here:

i know there were similar questions on this forum - but without a practical solution in this case...

Do you really need an 10Khz refresh rate of the data?
Something in the 10-25hz seems a lot more common.

Yes I do. I use a rainbowduino by seeedstudio - its a 12bit rgb matrix using pwm.

so i need such a high refresh rate to avid flimmering... and to create a brightness level i need to draw very quick. I tried to draw an image in one circle - the result was no image...

I was more thinking about disable/enable the i2c interrupt - would that be possible? or polling?

Its possible to pause the i2c timer in my pre draw task and renable it after the draw method? or would i loose too much data?