AnsweredAssumed Answered

TWI/I2C repeat start read ADP5585 on BF537

Question asked by Sudhanshu on Oct 11, 2013
Latest reply on Oct 17, 2013 by Prashant

Dear Sir,


I am trying to use ADP5585 as keypad decoder being used in our Project. I have successfully written data to it using I2C Interface. But I am having trouble reading data from it using repeated start. I don't know why I am not able to read data from ADP5585, to start with reading Address 0x00 on ADP5585  which should give me 0x22. I dont know what is wrong in my code, it just reads 0x00. Can anybody please help me out?


I am calling I2C_Read(0x34, 0x00) and the result is 0x00..


The single byte read sequence conditions needed to read data from ADP5585 is shown below.

Single Byte Read Sequence-Repeat Start.PNG

The 'C' subroutine for reading the data from I2C is shown below and I call it by using

u8 registerValue= I2C_Readw(u8 0x34, 0x00);


/*I2C Read function*/


u8 I2C_Readw( u8 slaveAddress, u8 registerAddress)


          u8  status=0;

//     int i, j;


          *pTWI_FIFO_CTL |= XMTFLUSH;          //clear TX FIFO

          *pTWI_FIFO_CTL |= RCVFLUSH;          //clear RX FIFO



          *pTWI_MASTER_STAT= BUFWRERR | BUFRDERR | DNAK | ANAK | LOSTARB;          //clear status






          *pTWI_CLKDIV=CLKLOW(50) | CLKHI(50);



          *pTWI_MASTER_ADDR= slaveAddress;




          *pTWI_MASTER_CTL=(2<<6) | MEN | RSTART | MDIR;





// while(*pTWI_FIFO_STAT != 0X0004)

// ssync();




          u8 rcv_data= *pTWI_RCV_DATA8;



I don't know what is wrong with my code