Hello, i am working with the Hercules and i can't read from I2C bus.
I write the next code (previously i configured the device with HalCoGen 3.09.00):
void main(void)
{
/* USER CODE BEGIN (3) */
i2cInit();
//Config
i2cREG1 -> MDR |= I2C_TRANSMITTER;
i2cSetSlaveAdd(i2cREG1,0x48);
i2cSetCount(i2cREG1, 1);
i2cSetStop(i2cREG1);
//send
i2cSetStart(i2cREG1);
i2cSendByte(i2cREG1, 0x00);
//reconfig
i2cSetMode(i2cREG1,I2C_MASTER);
i2cREG1 -> MDR |= I2C_RECEIVER;
i2cSetSlaveAdd(i2cREG1,0x48);
i2cSetCount(i2cREG1, 1);
i2cSetStop(i2cREG1);
//recive
i2cSetStart(i2cREG1);
a=i2cReceiveByte(i2cREG1);
while(1)
{
}
/* USER CODE END */
}
When i send bytes the i2c works, but i try to receive i have problems. I saw the bit frame the device sends the direction and the R/W bit low and don't receive anything.
I'm trying to comunicate to TMP275 temperature sensor.
Thanks