Rainbow Electronics AT91CAP9S250A User Manual

Page 494

Advertising
background image

494

6264A–CAP–21-May-07

AT91CAP9S500A/AT91CAP9S250A

Figure 34-15. TWI Write Operation with Single Data Byte and Internal Address

BEGIN

Set TWI clock

(CLDIV, CHDIV, CKDIV) in TWI_CWGR

(Needed only once)

Set the Control register:

- Master enable

TWI_CR = MSEN + SVDIS

Set the Master Mode register:

- Device slave address (DADR)

- Internal address size (IADRSZ)

- Transfer direction bit

Write ==> bit MREAD = 0

Load transmit register

TWI_THR = Data to send

Read Status register

TXRDY = 1?

Read Status register

TXCOMP = 1?

Transfer finished

Set the internal address

TWI_IADR = address

Yes

Yes

No

No

Advertising