AnsweredAssumed Answered

I2c data reading problem of MC9S12XHZ512

Question asked by Seema Saini on Feb 27, 2010
Latest reply on Mar 8, 2010 by Seema Saini

hi

   I have interfaced RTC (I2C based) to above microcontroller.I am able to write data into RTC but can read only once.

After reading data once it goes to busy state and then don't read or write,

Although I have set repaet start condition.I am using code for reading is like.

 

IIC0_IBCR_TXAK = 0;
IIC0_IBCR |= 0x30;

IIC0_IBDR = M41T00_ID;
while (!IIC0_IBSR_IBIF);
IIC0_IBSR_IBIF=1;
while(IIC0_IBSR_RXAK);


IIC0_IBDR = Address;
while (!IIC0_IBSR_IBIF);
IIC0_IBSR_IBIF=1;
while(IIC0_IBSR_RXAK);
IIC0_IBCR_RSTA = 1; 


IIC0_IBDR = 0xD1;
while (!IIC0_IBSR_IBIF);
IIC0_IBSR_IBIF=1;
while (IIC0_IBSR_RXAK);

 

 IIC0_IBCR_TX_RX = 0;
 IIC0_IBCR_TXAK = 1; 
RD_data = IIC0_IBDR;
 while (!IIC0_IBSR_IBIF);
 IIC0_IBSR_IBIF=1; 


  RD_data = IIC0_IBDR;
 IIC0_IBCR_MS_SL = 0;
 IIC0_IBDR=0x00;

 

 

Anyone has any idea,please let me know.

Thanks in advance

SARY

Outcomes