26.3.2.2.1 Clock Generation

The TWI supports several transmission modes with different frequency limitations:
  • Standard mode (Sm) up to 100 kHz
  • Fast mode (Fm) up to 400 kHz
  • Fast mode Plus (Fm+) up to 1 MHz
The Master Baud Rate (TWIn.MBAUD) register must be written to a value that will result in a TWI bus clock frequency equal or less than those frequency limits, depending on the transmission mode.

The low (TLOW) and high (THIGH) times are determined by the Master Baud Rate (TWIn.MBAUD) register, while the rise (TR) and fall (TOF) times are determined by the bus topology.

Figure 26-3. SCL Timing
  • TLOW is the low period of SCL clock
  • THIGH is the high period of SCL clock
  • TR is determined by the bus impedance; for internal pull-ups. Refer to Electrical Characteristics for details.
  • TOF is determined by the open-drain current limit and bus impedance. Refer to Electrical Characteristics for details.

Properties of the SCL Clock

The SCL frequency is given by:
f SCL = 1 T LOW + T HIGH + T OF + T R [Hz]
The SCL clock is designed to have a 50/50 duty cycle, where TOF is considered a part of TLOW. THIGH will not start until a high state of SCL has been detected.The BAUD bit field in the TWIn.MBAUD register and the SCL frequency are related by the following formula:
f S C L = f C L K _ P E R 10 + 2 × B A U D + f C L K _ P E R × T R (1)
Equation 1 can be transformed to express BAUD:
B A U D = f C L K _ P E R 2 × f S C L ( 5 + f C L K _ P E R × T R 2 ) (2)

Calculation of the BAUD Value

To ensure operation within the specifications of the desired speed mode (Sm, Fm, Fm+), follow these steps:
  1. Calculate a value for the BAUD bit field using equation 2
  2. Calculate TLOW using the BAUD value from step 1:
    T L O W = B A U D + 5 f C L K _ P E R T O F (3)
  3. Check if your TLOW from equation 3 is above the specified minimum of the desired mode (TLOW_Sm= 4700 ns, TLOW_Fm= 1300 ns, TLOW_Fm+= 500 ns)
    • If the calculated TLOW is above the limit, use the BAUD value from equation 2
    • If the limit is not met, calculate a new BAUD value using equation 4 below, where TLOW_mode is either TLOW_Sm, TLOW_Fm, or TLOW_Fm+ from the mode specifications:
      B A U D = f C L K _ P E R × ( T L O W _ m o d e + T O F ) 5 (4)