Line 14... |
Line 14... |
| CPU interrupts: | fast IRQ channel 7 | transmission done interrupt (see <<_processor_interrupts>>)
|
| CPU interrupts: | fast IRQ channel 7 | transmission done interrupt (see <<_processor_interrupts>>)
|
|=======================
|
|=======================
|
|
|
**Theory of Operation**
|
**Theory of Operation**
|
|
|
The two wire interface – also called "I²C" – is a quite famous interface for connecting several on-board
|
The two wire interface - also called "I²C" - is a quite famous interface for connecting several on-board
|
components. Since this interface only needs two signals (the serial data line `twi_sda_io` and the serial
|
components. Since this interface only needs two signals (the serial data line `twi_sda_io` and the serial
|
clock line `twi_scl_io`) – despite of the number of connected devices – it allows easy interconnections of
|
clock line `twi_scl_io`) - despite of the number of connected devices - it allows easy interconnections of
|
several peripheral nodes.
|
several peripheral nodes.
|
|
|
The NEORV32 TWI implements a **TWI controller**. It features "clock stretching" (if enabled via the control
|
The NEORV32 TWI implements a **TWI controller**. It features "clock stretching" (if enabled via the control
|
register), so a slow peripheral can halt the transmission by pulling the SCL line low. Currently, **no multi-controller
|
register), so a slow peripheral can halt the transmission by pulling the SCL line low. Currently, **no multi-controller
|
support** is available. Also, the NEORV32 TWI unit cannot operate in peripheral mode.
|
support** is available. Also, the NEORV32 TWI unit cannot operate in peripheral mode.
|
Line 63... |
Line 63... |
|
|
Based on the _TWI_CTRL_PRSCx_ configuration, the actual TWI clock frequency f~SCL~ is derived from the processor main clock f~main~ and is determined by:
|
Based on the _TWI_CTRL_PRSCx_ configuration, the actual TWI clock frequency f~SCL~ is derived from the processor main clock f~main~ and is determined by:
|
|
|
_**f~SCL~**_ = _f~main~[Hz]_ / (4 * `clock_prescaler`)
|
_**f~SCL~**_ = _f~main~[Hz]_ / (4 * `clock_prescaler`)
|
|
|
|
|
|
**Interrupt**
|
|
|
|
The TWI module provides a single interrupt to singal _idle state_ (= read for new transmission) to the CPU. Whenever TWI SPI module
|
|
is currently idle (and enabled), the interrupt request is active. A pending interrupt request is cleared
|
|
by triggering a new TWI transmission or by disabling the device.
|
|
|
|
|
.TWI register map (`struct NEORV32_TWI`)
|
.TWI register map (`struct NEORV32_TWI`)
|
[cols="<2,<2,<4,^1,<7"]
|
[cols="<2,<2,<4,^1,<7"]
|
[options="header",grid="all"]
|
[options="header",grid="all"]
|
|=======================
|
|=======================
|
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
|
| Address | Name [C] | Bit(s), Name [C] | R/W | Function
|