Switch TWI library to use 400kHz
This commit is contained in:
parent
39da065913
commit
777d1fba76
1 changed files with 3 additions and 3 deletions
|
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
/* define CPU frequency in Mhz here if not defined in Makefile */
|
/* define CPU frequency in Mhz here if not defined in Makefile */
|
||||||
#ifndef F_CPU
|
#ifndef F_CPU
|
||||||
#define F_CPU 4000000UL
|
#define F_CPU 16000000UL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* I2C clock in Hz */
|
/* I2C clock in Hz */
|
||||||
#define SCL_CLOCK 100000L
|
#define SCL_CLOCK 400000L
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void i2c_init(void)
|
void i2c_init(void)
|
||||||
{
|
{
|
||||||
/* initialize TWI clock: 100 kHz clock, TWPS = 0 => prescaler = 1 */
|
/* initialize TWI clock: 400 kHz clock, TWPS = 0 => prescaler = 1 */
|
||||||
|
|
||||||
TWSR = 0; /* no prescaler */
|
TWSR = 0; /* no prescaler */
|
||||||
TWBR = ((F_CPU/SCL_CLOCK)-16)/2; /* must be > 10 for stable operation */
|
TWBR = ((F_CPU/SCL_CLOCK)-16)/2; /* must be > 10 for stable operation */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue