User manual

Table Of Contents
Zynq-7000 AP SoC Technical Reference Manual www.xilinx.com 613
UG585 (v1.11) September 27, 2016
Chapter 20: I2C Controller
e. Clear the FIFOs: Set i2c.Control_reg0[CLR_FIFO] = 1.
f. Program the clock divisors:
- Set i2c.Control_reg0[divisor_a] = 0.
- Set i2c.Control_reg0[divisor_b] = 50.
These divisors generate an I2C SCL of 99 KHz using the CPU_1X clock of 111 MHz. For further
details refer to section 20.2.5 I2C Speed.
2. Configure Timeout. Write 0x0000_00FF to the i2c.Time_out_reg0 register. Wait 255 SCL cycles
when the SCL is held Low, before generating a timeout interrupt.
20.3.3 Configure Interrupts
The interrupts are described in section 20.2.8 Status and Interrupts. The i2c.Intrpt_enable_reg0 register
has bits to enable the interrupt mask and i2c.Intrpt_disable_reg0 has bits to forcefully disable the
interrupts. Each pair of bits should be set mutually exclusive:
Example: Program Example to Configure Completion Interrupt
1. Enable the completion interrupt. Set the enable bit, clear the disable bit, and verify the mask
value:
a. Set i2c.Intrpt_enable_reg0[COMP] = 1.
b. Clear i2c.Intrpt_disable_reg0[COMP] = 0.
c. i2c.intrpt_mask_reg0[COMP] reads back = 1.
2. Disable the completion interrupt. Set the enable bit, clear the disable bit, and verify the mask
value:
a. Set i2c.Intrpt_disable_reg0[COMP] = 1.
b. Clear i2c.Intrpt_enable_reg0[COMP] = 0.
c. i2c.Intrpt_mask_reg0[COMP] reads back = 0.
3. Monitor completion interrupt. I2c.Interrupt_status_reg0 provides status of completion
interrupt.:
a. Read i2c.Interrupt_status_reg0 [COMP]. 1 indicates that an interrupt occurred.
4. Clear completion interrupt. Write 1 to the i2c.Interrupt_status_reg0[COMP] bit field.
20.3.4 Data Transfers
Transfers can be achieved in polled mode or interrupt driven mode. Limitation on data count while
performing a master read transfer is 255 bytes. Below are examples of read and write transfer in
Master mode and example for Slave Monitor mode. Refer to section 20.2.3 Slave Monitor Mode for
details.
Example: Master Read Using Polled Method
1. Set direction of transfer as read and clear the FIFOs. Write 0x41 to i2c.Control_reg0.