From 260d7b7707bd46c54964779a76d45a87af28ffdc Mon Sep 17 00:00:00 2001 From: Oleg Kostyuk Date: Mon, 9 Sep 2013 02:54:24 +0300 Subject: [PATCH] Change I2C clock speed to 444 kHz --- keyboard/ergodox/twimaster.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/keyboard/ergodox/twimaster.c b/keyboard/ergodox/twimaster.c index 6959d81c..f91c08e6 100644 --- a/keyboard/ergodox/twimaster.c +++ b/keyboard/ergodox/twimaster.c @@ -26,10 +26,16 @@ *************************************************************************/ void i2c_init(void) { - /* initialize TWI clock: 400 kHz clock, TWPS = 0 => prescaler = 1 */ + /* initialize TWI clock + * minimal values in Bit Rate Register (TWBR) and minimal Prescaler + * bits in the TWI Status Register should give us maximal possible + * I2C bus speed - about 444 kHz + * + * for more details, see 20.5.2 in ATmega16/32 secification + */ - TWSR = 0; /* no prescaler */ - TWBR = ((F_CPU/SCL_CLOCK)-16)/2; /* must be > 10 for stable operation */ + TWSR = 0; /* no prescaler */ + TWBR = 10; /* must be >= 10 for stable operation */ }/* i2c_init */ -- 2.46.2