I have thoroughly read the TWI part of ATmega data sheets, but I am still confused about a few things.
If I write
TWCR = (1 << TWINT);
, will that write a zero toTWIE
(and thereby disable TWI interrupts)? If I writeTWCR = (1 << TWINT) | (1 << TWIE);
, will that write a one toTWIE
(and thereby reenable TWI interrupts)?In the most recent data sheet for the ATmega1284p for example, the SCL frequency is calculated as follows:
\$ SCL = \frac{F\_CPU}{16\ +\ (2\ *\ TWBR\ *\ PreScaler)} \$
However, on this document: http://www.atmel.com/Images/Atmel-2564-Using-the-TWI-Module-as-I2C-Master_ApplicationNote_AVR315.pdf the SCL frequency is calculated as follows:
\$ SCL = \frac{F\_CPU}{16\ +\ (2\ *\ TWBR)\ -\ (4^{TWBR})} \$
and I have even seen other versions on other websites. Has the formula changed? Which is the correct one?
- Is it safe to assume that the TWI hardware is the same for all microcontrollers in the ATmega series?