Change I2C clock speed to 444 kHz
This commit is contained in:
parent
5329bbefee
commit
260d7b7707
1 changed files with 9 additions and 3 deletions
|
|
@ -26,10 +26,16 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void i2c_init(void)
|
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 */
|
TWSR = 0; /* no prescaler */
|
||||||
TWBR = ((F_CPU/SCL_CLOCK)-16)/2; /* must be > 10 for stable operation */
|
TWBR = 10; /* must be >= 10 for stable operation */
|
||||||
|
|
||||||
}/* i2c_init */
|
}/* i2c_init */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue