Close

Timing constraints

A project log for Two Wire Sniff

Cheap and easy hardware implant for sniffing TWI (I2C) busses

juha-kiveksJuha Kivekäs 12/14/2016 at 05:240 Comments

The development has reached a point where it is clear the actions needed for sniffing are possible with the ATTiny45, even If there wont be a lot of time to waste. Sniffing a 100KHz signal with a microcontroller running at 8MHz only leaves 80 clocks per bit on the TWI bus which is not exactly a lot. Therefore some interrupt handling routines have to be made to fit that constraint, so some effort to optimize has to be done.

Optimizing for speed is easily done by using C or ASM as the language. As I'm already hitting these constraints with C, I've decided to go for ASM. Luckily there is very little arithmetic and complex logic needed in the project so this will not be a big problem. Since I'm reaching high speeds by the means of less instructions, this will have the natural effect of making the binary tiny and reaching the 1024 byte limit is not a risk.

Another timing related issue is the speed of writing to the EEPROM. It can only write at a baudrare of approximately 10KHz, which means I'll miss ten bytes on the bus if I stop to write a single bus to the EEPROM. Luckily most devices that require human interaction will be having long breaks (hundreds of milliseconds) between transmissions that can be used for moving the sniffed data from RAM to long-term storage.

Some design descisions will have to be made on the basis of these timing limitations. Since I'm originally working on the implant with a particular device in mind, the descisions will be made according to what is the best way to deal with timing in that device. Effort will be made to make the code readable and editable to fit other needs

Discussions