Other Parts Discussed in Thread: HALCOGEN, TMP468
Tool/software: Code Composer Studio
Hello,
I'm brand new to i2c and have an idea of what's required to read from a slave device using a master, however I am struggling to successfully code my pseudocode.
I'm wanting to read the local temperature sensor on the TI TMP468 using the TMS50ls1227PGE's i2c bus. I've enabled the i2c driver, pinmux, and enabled all of the i2c interrupts in HalCoGen.
In CCS, I've typed the following code within a FreeRTOS task (I did i2cInit() in main):
/* Set direction to receiver */ i2cSetDirection(i2cREG1, I2C_TRANSMITTER); i2cSetMode(i2cREG1, I2C_MASTER); i2cSetSlaveAdd(i2cREG1, 0b1001000); i2cSetStart(i2cREG1); //start bit i2cSendByte(i2cREG1, 0b10010000); //write to address 1001000, the address of the temperature sensor i2cSendByte(i2cREG1, 0b00000000); //the internal temperature sensor is at register 0 i2cSetStart(i2cREG1); // resend the start bit i2cSendByte(i2cREG1, 0b10010001); //read from device 1001000 while(i2cIsRxReady(i2cREG1)){}; //wait until clear i2cSetDirection(i2cREG1, I2C_RECEIVER); //set i2c to receive data data = i2cReceiveByte(i2cREG1); //receive byte from register i2cSetStop(i2cREG1); //send stop bit
I'm not seeing any activity in my data variable and when I debug my code is always stuck inside of i2cSendByte at the "while ((i2c->STR & (uint32)I2C_TX_INT) == 0U)"
I'm not really sure where to go from here, any ideas or obvious mistakes?
Thank you!