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.
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)
// 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_CONTROL= TWI_ENA | PRESCALE120M;
*pTWI_CLKDIV=CLKLOW(50) | CLKHI(50);
*pTWI_MASTER_CTL=(2<<6) | MEN | RSTART | MDIR;
// while(*pTWI_FIFO_STAT != 0X0004)
u8 rcv_data= *pTWI_RCV_DATA8;
I don't know what is wrong with my code