TWIM operation

nRF54LM20A | nRF54LM20B Datasheet

The FREQUENCY register defines the speed at which data is transmitted over the interface. Enumerators for common frequencies, such as K100 or K400, are provided.

The following formula can be used to calculate arbitrary frequencies. Due to the finite resolution of the clock generator, the actual SCL frequency may vary slightly from the calculated value.
Note: The frequency calculation equation is applicable only within the following SCL frequency ranges:
  • Fast-mode: 90 kHz to 500 kHz
  • Fast-mode plus: 900 kHz to 1100 kHz
Outside of these frequency intervals, the accuracy is not guaranteed.
Figure 3. TWIM frequency
TWIM frequency calculation equation
  • FREQUENCY is the value to be used in the TWIM FREQUENCY register.
  • f_PCLK is the peripheral clock frequency for the TWIM instance, as defined in Instances.
  • desired_frequency is the desired frequency in hertz, such as 100000 or 400000.

TWIM is started by triggering the DMA.TX.START or DMA.RX.START tasks, and stopped by triggering the STOP task. If TWIM is running when the STOP task is triggered, it stops and generates a STOPPED event.

After TWIM starts, the DMA.TX.START and DMA.RX.START tasks must not be triggered again until TWIM has issued a LASTRX, LASTTX, or STOPPED event.

TWIM can be suspended using the SUSPEND task, which is useful when using TWIM in a low priority interrupt context. When TWIM enters the SUSPEND state, it will automatically issue a SUSPENDED event while performing a continuous clock stretching. This continues until a RESUME task is received. TWIM cannot be stopped while it is suspended. The STOP task must be issued after TWIM resumes operation.

Note: Any ongoing byte transfer is allowed to complete before suspend is enforced. A SUSPEND task has no effect unless TWIM is actively involved in a transfer.

If a NACK is clocked in from the target, TWIM generates an ERROR event.