I
the below code is not working for me -
UCB1CTL1 |= UCTR;
I2CStart();
SendByte(0x00);
SendByte(0xff);
SendByte(0xAf);
I2CStop();
__delay_cycles(1000);
I2CStart();
SendByte(0x00);
SendByte(0xff);
UCB1CTL1 &= ~UCTR;
I2CStart();
while (!(UCB1IFG&UCRXIFG)); //this loop is not ending
UCB1IFG &= ~UCRXIFG;
rxbuff[0] = UCB1RXBUF;
while this code below is working -
UCB1CTL1 |= UCTR;
I2CStart();
SendByte(0x00);
SendByte(0xff);
SendByte(0xAf);
I2CStop();
__delay_cycles(1000);
I2CStart();
SendByte(0x00);
SendByte(0xff);
I2CStop();
UCB1CTL1 &= ~UCTR;
I2CStart();
while (!(UCB1IFG&UCRXIFG));
UCB1IFG &= ~UCRXIFG;
rxbuff[0] = UCB1RXBUF;
those are the func for both codes -
void I2CStart(void)
{
UCB1CTL1 |= UCTXSTT; // I2C TX, start condition
}
void I2CStop(void)
{
UCB1CTL1 |= UCTXSTP; // I2C TX, stop condition
}
void SendByte(unsigned char Sbyte)
{
UCB1TXBUF= Sbyte;
while(!(UCB1IFG&UCTXIFG));
UCB1IFG &= ~UCTXIFG;
while(UCB1CTL1&UCTXSTT);
__delay_cycles(500);
}
my qustion is, how can i do a random read with a dummy write and restart condition for reading and without the stop condition part
Thanks,
Oz