micropad
Member
Dear Rogers,
Thanks for the reply
I identified a problem with my I2CRead() subroutine, but it is working. please see below I2C Read() subroutine
In the above code the FOR loop is placing in wrong place, but it is working
and see below codes. I put for loop in correct location,but it does not working
Please advice
Thanks in advance
Thanks for the reply
I identified a problem with my I2CRead() subroutine, but it is working. please see below I2C Read() subroutine
Code:
void I2Cread(){
for(i=0;i<8;i++){
I2CStart();
I2CSend(0xD0); /* Send slave address with write */ /* Send address for dummy write operation *//* this address is actually where we are going to read from */
I2CSend(0x00); /* Send a repeated start, after a dummy write to start reading */
I2CRestart();
I2CSend(0xD1); /* send slave address with read bit set */
I2CData[i] = I2CRead(); /* read a byte */ /* ACK if its not the last byte to read */
}
I2CStop(); /* Send stop */
}
In the above code the FOR loop is placing in wrong place, but it is working
and see below codes. I put for loop in correct location,but it does not working
Code:
void I2Cread(){
I2CStart();
I2CSend(0xD0); /* Send slave address with write */ /* Send address for dummy write operation *//* this address is actually where we are going to read from */
I2CSend(0x00); /* Send a repeated start, after a dummy write to start reading */
I2CRestart();
I2CSend(0xD1); /* send slave address with read bit set */
for(i=0;i<8;i++) {
I2CData[i] = I2CRead(); /* read a byte */ /* ACK if its not the last byte to read */
}
I2CStop(); /* Send stop */
}
Please advice
Thanks in advance
Last edited: