Figure 34-16 on – Rainbow Electronics AT91CAP9S250A User Manual

Page 495

Advertising
background image

495

6264A–CAP–21-May-07

AT91CAP9S500A/AT91CAP9S250A

Figure 34-16. TWI Write Operation with Multiple Data Bytes with or without Internal Address

Set the Control register:

- Master enable

TWI_CR = MSEN + SVDIS

Set the Master Mode register:

- Device slave address

- Internal address size

(if IADR used)

- Transfer direction bit

Write ==> bit MREAD = 0

Internal address size = 0?

Load Transmit register

TWI_THR = Data to send

Read Status register

TXRDY = 1?

Data to send?

Read Status register

TXCOMP = 1?

END

BEGIN

Set the internal address

TWI_IADR = address

Yes

TWI_THR = data to send

Yes

Yes

Yes

No

No

No

Set TWI clock

(CLDIV, CHDIV, CKDIV) in TWI_CWGR

(Needed only once)

Advertising