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.

EK-TM4C1294XL: Problem with LM75A sensor I2C comminication

Part Number: EK-TM4C1294XL
Other Parts Discussed in Thread: LM75A

Hello ;

We aim to use LM75A sensor to measure temperature . We couldnt make i2c comminication between sensor and our controller card . Main problem is that we cant build i2c pins . We follow instructions for tiva c series for our card . When we observe on oscilloscope , we cant see clock wave on SCL line . 

We have slave address that is 0x00 . We connect sensor address pins to ground . 

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "inc/tm4c129xnczad.h"

#include <Wire.h>
#define SLAVE_ADDRESS 0x00


void setup() {
  Serial.begin(9600);
  Serial.print("asd0");
  GPIOPinConfigure(GPIO_PK6_I2C4SCL);
    GPIOPinConfigure(GPIO_PK7_I2C4SDA);
    

    GPIOPinTypeI2C(GPIO_PORTK_BASE, (1 << 7));       // Configures SDA
    GPIOPinTypeI2CSCL(GPIO_PORTK_BASE, (1 << 6));    // Configures SCL
    
Serial.print("test1");
   I2CMasterInitExpClk(I2C4_BASE, g_ui32SysClock, false);

   I2CSlaveEnable(I2C4_BASE);
   Serial.print("test2");
    I2CSlaveInit(I2C4_BASE, SLAVE_ADDRESS);
   I2CMasterSlaveAddrSet(I2C4_BASE, SLAVE_ADDRESS, false);
    Serial.print("test3");
   
}

  • First, do you have pull-up resistors on both SDA and SCL? Second, I see you configure the I2C4 as a master, but I do not see a call to "I2CMasterDataPut(). Is that in a different part of your code?
  • #include <stdarg.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_i2c.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "driverlib/i2c.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include <inc/hw_ints.h>
    #include "driverlib/interrupt.h"
    /**
     * main.c
     */
    
    
    //#define SLAVE_ADDRESS 0x3C
    
    
    int main(void)
    {
    
        volatile  uint32_t  result;
    int  ui32SysClock;
        //Enable GPIO for Configuring the I2C Interface Pins
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
        
        // Wait for the Peripheral to be ready for programming
        
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOL)
        || !SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOK));
        
        // Configure Pins for I2C2 Master Interface
        
        GPIOPinConfigure(GPIO_PL1_I2C2SCL);
        GPIOPinConfigure(GPIO_PL0_I2C2SDA);
        GPIOPinTypeI2C(GPIO_PORTL_BASE, GPIO_PIN_0);
        GPIOPinTypeI2CSCL(GPIO_PORTL_BASE, GPIO_PIN_1);
        
        // Configure Pins for I2C3 Slave Interface
        
        GPIOPinConfigure(GPIO_PK4_I2C3SCL);
        GPIOPinConfigure(GPIO_PK5_I2C3SDA);
        GPIOPinTypeI2C(GPIO_PORTK_BASE, GPIO_PIN_5);
        GPIOPinTypeI2CSCL(GPIO_PORTL_BASE, GPIO_PIN_4);
    
        I2CMasterInitExpClk(I2C2_BASE, SysCtlClockGet(), false);
    
       ////////////////////////////////////////
    
    
    
    ////////////////////////////////////
    
    	
    	// Setup System Clock for 120MHz
    	
    	ui32SysClock = SysCtlClockFreqSet((SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_XTAL_25MHZ |
    	SYSCTL_CFG_VCO_480), 120000000);
    	
    	// Stop the Clock, Reset and Enable I2C Module
    	// in Master Function
    	//
    	SysCtlPeripheralDisable(SYSCTL_PERIPH_I2C2);
    	SysCtlPeripheralReset(SYSCTL_PERIPH_I2C2);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C2);
    	
    	// Wait for the Peripheral to be ready for programming
    	
    	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C2));
    	
    	// Initialize and Configure the Master Module
    	
    	I2CMasterInitExpClk(I2C2_BASE, ui32SysClock, false);
    	
    	// Enable Interrupts for Arbitration Lost, Stop, NAK, Clock Low
    	// Timeout and Data.
    	
    	I2CMasterIntEnableEx(I2C2_BASE, (I2C_MASTER_INT_ARB_LOST |
    	I2C_MASTER_INT_STOP | I2C_MASTER_INT_NACK |
    	I2C_MASTER_INT_TIMEOUT | I2C_MASTER_INT_DATA));
    	
    	// Enable the Interrupt in the NVIC from I2C Master
    	
    	IntEnable(INT_I2C2);
    
    #define SLAVE_ADDRESS_EXT 0x33
    #define NUM_OF_I2CBYTES 255
    
    	    I2CMasterSlaveAddrSet(I2C2_BASE, SLAVE_ADDRESS_EXT, false);
    
    
    
    
    	 while(1)
    	    {
    	       
    
    	        I2CMasterDataPut(I2C2_BASE, 0x33);
    	        I2CMasterControl(I2C2_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    
    	        // Wait until the slave has received and acknowledged the data.
    	        
    	        while(!(I2CSlaveStatus(I2C3_BASE) & I2C_SLAVE_ACT_RREQ));
    	        
    	        // Read the data from the slave.
    	       
    	        result = I2CSlaveDataGet(I2C3_BASE);
    	        
    	        // Wait until master module is done transferring.
    	        
    	        while(I2CMasterBusy(I2C3_BASE));
    	        
    	       
    	    }
    
    
    
    	return 0;
    
    }
    

    All of my code here . I use your advices but still doesnt work . Do I have any mistake that you catch or need to do ?