0
votes

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 pins. I've enabled the i2c driver, pinmux, and enabled all of the i2c interrupts in HalCoGen. For reference, all non-standard functions are defined in TI's i2c.c file.

In CCS, I've typed the following code within a FreeRTOS task (I did i2cInit() in main):

i2cSetMode(i2cREG1, I2C_MASTER);

    /* Set direction to receiver */
    i2cSetDirection(i2cREG1, I2C_TRANSMITTER);

    i2cSetStart(i2cREG1); //start bit

    i2cSetSlaveAdd(i2cREG1, 0b1001000); //address of temp sensor
    while(i2cIsTxReady(i2cREG1)){}; //wait until flag is clear
    i2cSendByte(i2cREG1, 0b00000000); //register to read from 

    i2cSetStart(i2cREG1); 
    i2cSendByte(i2cREG1, 0b10010001); //read from sensor

    i2cSetDirection(i2cREG1, I2C_RECEIVER);
    while(i2cIsRxReady(i2cREG1)){};
    data = i2cReceiveByte(i2cREG1); //read data

    i2cSetStop(i2cREG1); //stop bit

I'm not seeing any activity in my data variable and when I debug my code is always stuck inside of void i2cInterrupt() at:

uint32 vec = (i2cREG1->IVR & 0x00000007U);

I'm not really sure where to go from here, any ideas or obvious mistakes?

Thanks!

1

1 Answers

2
votes

I would recommend first trying to read from a register with non-changing contents: in the case of tmp468, that would be address FE, which contains Manufacturer's ID of 0x5449. That will allow you to "wring out" your I2C code.

(By the way, you may also want to ask this question in the http://e2e.ti.com/support/microcontrollers/hercules/ forum.)