> How do I address I2FDR? How so I set the I2FDR to a particular value?
Your development environment sure have either
(case 1) define or
(case 2) C structure, which allows access to any register of a peripheral controller.
In the first case, you where the ready-made define of I2FDR symbol is available, you can use similar to
volatile BYTE * pI2FDR = I2FDR;
*pI2FDR = 0x36;
In second case, where I2FDR is available as part of the C structure, you can use similar to
sim.i2c.fdr = 0x36;
> Will I2FDR = 0x36 work?
Yes, if your development environment has define similar to
#define I2FDR (sim.i2c.fdr)
> I want the clock frequency to be 400KHz. Should I set I2FDR with 0x36 or 0x37?
Which internal bus clock do you have?
For example, mcf5270 with core (system) clock Fsys=147.456 MHz, the calculated divider is
IC = (Fsys/2)/Fsck = (147.456 MHz) / 2 / (0.4 MHz) = 184.32
Thus, the nearest integer value of the divider, which results in Fsck<=400 kHz, is 185.
> set I2CR.
> question : How do I address single bit in this register? I want the processor to be in Master mode,
> it will receive data from I2C device.
In the first case, where the ready-made define of I2FDR symbol is available. You can use similar to
volatile BYTE * pI2CR = I2CR;
*pI2CR |= 0x20;
In second case, where I2CR is available as part of the C structure, you can use similar to
sim.i2c.cr |= 0x20;
> But while transmitting device address, does the processor need to be in transmitter mode and then switch to receiver mode?
In i2c protocol, transmit and receive are physically simultaneous. But, most of i2c libraries send START condition together with SLAVE_ADDRESS word by calling transmit_slave_address() function, and receive the data from the slave by receive_slave_data() function.
> What about acknowledge signal? Do i have to generate it every time or it is generated automatically?
To transmit the acknowledge bit, you need bit I2CR[TXAK] be zero before or simuntaneously with setting bit I2CR[MSTA].
> question: Do i need to set and clear any flag/bit from I2SR while reading data from I2DR?
No. But, you need verify I2SR[IBB]=0.
> Am I right about the above procedure? if not please let me know the correct procedure.
See examples in the Reference Manual.