This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIVA TM4C1294XL interfacing with MLX90614 temperature IR

Hey guys,

I have got my head around the infrared temperature sensor MLX90614, but have a hard time interfacing it to my TIVA TM4C1294XL microcontroller.

I was previously looking through following forum section, but did not find an answer:

And therefore I am writing here. I am setting up the microcontroller as following:

void inituC(void)
{
	//g_ui32SysClock = MAP_SysCtlClockFreqSet(SYSCTL_OSC_INT |
	//										SYSCTL_USE_PLL | SYSCTL_CFG_VCO_320, 40000000);

	g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
												 SYSCTL_OSC_MAIN   | SYSCTL_USE_PLL |
												 SYSCTL_CFG_VCO_480), 120000000);

		SysCtlDelay(60000);

		SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	    SysCtlDelay(30);

	    IntMasterEnable();
}

I2C connections in following code:

void initI2C(void)
{
    //
    // Enable Peripheral Clocks
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);

    //
    // Enable pin PB3 for I2C0 I2C0SDA
    //
    MAP_GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    MAP_GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);

    //
    // Enable pin PB2 for I2C0 I2C0SCL
    //
    MAP_GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    MAP_GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);

    //
	// Initialize Master
	//
	//SMBusMasterInit(&g_sMaster, I2C0_BASE, g_ui32SysClock);
	//SMBusMasterIntEnable(&g_sMaster);

    //MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_10MA, GPIO_PIN_TYPE_OD);
    //MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_10MA, GPIO_PIN_TYPE_OD);
    MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_DIR_MODE_HW);
    MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_DIR_MODE_HW);

	//
	// Initialize Master
	//
	I2CMasterInitExpClk(I2C0_BASE, g_ui32SysClock, false);

}

And my program:

void main(void)
{
	inituC();
	initI2C();

	while(1)
	{
		
		ReceivedByte = I2CReceiveBurst(TargetAddress, Command);
		
	}
uint32_t I2CReceiveBurst(uint8_t slave_addr, uint8_t reg)
{
    //specify that we are writing (a register address) to the
    //slave device
    I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);

    //specify register to be read
    I2CMasterDataPut(I2C0_BASE, reg);

    //send control byte and register address byte to slave device
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //specify that we are going to read from slave device
    I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, true);

    //send control byte and read from the register we
    //specified
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //return data pulled from the specified register
    DataByteLow = I2CMasterDataGet(I2C0_BASE);

    //send control byte and read from the register we
    //specified
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //return data pulled from the specified register
    DataByteHigh = I2CMasterDataGet(I2C0_BASE);

    //send control byte and read from the register we
    //specified
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);

    //wait for MCU to finish transaction
    while(I2CMasterBusy(I2C0_BASE));

    //return data pulled from the specified register
    PEC = I2CMasterDataGet(I2C0_BASE);

    return (DataByteHigh<<8)+DataByteLow;
}
}

The issue is, that the return value ALWAYS is 0xFFFF and that was mentioned as well to be a possible error in the other forum post. He did however not tell the working code, and I am suspecting what he changed to make it work. 


Does anyone have an idea what might be wrong / lacking here?
I also read from the other article, that it might help lowering the clock frequency. Can it be, that the clock can be set at 16 MHz for the TIVA TM4C1294XL? Or just 40 Mhz? Because I tried that, without working.
Thanks a lot for the help!