![FTDI FT51A Application Note Download Page 47](http://html1.mh-extra.com/html/ftdi/ft51a/ft51a_application-note_2341158047.webp)
Application Note
AN_289 FT51A Programming Guide
Version 1.0
Document Reference No.: FT_000962 Clearance No.: FTDI# 483
46
Copyright © 2015 Future Technology Devices International Limited
o
Read the
I2CMSA
register until the
BUSY
bit is clear.
o
Read the first byte of data from the
I2CMBUF
register.
o
For the remaining bytes (except the last byte):
Write to the Control Register
I2CMCR
with
HS
=0,
ACK
=1,
STOP
=0,
START
=1,
RUN
=1.
Read the
I2CMSA
register until the
BUSY
bit is clear.
Read the next byte of data from the
I2CMBUF
register.
o
Write to the Control Register
I2CMCR
with
HS
=0,
ACK
=0,
STOP
=1,
START
=1,
RUN
=1.
o
Read the
I2CMSA
register until the
BUSY
bit is clear.
o
Read the last byte of data from the
I2CMBUF
register.
uint8_t
data;
uint8_t
nFlagData;
// Set I2C Slave Address
I2CMSA = 0x22<<1 | 0x01; \\I2C_READ_NOT_WRITE
__asm NOP __endasm;
do
{ // loop while busy
status = I2CMCR;
if (!(status & 0x01)) //I2C_STATUS_BUSY
{
if (status & 0x02) //I2C_STATUS_ERROR
return 0;
return 1;
}
}while( 1 );
I2CMCR = 0x04 | 0x02 | 0x01; // I2C_FLAGS_STOP | I2C_FLAGS_START | I2C_FLAGS_RUN
do
{ // loop while busy
status = I2CMCR;
if (!(status & 0x01)) //I2C_STATUS_BUSY
{
if (status & 0x02) //I2C_STATUS_ERROR
return 0;
return 1;
}
}while( 1 );
data = I2CMBUF;
nFlagData = I2CMCR;
I2CMCR = nFlagData & ~0x08; // clear ack'ing