I've been working on this project for quite some time off and on. I'm pretty close to something that's stable, but it seems there are a few hitches. My main issue that that the device seems to become not responsive and disappear from the bus after a short time and I need to physically reconnect it to get it to start reading again and then it will disappear again after a short time. Often the first read doesn't work, but the following reads will work.
I'm using TinyWireS library on the ATTiny85 and have written some code to measure frequency in two ways using Timer 1 because Timer 0 is used by the I2C. PB1 is the input pin. I'm measuring lower frequencies.. 10hz-1000hz.
Method 1: Measure the time between two pulses via interrupt. With a few simple calculations based on the chip frequency and prescaler, I can compute the period and this the frequency.
Method 2: Use a Gate Timer. So, count the incoming pulses via interrupt and then then Timer 1 Overflows, we get the total pulses and then again, via some simple calculations based on chip frequency and prescaler, we can get the frequency.
Method 1 has been more accurate and precise, but method 1 seems more "stable".
I think there is something going on between these PCINT and Overflow interrupts and the I2C interrupts that is causing this issue. I'm having real difficulty getting this to work without falling off the bus. I also think this may have to do with clock stretching via the ATTiny as well. I'm running the bus speed for this device at 10kHz too..
I have some 16Mhz crystals on the way and will be able to test them tomorrow to see if the performance improves. I'm looking for some guidance on this project and wondering if someone can help to find the issue.