5 slave mode programming examples, 1 initialize unit, To initialize the unit – Intel PXA26X User Manual

Page 356: Set the slave address in the isar, Enable desired interrupts in the icr, Set the icr[iue] bit to enable the i2c unit, 2 write n bytes as a slave, To write n bytes as a slave, Return from interrupt, Load data byte to transfer in the idbr

Advertising
background image

9-18

Intel® PXA26x Processor Family Developer’s Manual

Inter-Integrated Circuit Bus Interface Unit

9.5

Slave Mode Programming Examples

The following sub-sections describe slave mode programming.

9.5.1

Initialize Unit

To initialize the unit:

1. Set the slave address in the ISAR.

2. Enable desired interrupts in the ICR.

3. Set the ICR[IUE] bit to enable the I

2

C unit.

9.5.2

Write n Bytes as a Slave

To write n bytes as a slave:

1. When a Slave Address Detected interrupt occurs.

Read ISR: slave address detected (1), unit busy (1), R/nW bit (1), ACK/NAK (0)

2. Write a 1 to the ISR[SAD] bit to clear the interrupt.

3. Return from interrupt.

4. Load data byte to transfer in the IDBR.

5. Set ICR[TB] bit.

6. When a IDBR transmit empty interrupt occurs.

Read ISR: IDBR transmit empty (1), ACK/NAK (0), R/nW bit (0)

7. Load data byte to transfer in the IDBR.

8. Set the ICR[TB] bit.

9. Write a 1 to the ISR[ITE] bit to clear interrupt.

10. Return from interrupt.

11. Repeat steps 6 to 10 for n-1 times. If, at any time, the slave does not have data, the I

2

C unit

keeps SCL low until data is available.

12. When a IDBR transmit empty interrupt occurs.

Read ISR: IDBR transmit empty (1), ACK/NAK (1), R/nW bit (0)

13. Write a 1 to the ISR[ITE] bit to clear interrupt.

14. Return from interrupt

15. When slave stop detected interrupt occurs.

Read ISR: unit busy (0), slave STOP detected (1)

16. Write a 1 to the ISR[SSD] bit to clear interrupt.

Advertising