Freescale Semiconductor MCF5480 User Manual

Page 871

Advertising
background image

Initialization Sequence

MCF548x Reference Manual, Rev. 3

Freescale Semiconductor

28-17

/* Set I2CR.MTX to put the module in transit mode */

MCF_I2C_I2CR |= MCF_I2C_I2CR_MTX;

/* Send the contents of tx_buffer until NACK is detected */

i = 0;

while (1)

{

/*Put TX data into I2DR */

MCF_I2C_I2DR = tx_buffer[i];

/*Wait for transfer to complete */

while (!(MCF_I2C_I2SR & MCF_I2C_I2SR_IIF) );

/* Clear IIF bit */

MCF_I2C_I2SR &= 0xFD;

/*Detect when no ACK is received */

if(MCF_I2C_I2SR & MCF_I2C_I2SR_RXAK)

{

/*Finish the transfer by putting the module into its idle state. */
MCF_I2C_I2CR = 0x80;
break;

}

i++;

}

/*************************************************************************

* Slave RX illustrating dummy read of I2DR (interrupt function disabled) *

**************************************************************************/

/* Clear I2CR.MTX to put the module in receive mode */

MCF_I2C_I2CR &= 0xEF;

/* Dummy read of I2DR to signal the module is ready for the next byte */

dummy_read = MCF_I2C_I2DR;

Advertising
This manual is related to the following products: